-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by rousseldenis
- Loading branch information
Showing
16 changed files
with
754 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...p/stock_quant_package_product_packaging/odoo/addons/stock_quant_package_product_packaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_quant_package_product_packaging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
===================================== | ||
Stock Quant Package Product Packaging | ||
===================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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%2Fstock--logistics--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_quant_package_product_packaging | ||
:alt: OCA/stock-logistics-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_quant_package_product_packaging | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/154/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to define on a Product Package (`stock.quant.package`), a | ||
Packaging Type (`product.packaging`) that is linked to a product, if said | ||
package only contains Quants (`stock.quants`) from this product, and the sum of | ||
the quants quantities is equal to the Packaging quantity. | ||
|
||
If such a packaging exists, it will be automatically assigned to a package after | ||
the move is set to done. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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/stock-logistics-workflow/issues/new?body=module:%20stock_quant_package_product_packaging%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Akim Juillerat <akim.juillerat@camptocamp.com> | ||
|
||
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. | ||
|
||
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_quant_package_product_packaging>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Stock Quant Package Product Packaging", | ||
"summary": "Use product packagings on packages", | ||
"version": "16.0.1.0.0", | ||
"development_status": "Beta", | ||
"category": "Warehouse Management", | ||
"website": "https://github.com/OCA/stock-logistics-workflow", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["stock"], | ||
"data": ["views/stock_quant_package.xml"], | ||
} |
64 changes: 64 additions & 0 deletions
64
stock_quant_package_product_packaging/i18n/stock_quant_package_product_packaging.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_quant_package_product_packaging | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \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_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_move_line__display_name | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_move_line__id | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_move_line____last_update | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model,name:stock_quant_package_product_packaging.model_stock_quant_package | ||
msgid "Packages" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,help:stock_quant_package_product_packaging.field_stock_quant_package__product_packaging_id | ||
msgid "" | ||
"Packaging of the product, used for internal logisticstransfers, put-away " | ||
"rules, ..." | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model,name:stock_quant_package_product_packaging.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package__product_packaging_id | ||
msgid "Product Packaging" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package__single_product_id | ||
msgid "Single Product" | ||
msgstr "" | ||
|
||
#. module: stock_quant_package_product_packaging | ||
#: model:ir.model.fields,field_description:stock_quant_package_product_packaging.field_stock_quant_package__single_product_qty | ||
msgid "Single Product Qty" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import stock_quant_package | ||
from . import stock_move_line |
15 changes: 15 additions & 0 deletions
15
stock_quant_package_product_packaging/models/stock_move_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
def _action_done(self): | ||
res = super()._action_done() | ||
# _action_done in stock module sometimes delete a move line, we | ||
# have to check if it still exists before reading/writing on it | ||
for line in self.exists().filtered(lambda l: l.result_package_id): | ||
line.result_package_id.auto_assign_packaging() | ||
return res |
55 changes: 55 additions & 0 deletions
55
stock_quant_package_product_packaging/models/stock_quant_package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockQuantPackage(models.Model): | ||
|
||
_inherit = "stock.quant.package" | ||
|
||
# This is not the same thing as 'packaging_id': | ||
# * packaging_id is the "Package type", packaging which have | ||
# no 'product_id' and used for the delivery (postal 2kg, ...) | ||
# * product_packaging_id is the actual Product Packaging (usually | ||
# using a GTIN) used for the internal logistics/reception. It | ||
# has a product_id | ||
product_packaging_id = fields.Many2one( | ||
"product.packaging", | ||
"Product Packaging", | ||
index=True, | ||
help="Packaging of the product, used for internal logistics" | ||
"transfers, put-away rules, ...", | ||
) | ||
single_product_id = fields.Many2one( | ||
"product.product", compute="_compute_single_product" | ||
) | ||
single_product_qty = fields.Float(compute="_compute_single_product") | ||
|
||
@api.depends("quant_ids", "quant_ids.product_id") | ||
def _compute_single_product(self): | ||
for pack in self: | ||
pack_products = pack.quant_ids.mapped("product_id") | ||
if len(pack_products) == 1: | ||
pack.single_product_id = pack_products.id | ||
# TODO handle uom | ||
pack.single_product_qty = sum(pack.quant_ids.mapped("quantity")) | ||
else: | ||
pack.single_product_id = False | ||
pack.single_product_qty = 0 | ||
|
||
def auto_assign_packaging(self): | ||
for pack in self: | ||
if ( | ||
not pack.product_packaging_id | ||
and pack.single_product_id | ||
and pack.single_product_qty | ||
): | ||
packaging = self.env["product.packaging"].search( | ||
[ | ||
("product_id", "=", pack.single_product_id.id), | ||
("qty", "=", pack.single_product_qty), | ||
], | ||
limit=1, | ||
) | ||
if packaging: | ||
pack.write({"product_packaging_id": packaging.id}) |
3 changes: 3 additions & 0 deletions
3
stock_quant_package_product_packaging/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Akim Juillerat <akim.juillerat@camptocamp.com> | ||
* Fernando La Chica - GreenIce <fernandolachica@gmail.com> | ||
* Denis Roussel <denis.roussel@acsone.eu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This module allows to define on a Product Package (`stock.quant.package`), a | ||
Packaging Type (`product.packaging`) that is linked to a product, if said | ||
package only contains Quants (`stock.quants`) from this product, and the sum of | ||
the quants quantities is equal to the Packaging quantity. | ||
|
||
If such a packaging exists, it will be automatically assigned to a package after | ||
the move is set to done. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.