diff --git a/purchase_sale_lot_intercompany/README.rst b/purchase_sale_lot_intercompany/README.rst new file mode 100644 index 00000000000..473981bd852 --- /dev/null +++ b/purchase_sale_lot_intercompany/README.rst @@ -0,0 +1,90 @@ +============================== +Purchase Sale Lot Intercompany +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fcf43c16ff81db57eb3eee41701402c61c94c226ee53f1555f35e78796a00e03 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmulti--company-lightgray.png?logo=github + :target: https://github.com/OCA/multi-company/tree/16.0/purchase_sale_lot_intercompany + :alt: OCA/multi-company +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-purchase_sale_lot_intercompany + :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/multi-company&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to propagate lot numbers from a purchase to a sale line, in a multi-company context. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Check the "Lots/Serial Numbers propagated in sale" + +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 +~~~~~~~~~~~~ + +* Kévin Roche +* Guillaume MASSON + +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-Kev-Roche| image:: https://github.com/Kev-Roche.png?size=40px + :target: https://github.com/Kev-Roche + :alt: Kev-Roche + +Current `maintainer `__: + +|maintainer-Kev-Roche| + +This module is part of the `OCA/multi-company `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_sale_lot_intercompany/__init__.py b/purchase_sale_lot_intercompany/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_sale_lot_intercompany/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_sale_lot_intercompany/__manifest__.py b/purchase_sale_lot_intercompany/__manifest__.py new file mode 100644 index 00000000000..7dde1b1bf0a --- /dev/null +++ b/purchase_sale_lot_intercompany/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Sale Lot Intercompany", + "summary": "Intercompany PO/SO lot number propagation", + "version": "16.0.1.0.0", + "category": "Purchase Management", + "website": "https://github.com/OCA/multi-company", + "author": "Akretion, Odoo Community Association (OCA)", + "maintainers": ["Kev-Roche"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "purchase_lot", + "purchase_sale_stock_inter_company", + ], + "data": [ + "views/res_config_settings_views.xml", + ], +} diff --git a/purchase_sale_lot_intercompany/i18n/fr.po b/purchase_sale_lot_intercompany/i18n/fr.po new file mode 100644 index 00000000000..ab3a158a51f --- /dev/null +++ b/purchase_sale_lot_intercompany/i18n/fr.po @@ -0,0 +1,77 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_sale_lot_intercompany +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-03-13 18:52+0000\n" +"PO-Revision-Date: 2023-03-13 19:54+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.2.2\n" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model,name:purchase_sale_lot_intercompany.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model,name:purchase_sale_lot_intercompany.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de config" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_purchase_order__display_name +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_company__display_name +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_config_settings__display_name +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_stock_production_lot__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_purchase_order__id +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_company__id +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_config_settings__id +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_stock_production_lot__id +msgid "ID" +msgstr "" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_purchase_order____last_update +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_company____last_update +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_config_settings____last_update +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_stock_production_lot____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model,name:purchase_sale_lot_intercompany.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lot/N° série" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_company__propagated_serial_number +msgid "Lots/Serial Numbers are propogated in this company" +msgstr "Lot/N° série copiés dans cette société" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model.fields,field_description:purchase_sale_lot_intercompany.field_res_config_settings__propagated_serial_number +msgid "Lots/Serial Numbers propagated in sale" +msgstr "Lot/N° série copiés dans les commandes de ventes" + +#. module: purchase_sale_lot_intercompany +#: model_terms:ir.ui.view,arch_db:purchase_sale_lot_intercompany.res_config_settings_view_form +msgid "Propagated Lots from purchase to sale" +msgstr "Lot/N° série copiés des achats vers les commandes de ventes de cette société" + +#. module: purchase_sale_lot_intercompany +#: model:ir.model,name:purchase_sale_lot_intercompany.model_purchase_order +msgid "Purchase Order" +msgstr "Commande fournisseur" diff --git a/purchase_sale_lot_intercompany/models/__init__.py b/purchase_sale_lot_intercompany/models/__init__.py new file mode 100644 index 00000000000..bd5f714f7c9 --- /dev/null +++ b/purchase_sale_lot_intercompany/models/__init__.py @@ -0,0 +1,4 @@ +from . import purchase_order +from . import stock_production_lot +from . import res_company +from . import res_config_settings diff --git a/purchase_sale_lot_intercompany/models/purchase_order.py b/purchase_sale_lot_intercompany/models/purchase_order.py new file mode 100644 index 00000000000..f12b83549f0 --- /dev/null +++ b/purchase_sale_lot_intercompany/models/purchase_order.py @@ -0,0 +1,18 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# @author Guillaume MASSON +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + def _prepare_sale_order_line_data(self, purchase_line, dest_company, sale_order): + vals = super()._prepare_sale_order_line_data( + purchase_line, dest_company, sale_order + ) + if dest_company.propagated_serial_number and purchase_line.lot_id: + vals["lot_id"] = purchase_line.lot_id.get_inter_company_lot(dest_company).id + return vals diff --git a/purchase_sale_lot_intercompany/models/res_company.py b/purchase_sale_lot_intercompany/models/res_company.py new file mode 100644 index 00000000000..dfc8c922a38 --- /dev/null +++ b/purchase_sale_lot_intercompany/models/res_company.py @@ -0,0 +1,14 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# @author Guillaume MASSON +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + propagated_serial_number = fields.Boolean( + string="Lots/Serial Numbers are propogated in this company" + ) diff --git a/purchase_sale_lot_intercompany/models/res_config_settings.py b/purchase_sale_lot_intercompany/models/res_config_settings.py new file mode 100644 index 00000000000..dfcfd65c61b --- /dev/null +++ b/purchase_sale_lot_intercompany/models/res_config_settings.py @@ -0,0 +1,16 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# @author Guillaume MASSON +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + propagated_serial_number = fields.Boolean( + string="Lots/Serial Numbers propagated in sale", + related="company_id.propagated_serial_number", + readonly=False, + ) diff --git a/purchase_sale_lot_intercompany/models/stock_production_lot.py b/purchase_sale_lot_intercompany/models/stock_production_lot.py new file mode 100644 index 00000000000..6a8ddbe8b62 --- /dev/null +++ b/purchase_sale_lot_intercompany/models/stock_production_lot.py @@ -0,0 +1,29 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# @author Guillaume MASSON +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockProductionLot(models.Model): + _inherit = "stock.lot" + + def get_inter_company_lot(self, company): + self.ensure_one() + lot = self.sudo().search( + [ + ("name", "=", self.name), + ("product_id", "=", self.product_id.id), + ("company_id", "=", company.id), + ] + ) + if not lot: + lot = self.sudo().create( + { + "name": self.name, + "product_id": self.product_id.id, + "company_id": company.id, + } + ) + return lot diff --git a/purchase_sale_lot_intercompany/readme/CONTRIBUTORS.rst b/purchase_sale_lot_intercompany/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..dc476007e69 --- /dev/null +++ b/purchase_sale_lot_intercompany/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Kévin Roche +* Guillaume MASSON diff --git a/purchase_sale_lot_intercompany/readme/DESCRIPTION.rst b/purchase_sale_lot_intercompany/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..3c793ab11fe --- /dev/null +++ b/purchase_sale_lot_intercompany/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to propagate lot numbers from a purchase to a sale line, in a multi-company context. diff --git a/purchase_sale_lot_intercompany/readme/USAGE.rst b/purchase_sale_lot_intercompany/readme/USAGE.rst new file mode 100644 index 00000000000..d5d3f79c0ff --- /dev/null +++ b/purchase_sale_lot_intercompany/readme/USAGE.rst @@ -0,0 +1 @@ +Check the "Lots/Serial Numbers propagated in sale" diff --git a/purchase_sale_lot_intercompany/static/description/index.html b/purchase_sale_lot_intercompany/static/description/index.html new file mode 100644 index 00000000000..a47413ee719 --- /dev/null +++ b/purchase_sale_lot_intercompany/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Purchase Sale Lot Intercompany + + + +
+

