Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] stock_quant_package_product_packaging: Migration to 16.0 #1103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/stock_quant_package_product_packaging/setup.py
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,
)
79 changes: 79 additions & 0 deletions stock_quant_package_product_packaging/README.rst
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.
1 change: 1 addition & 0 deletions stock_quant_package_product_packaging/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_quant_package_product_packaging/__manifest__.py
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"],
}
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 ""
2 changes: 2 additions & 0 deletions stock_quant_package_product_packaging/models/__init__.py
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 stock_quant_package_product_packaging/models/stock_move_line.py
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
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 stock_quant_package_product_packaging/readme/CONTRIBUTORS.rst
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>
7 changes: 7 additions & 0 deletions stock_quant_package_product_packaging/readme/DESCRIPTION.rst
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.
Loading