diff --git a/grap_custom_import_purchase_discount/README.rst b/grap_custom_import_purchase_discount/README.rst index d1df468..e69de29 100644 --- a/grap_custom_import_purchase_discount/README.rst +++ b/grap_custom_import_purchase_discount/README.rst @@ -1,64 +0,0 @@ -==================================================================== -GRAP - Custom Import Product Supplierinfo Quantity Multiplier Module -==================================================================== - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:9b8df078c1fb893b68650c2ee64e375d840edd6d1f8f7bfdb0f1a4da37012215 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |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-grap%2Fgrap--odoo--import-lightgray.png?logo=github - :target: https://github.com/grap/grap-odoo-import/tree/16.0/grap_custom_import_product_supplierinfo_qty_multiplier - :alt: grap/grap-odoo-import - -|badge1| |badge2| |badge3| - -This module improve the "import" features provided by Odoo. - -* ``product.product``: - - * Allow to recover ``multiplier_qty`` field in the supplier info level. - -**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 -~~~~~~~ - -* GRAP - -Contributors -~~~~~~~~~~~~ - -* Sylvain LE GAL - -Maintainers -~~~~~~~~~~~ - -This module is part of the `grap/grap-odoo-import `_ project on GitHub. - -You are welcome to contribute. diff --git a/grap_custom_import_purchase_discount/models/custom_import_product_mixin.py b/grap_custom_import_purchase_discount/models/custom_import_product_mixin.py index bebbdc5..b97a914 100644 --- a/grap_custom_import_purchase_discount/models/custom_import_product_mixin.py +++ b/grap_custom_import_purchase_discount/models/custom_import_product_mixin.py @@ -11,5 +11,5 @@ class CustomImportProductMixin(models.AbstractModel): def _custom_import_prepare_supplierinfo_vals(self, partner, vals): res = super()._custom_import_prepare_supplierinfo_vals(partner, vals) - res["discount"] = vals.get("grap_import_supplier_discount_1") * 100 + res["discount"] = (vals.get("grap_import_supplier_discount_1") or 0.0) * 100 return res diff --git a/grap_custom_import_purchase_discount/tests/test_module.py b/grap_custom_import_purchase_discount/tests/test_module.py index 18fccc2..4334ab4 100644 --- a/grap_custom_import_purchase_discount/tests/test_module.py +++ b/grap_custom_import_purchase_discount/tests/test_module.py @@ -8,7 +8,7 @@ @tagged("post_install", "-at_install") -class TestModuleProductSupplierinfoQtyMultiplier(TestModuleProduct): +class TestModulePurchaseDiscount(TestModuleProduct): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/grap_custom_import_purchase_triple_discount/README.rst b/grap_custom_import_purchase_triple_discount/README.rst new file mode 100644 index 0000000..e69de29 diff --git a/grap_custom_import_purchase_triple_discount/__init__.py b/grap_custom_import_purchase_triple_discount/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/grap_custom_import_purchase_triple_discount/__manifest__.py b/grap_custom_import_purchase_triple_discount/__manifest__.py new file mode 100644 index 0000000..5980194 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "GRAP - Custom Product Import - Purchase Triple Discount Module", + "summary": "Extra GRAP Tools to import product data for" + " Purchase Triple Discount module", + "version": "16.0.1.0.0", + "category": "Tools", + "author": "GRAP", + "website": "https://github.com/grap/grap-odoo-import", + "license": "AGPL-3", + "depends": ["grap_custom_import_purchase_discount", "purchase_triple_discount"], + "auto_install": True, + "installable": True, +} diff --git a/grap_custom_import_purchase_triple_discount/models/__init__.py b/grap_custom_import_purchase_triple_discount/models/__init__.py new file mode 100644 index 0000000..84c7d0c --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/models/__init__.py @@ -0,0 +1,2 @@ +from . import custom_import_product_mixin +from . import product_template diff --git a/grap_custom_import_purchase_triple_discount/models/custom_import_product_mixin.py b/grap_custom_import_purchase_triple_discount/models/custom_import_product_mixin.py new file mode 100644 index 0000000..8d5a242 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/models/custom_import_product_mixin.py @@ -0,0 +1,16 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class CustomImportProductMixin(models.AbstractModel): + _name = "custom.import.product.mixin" + _inherit = ["custom.import.product.mixin"] + + def _custom_import_prepare_supplierinfo_vals(self, partner, vals): + res = super()._custom_import_prepare_supplierinfo_vals(partner, vals) + res["discount2"] = (vals.get("grap_import_supplier_discount_2") or 0.0) * 100 + res["discount3"] = (vals.get("grap_import_supplier_discount_3") or 0.0) * 100 + return res diff --git a/grap_custom_import_purchase_triple_discount/models/product_template.py b/grap_custom_import_purchase_triple_discount/models/product_template.py new file mode 100644 index 0000000..0ee2d53 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/models/product_template.py @@ -0,0 +1,17 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + grap_import_supplier_discount_2 = fields.Float( + string="Supplier Discount 2 (For import)", store=False + ) + + grap_import_supplier_discount_3 = fields.Float( + string="Supplier Discount 3 (For import)", store=False + ) diff --git a/grap_custom_import_purchase_triple_discount/readme/CONTRIBUTORS.rst b/grap_custom_import_purchase_triple_discount/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..9f76a75 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL diff --git a/grap_custom_import_purchase_triple_discount/readme/DESCRIPTION.rst b/grap_custom_import_purchase_triple_discount/readme/DESCRIPTION.rst new file mode 100644 index 0000000..fe0e6da --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module improve the "import" features provided by Odoo. + +* ``product.product``: + + * Allow to recover ``discount2`` and ``discount3`` fields + in the supplier info level. diff --git a/grap_custom_import_purchase_triple_discount/tests/__init__.py b/grap_custom_import_purchase_triple_discount/tests/__init__.py new file mode 100644 index 0000000..d9b96c4 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/grap_custom_import_purchase_triple_discount/tests/templates/product/product.csv b/grap_custom_import_purchase_triple_discount/tests/templates/product/product.csv new file mode 100644 index 0000000..c432950 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/tests/templates/product/product.csv @@ -0,0 +1,2 @@ +name,uom_id,categ_id,grap_import_supplier_name,grap_import_supplier_discount_1,grap_import_supplier_discount_2,grap_import_supplier_discount_3 +Mention Good (Late chocolate),Units,All / Saleable,Ready Mat,0.33,0.22,0.11 diff --git a/grap_custom_import_purchase_triple_discount/tests/test_module.py b/grap_custom_import_purchase_triple_discount/tests/test_module.py new file mode 100644 index 0000000..1cb01d9 --- /dev/null +++ b/grap_custom_import_purchase_triple_discount/tests/test_module.py @@ -0,0 +1,34 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import tagged + +from odoo.addons.grap_custom_import_product.tests.test_module import TestModuleProduct + + +@tagged("post_install", "-at_install") +class TestModulePurchaseTripleDiscount(TestModuleProduct): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.ProductProduct = cls.env["product.product"] + + def _test_import_purchase_discount(self, model): + products, messages = self._test_import_file( + "grap_custom_import_purchase_triple_discount", + model, + "product.csv", + folder="product", + ) + self.assertFalse(messages) + self.assertEqual(len(products), 1) + self.assertEqual(products.seller_ids.discount, 33.0) + self.assertEqual(products.seller_ids.discount2, 22.0) + self.assertEqual(products.seller_ids.discount3, 11.0) + + def test_01_import_purchase_discount_product(self): + self._test_import_purchase_discount("product.product") + + def test_02_import_purchase_discount_template(self): + self._test_import_purchase_discount("product.template")