Purchase Sale Lot Intercompany

+ + +

Beta License: AGPL-3 OCA/multi-company Translate me on Weblate Try me on Runboat

+

This module allows to propagate lot numbers from a purchase to a sale line, in a multi-company context.

+

Table of contents

+ +
+

Usage

+

Check the “Lots/Serial Numbers propagated in sale”

+
+
+

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
  • +
+
+ +
+

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:

+

Kev-Roche

+

This module is part of the OCA/multi-company project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_sale_lot_intercompany/tests/__init__.py b/purchase_sale_lot_intercompany/tests/__init__.py new file mode 100644 index 00000000000..0bf74e8ec18 --- /dev/null +++ b/purchase_sale_lot_intercompany/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_sale_lot_intercompany diff --git a/purchase_sale_lot_intercompany/tests/test_purchase_sale_lot_intercompany.py b/purchase_sale_lot_intercompany/tests/test_purchase_sale_lot_intercompany.py new file mode 100644 index 00000000000..44b5c0abee8 --- /dev/null +++ b/purchase_sale_lot_intercompany/tests/test_purchase_sale_lot_intercompany.py @@ -0,0 +1,31 @@ +# Copyright 2023 Akretion (https://www.akretion.com). +# @author Kévin Roche +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.purchase_sale_stock_inter_company.tests.test_inter_company_purchase_sale_stock import ( + TestPurchaseSaleStockInterCompany, +) + + +class TestPurchaseSaleLotIntercompany(TestPurchaseSaleStockInterCompany): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.lot_test = cls.env["stock.lot"].create( + { + "name": "lot_test", + "product_id": cls.product.id, + "company_id": cls.warehouse_a.company_id.id, + } + ) + cls.purchase_company_a.order_line[0].lot_id = cls.lot_test + + def test_with_propagated_serial_number(self): + self.company_b.propagated_serial_number = True + sale = self._approve_po() + self.assertEqual(sale.order_line[0].lot_id.name, "lot_test") + + def test_without_propagated_serial_number(self): + sale = self._approve_po() + self.assertFalse(sale.order_line[0].lot_id) diff --git a/purchase_sale_lot_intercompany/views/res_config_settings_views.xml b/purchase_sale_lot_intercompany/views/res_config_settings_views.xml new file mode 100644 index 00000000000..347fdc8d0bf --- /dev/null +++ b/purchase_sale_lot_intercompany/views/res_config_settings_views.xml @@ -0,0 +1,26 @@ + + + + res.config.settings.form.inherit + res.config.settings + + + + + + + + diff --git a/setup/purchase_sale_lot_intercompany/odoo/addons/purchase_sale_lot_intercompany b/setup/purchase_sale_lot_intercompany/odoo/addons/purchase_sale_lot_intercompany new file mode 120000 index 00000000000..40a3040f32d --- /dev/null +++ b/setup/purchase_sale_lot_intercompany/odoo/addons/purchase_sale_lot_intercompany @@ -0,0 +1 @@ +../../../../purchase_sale_lot_intercompany \ No newline at end of file diff --git a/setup/purchase_sale_lot_intercompany/setup.py b/setup/purchase_sale_lot_intercompany/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_sale_lot_intercompany/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)