diff --git a/purchase_lot/README.rst b/purchase_lot/README.rst new file mode 100644 index 00000000000..2bd8f462937 --- /dev/null +++ b/purchase_lot/README.rst @@ -0,0 +1,96 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============ +Purchase Lot +============ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3f42d6b0819dc3443606dd38144343955f224d6ddc5f7bf72a8047eb1df48096 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_lot + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_lot + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the lot_id field in the purchase order lines, and +propagates it to stock pickings in the order confirmation. + +This module can also be used along with sale_order_lot_selection to +propagate lot from sale orders to purchase orders. It allows to buy +specific lot for a sale order (may be useful for fully configurable +products) + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion + +Contributors +------------ + +- Florian Dacosta +- David BEAL +- Alejandro Parrales + +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-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px + :target: https://github.com/florian-dacosta + :alt: florian-dacosta + +Current `maintainer `__: + +|maintainer-florian-dacosta| + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_lot/__init__.py b/purchase_lot/__init__.py new file mode 100644 index 00000000000..83e553ac462 --- /dev/null +++ b/purchase_lot/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/purchase_lot/__manifest__.py b/purchase_lot/__manifest__.py new file mode 100644 index 00000000000..0aa84841a32 --- /dev/null +++ b/purchase_lot/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2022 Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Lot", + "version": "19.0.1.0.0", + "category": "Purchase", + "license": "AGPL-3", + "author": "Akretion, Odoo Community Association (OCA)", + "maintainers": ["florian-dacosta"], + "website": "https://github.com/OCA/purchase-workflow", + "depends": ["purchase_stock", "stock_restrict_lot"], + "data": [ + "views/purchase_order_view.xml", + ], + "installable": True, +} diff --git a/purchase_lot/i18n/es.po b/purchase_lot/i18n/es.po new file mode 100644 index 00000000000..fc3b80958b1 --- /dev/null +++ b/purchase_lot/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-03 13:40+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea de Orden de Compra" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "Número de Serie" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "Regla de existencias" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "" diff --git a/purchase_lot/i18n/hr.po b/purchase_lot/i18n/hr.po new file mode 100644 index 00000000000..f12d21e0d48 --- /dev/null +++ b/purchase_lot/i18n/hr.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-09-29 10:42+0000\n" +"Last-Translator: vladimiruvid \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "Osigurajte sljedivost uskladištivog proizvoda u vašem skladištu." + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Stavka Narudžbenice" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "Lot / SN" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "Skladišno pravilo" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "Praćenje" diff --git a/purchase_lot/i18n/hr_HR.po b/purchase_lot/i18n/hr_HR.po new file mode 100644 index 00000000000..125d3dcda98 --- /dev/null +++ b/purchase_lot/i18n/hr_HR.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: hr_HR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "" diff --git a/purchase_lot/i18n/it.po b/purchase_lot/i18n/it.po new file mode 100644 index 00000000000..bd288c21196 --- /dev/null +++ b/purchase_lot/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-05-27 08:40+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "Assicura la tracciabilità di un prodotto stoccabile nel magazzino." + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Riga ordine di acquisto" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "Numero seriale" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "Regola di giacenza" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "Tracciamento" diff --git a/purchase_lot/i18n/pt_BR.po b/purchase_lot/i18n/pt_BR.po new file mode 100644 index 00000000000..73b0d4ad826 --- /dev/null +++ b/purchase_lot/i18n/pt_BR.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" + +#. module: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "" diff --git a/purchase_lot/i18n/purchase_lot.pot b/purchase_lot/i18n/purchase_lot.pot new file mode 100644 index 00000000000..c2c2a30051f --- /dev/null +++ b/purchase_lot/i18n/purchase_lot.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: purchase_lot +#: model:ir.model.fields,help:purchase_lot.field_purchase_order_line__tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__lot_id +#: model_terms:ir.ui.view,arch_db:purchase_lot.view_purchase_order_filter +msgid "Serial Number" +msgstr "" + +#. module: purchase_lot +#: model:ir.model,name:purchase_lot.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_lot +#: model:ir.model.fields,field_description:purchase_lot.field_purchase_order_line__tracking +msgid "Tracking" +msgstr "" diff --git a/purchase_lot/models/__init__.py b/purchase_lot/models/__init__.py new file mode 100644 index 00000000000..708b29a13a6 --- /dev/null +++ b/purchase_lot/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import purchase_order_line +from . import stock_rule diff --git a/purchase_lot/models/purchase_order_line.py b/purchase_lot/models/purchase_order_line.py new file mode 100644 index 00000000000..cc17b57caee --- /dev/null +++ b/purchase_lot/models/purchase_order_line.py @@ -0,0 +1,75 @@ +# Copyright (C) 2022 Akretion (). +# @author David BEAL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class PurchaseOrderLine(models.Model): + _inherit = "purchase.order.line" + + lot_id = fields.Many2one("stock.lot", string="Serial Number", copy=False) + tracking = fields.Selection(related="product_id.tracking") + + @api.model + def _prepare_purchase_order_line_from_procurement( + self, + product_id, + product_qty, + product_uom, + location_dest_id, + name, + origin, + company_id, + values, + po, + ): + vals = super()._prepare_purchase_order_line_from_procurement( + product_id, + product_qty, + product_uom, + location_dest_id, + name, + origin, + company_id, + values, + po, + ) + lot_id = values.get("restrict_lot_id") + if lot_id: + vals["lot_id"] = lot_id + return vals + + def _prepare_stock_move_vals( + self, picking, price_unit, product_uom_qty, product_uom + ): + vals = super()._prepare_stock_move_vals( + picking, price_unit, product_uom_qty, product_uom + ) + if self.lot_id: + vals["restrict_lot_id"] = self.lot_id.id + return vals + + def _find_candidate( + self, + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ): + lot_id = values.get("restrict_lot_id", False) + self = self.filtered(lambda line: line.lot_id.id == lot_id) + return super()._find_candidate( + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ) diff --git a/purchase_lot/models/stock_rule.py b/purchase_lot/models/stock_rule.py new file mode 100644 index 00000000000..9861f60a1d3 --- /dev/null +++ b/purchase_lot/models/stock_rule.py @@ -0,0 +1,16 @@ +# Copyright (C) 2022 Akretion (). +# @author David BEAL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + @api.model + def _get_procurements_to_merge_groupby(self, procurement): + return ( + procurement.values.get("restrict_lot_id"), + super()._get_procurements_to_merge_groupby(procurement), + ) diff --git a/purchase_lot/pyproject.toml b/purchase_lot/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_lot/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_lot/readme/CONTRIBUTORS.md b/purchase_lot/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..960c9118f3c --- /dev/null +++ b/purchase_lot/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Florian Dacosta \<\> +- David BEAL \<\> +- Alejandro Parrales \<\> diff --git a/purchase_lot/readme/DESCRIPTION.md b/purchase_lot/readme/DESCRIPTION.md new file mode 100644 index 00000000000..b5c88779962 --- /dev/null +++ b/purchase_lot/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +This module adds the lot_id field in the purchase order lines, +and propagates it to stock pickings in the order confirmation. + +This module can also be used along with sale_order_lot_selection to propagate lot from sale orders to purchase orders. +It allows to buy specific lot for a sale order (may be useful for fully configurable products) diff --git a/purchase_lot/static/description/icon.png b/purchase_lot/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_lot/static/description/icon.png differ diff --git a/purchase_lot/static/description/index.html b/purchase_lot/static/description/index.html new file mode 100644 index 00000000000..009306b880a --- /dev/null +++ b/purchase_lot/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Purchase Lot

