Skip to content

Commit

Permalink
[ADD] stock_product_pack: new module
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestotejeda authored and Usdoo Wedoo committed Sep 18, 2021
1 parent 561183f commit 56a0d48
Show file tree
Hide file tree
Showing 13 changed files with 754 additions and 0 deletions.
110 changes: 110 additions & 0 deletions stock_product_pack/README.rst
@@ -0,0 +1,110 @@
==================
Stock product Pack
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--pack-lightgray.png?logo=github
:target: https://github.com/OCA/product-pack/tree/12.0/stock_product_pack
:alt: OCA/product-pack
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-pack-12-0/product-pack-12-0-stock_product_pack
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/286/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to get the right available *On Hand* and *Forecasted*
quantities of the packs.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to *Inventory -> Master Data -> Product*, create a product and check
"Is Pack?" field, then set the products has to include in the Pack.
#. Set type of product pack.


Usage
=====

To use this module, you need to:

#. Go to *Inventory -> Operations -> Transfers* and create transfer related to
components of a Pack 'X'.
#. Then go to *Inventory -> Master Data -> Product*, find the Pack 'X' and you
will see in the smart buttons that show *On Hand* and *Forecasted* the
quantities based on the *On Hand* and *Forecasted* quantities of
its components. That is the minimum quantities of its components.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-pack/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-pack/issues/new?body=module:%20stock_product_pack%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* NaN·tic
* ADHOC SA
* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
* Pedro M. Baeza
* Sergio Teruel

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-ernestotejeda| image:: https://github.com/ernestotejeda.png?size=40px
:target: https://github.com/ernestotejeda
:alt: ernestotejeda

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ernestotejeda|

This module is part of the `OCA/product-pack <https://github.com/OCA/product-pack/tree/12.0/stock_product_pack>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions stock_product_pack/__init__.py
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
24 changes: 24 additions & 0 deletions stock_product_pack/__manifest__.py
@@ -0,0 +1,24 @@
# Copyright 2019 NaN (http://www.nan-tic.com) - Àngel Àlvarez
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Stock product Pack',
'version': '12.0.1.0.0',
'category': 'Warehouse',
'summary': 'This module allows you to get the right available quantities '
'of the packs',
'website': 'https://github.com/OCA/product-pack',
'author': 'NaN·tic, '
'ADHOC SA, '
'Tecnativa, '
'Odoo Community Association (OCA)',
'maintainers': ['ernestotejeda'],
'license': 'AGPL-3',
'depends': [
'product_pack',
'stock',
],
'installable': True,
'auto_install': True,
'application': False,
}
22 changes: 22 additions & 0 deletions stock_product_pack/i18n/es.po
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_product_pack
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-09-18 14:54+0000\n"
"PO-Revision-Date: 2019-09-18 14:54+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_product_pack
#: model:ir.model,name:stock_product_pack.model_product_product
msgid "Product"
msgstr "Producto"

3 changes: 3 additions & 0 deletions stock_product_pack/models/__init__.py
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import product_product
37 changes: 37 additions & 0 deletions stock_product_pack/models/product_product.py
@@ -0,0 +1,37 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
import math


class ProductProduct(models.Model):
_inherit = 'product.product'

def _compute_quantities_dict(
self, lot_id, owner_id, package_id,
from_date=False, to_date=False):
res = super()._compute_quantities_dict(
lot_id, owner_id, package_id, from_date=from_date, to_date=to_date)
packs = self.filtered('pack_ok')
for product in packs.with_context(prefetch_fields=False):
pack_qty_available = []
pack_virtual_available = []
for subproduct in product.pack_line_ids:
subproduct_stock = subproduct.product_id
sub_qty = subproduct.quantity
if sub_qty:
pack_qty_available.append(math.floor(
subproduct_stock.qty_available / sub_qty))
pack_virtual_available.append(math.floor(
subproduct_stock.virtual_available / sub_qty))
res[product.id] = {
'qty_available': (
pack_qty_available and min(pack_qty_available) or False),
'incoming_qty': 0,
'outgoing_qty': 0,
'virtual_available': (
pack_virtual_available and
min(pack_virtual_available) or False),
}
return res
6 changes: 6 additions & 0 deletions stock_product_pack/readme/CONFIGURE.rst
@@ -0,0 +1,6 @@
To configure this module, you need to:

#. Go to *Inventory -> Master Data -> Product*, create a product and check
"Is Pack?" field, then set the products has to include in the Pack.
#. Set type of product pack.

5 changes: 5 additions & 0 deletions stock_product_pack/readme/CONTRIBUTORS.rst
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
* Pedro M. Baeza
* Sergio Teruel
2 changes: 2 additions & 0 deletions stock_product_pack/readme/DESCRIPTION.rst
@@ -0,0 +1,2 @@
This module allows you to get the right available *On Hand* and *Forecasted*
quantities of the packs.
8 changes: 8 additions & 0 deletions stock_product_pack/readme/USAGE.rst
@@ -0,0 +1,8 @@
To use this module, you need to:

#. Go to *Inventory -> Operations -> Transfers* and create transfer related to
components of a Pack 'X'.
#. Then go to *Inventory -> Master Data -> Product*, find the Pack 'X' and you
will see in the smart buttons that show *On Hand* and *Forecasted* the
quantities based on the *On Hand* and *Forecasted* quantities of
its components. That is the minimum quantities of its components.

0 comments on commit 56a0d48

Please sign in to comment.