+ +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This module adds the lot_id field in the purchase order lines, and +propagates it to stock pickings in the order confirmation.

+

This module can also be used along with sale_order_lot_selection to +propagate lot from sale orders to purchase orders. It allows to buy +specific lot for a sale order (may be useful for fully configurable +products)

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

florian-dacosta

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/purchase_lot/tests/__init__.py b/purchase_lot/tests/__init__.py new file mode 100644 index 00000000000..1becf8a73ed --- /dev/null +++ b/purchase_lot/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_lot diff --git a/purchase_lot/tests/test_purchase_lot.py b/purchase_lot/tests/test_purchase_lot.py new file mode 100644 index 00000000000..6c07bbb2809 --- /dev/null +++ b/purchase_lot/tests/test_purchase_lot.py @@ -0,0 +1,118 @@ +# Copyright (C) 2022 Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPurchaseLot(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_id = cls.env["res.partner"].create({"name": "Test Supplier"}) + cls.customer_loc = cls.env.ref("stock.stock_location_customers") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.large_cabinet = cls.env["product.product"].create( + { + "name": "Test Product Lot", + "type": "consu", + } + ) + buy_route = cls.env.ref("purchase_stock.route_warehouse0_buy") + mto_route = cls.env.ref("stock.route_warehouse0_mto") + mto_route.write({"active": True}) + # ensure full make to order and not mts or mto + mto_route.rule_ids.write({"procure_method": "make_to_order"}) + cls.large_cabinet.write( + { + "route_ids": [(4, buy_route.id, 0), (4, mto_route.id, 0)], + "tracking": "lot", + } + ) + cls.env["product.supplierinfo"].create( + { + "product_tmpl_id": cls.large_cabinet.product_tmpl_id.id, + "product_id": cls.large_cabinet.id, + "partner_id": cls.partner_id.id, + } + ) + cls.out_picking_type = cls.env.ref("stock.picking_type_out") + cls.lot1 = cls.env["stock.lot"].create( + { + "name": "lot1", + "product_id": cls.large_cabinet.id, + "company_id": cls.warehouse.company_id.id, + } + ) + cls.lot2 = cls.env["stock.lot"].create( + { + "name": "lot2", + "product_id": cls.large_cabinet.id, + "company_id": cls.warehouse.company_id.id, + } + ) + + def test_purchase_lot(self): + group = self.env["stock.reference"].create({"name": "My test delivery"}) + vals_list = [ + { + "product_id": self.large_cabinet.id, + "location_id": self.warehouse.lot_stock_id.id, + "location_dest_id": self.customer_loc.id, + "product_uom_qty": 1, + "product_uom": self.large_cabinet.uom_id.id, + "description_picking": "test", + "procure_method": "make_to_order", + "warehouse_id": self.warehouse.id, + "restrict_lot_id": self.lot1.id, + "picking_type_id": self.out_picking_type.id, + "reference_ids": [(4, group.id)], + }, + { + "product_id": self.large_cabinet.id, + "location_id": self.warehouse.lot_stock_id.id, + "location_dest_id": self.customer_loc.id, + "product_uom_qty": 1, + "product_uom": self.large_cabinet.uom_id.id, + "description_picking": "test", + "procure_method": "make_to_order", + "warehouse_id": self.warehouse.id, + "restrict_lot_id": self.lot2.id, + "picking_type_id": self.out_picking_type.id, + "reference_ids": [(4, group.id)], + }, + ] + moves = self.env["stock.move"].create(vals_list) + moves._action_confirm() + pols = self.env["purchase.order.line"].search( + [("move_dest_ids", "in", moves.ids)] + ) + # not merged because of different lot + self.assertEqual(len(pols), 2) + pol1 = pols.filtered( + lambda line: line.move_dest_ids.restrict_lot_id.id == self.lot1.id + ) + self.assertEqual(pol1.lot_id.id, self.lot1.id) + pol1.order_id.button_confirm() + self.assertEqual(pol1.move_ids.restrict_lot_id.id, self.lot1.id) + + def test_purchase_lot_stock_propagation(self): + purchase = self.env["purchase.order"].create( + { + "partner_id": self.partner_id.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.large_cabinet.id, + "product_qty": 1.0, + "lot_id": self.lot1.id, + }, + ) + ], + } + ) + purchase.button_confirm() + picking = purchase.picking_ids[:1] + move = picking.move_ids[:1] + self.assertEqual(self.lot1, move.restrict_lot_id) diff --git a/purchase_lot/views/purchase_order_view.xml b/purchase_lot/views/purchase_order_view.xml new file mode 100644 index 00000000000..6333967ab8d --- /dev/null +++ b/purchase_lot/views/purchase_order_view.xml @@ -0,0 +1,53 @@ + + + + purchase.order + + + + + + + + + + + purchase.order.line + + + + + + + + + + + purchase.order + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..e69de29bb2d