diff --git a/README.md b/README.md index a23dee096..d99f554ac 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ addon | version | maintainers | summary [sale_coupon_product_exclude](sale_coupon_product_exclude/) | 14.0.1.0.0 | | Apply a discount to the order, excluding products matching the domain [sale_coupon_reward_add_product](sale_coupon_reward_add_product/) | 14.0.1.0.0 | [![jcoux](https://github.com/jcoux.png?size=30px)](https://github.com/jcoux) [![ivantodorovich](https://github.com/ivantodorovich.png?size=30px)](https://github.com/ivantodorovich) | Sale Coupon Automatic free product as normal [sale_coupon_reward_fixed_price](sale_coupon_reward_fixed_price/) | 14.0.1.1.0 | | Apply fixed price for domain matching products +[sale_coupon_reward_fixed_price_order_line_link](sale_coupon_reward_fixed_price_order_line_link/) | 14.0.1.0.0 | [![aleuffre](https://github.com/aleuffre.png?size=30px)](https://github.com/aleuffre) [![renda-dev](https://github.com/renda-dev.png?size=30px)](https://github.com/renda-dev) [![PicchiSeba](https://github.com/PicchiSeba.png?size=30px)](https://github.com/PicchiSeba) | Bridge module to track promotions on SOL with the discount in field [sale_promotion_discount_in_field](sale_promotion_discount_in_field/) | 14.0.1.1.0 | [![CetmixGitDrone](https://github.com/CetmixGitDrone.png?size=30px)](https://github.com/CetmixGitDrone) [![Volodiay622](https://github.com/Volodiay622.png?size=30px)](https://github.com/Volodiay622) | Put promotion discount into discount field [//]: # (end addons) diff --git a/sale_coupon_domain_product_reward_fixed_price/models/sale_order.py b/sale_coupon_domain_product_reward_fixed_price/models/sale_order.py index 6d4204faa..704293cfe 100644 --- a/sale_coupon_domain_product_reward_fixed_price/models/sale_order.py +++ b/sale_coupon_domain_product_reward_fixed_price/models/sale_order.py @@ -16,5 +16,6 @@ def _set_reward_fixed_price_for_lines(self, program): lambda line: program._get_valid_products(line.product_id), ) lines.write({"price_unit": program.price_unit}) + return lines else: - super()._set_reward_fixed_price_for_lines(program) + return super()._set_reward_fixed_price_for_lines(program) diff --git a/sale_coupon_reward_fixed_price/models/sale_order.py b/sale_coupon_reward_fixed_price/models/sale_order.py index bbbc7f637..65a4e046b 100644 --- a/sale_coupon_reward_fixed_price/models/sale_order.py +++ b/sale_coupon_reward_fixed_price/models/sale_order.py @@ -76,9 +76,7 @@ def _set_reward_fixed_price_for_lines(self, program): price_unit = program.price_unit lines = self._get_paid_order_lines() if program.discount_apply_on == "cheapest_product": - line = self._get_cheapest_line() - if line: - line.price_unit = price_unit + lines = self._get_cheapest_line() elif program.discount_apply_on in ["specific_products", "on_order"]: if program.discount_apply_on == "specific_products": # We should not exclude reward line that offer this product @@ -102,15 +100,13 @@ def _set_reward_fixed_price_for_lines(self, program): lambda x: x.product_id in (program.discount_specific_product_ids | free_product_lines), ) - for line in lines: - line.price_unit = price_unit elif program.discount_apply_on == "domain_product": # for compatibility with `sale_promotion_domain_product_discount` module lines = (self.order_line - self._get_reward_lines()).filtered( lambda line: program._get_valid_products(line.product_id), ) - for line in lines: - line.price_unit = price_unit + lines.write({"price_unit": price_unit}) + return lines def _get_reward_line_values(self, program): """ diff --git a/sale_coupon_reward_fixed_price_order_line_link/README.rst b/sale_coupon_reward_fixed_price_order_line_link/README.rst new file mode 100644 index 000000000..123033c2e --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/README.rst @@ -0,0 +1,99 @@ +========================================= +Coupon Reward Fixed Price Order Line Link +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:56eca0c2aaa35a8a510a9d5f3102c17dbdfdfef8d20a7b998c016f87d8290341 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--promotion-lightgray.png?logo=github + :target: https://github.com/OCA/sale-promotion/tree/14.0/sale_coupon_reward_fixed_price_order_line_link + :alt: OCA/sale-promotion +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_reward_fixed_price_order_line_link + :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/sale-promotion&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Bridge module between Sale Coupon Order Line Link and +Sale Coupon Reward Fixed Price + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +No action necessary, module works out of the box. + +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 +~~~~~~~ + +* PyTech SRL + +Contributors +~~~~~~~~~~~~ + + +* `PyTech SRL `__: + + * Alessandro Uffreduzzi + +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-aleuffre| image:: https://github.com/aleuffre.png?size=40px + :target: https://github.com/aleuffre + :alt: aleuffre +.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px + :target: https://github.com/renda-dev + :alt: renda-dev +.. |maintainer-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px + :target: https://github.com/PicchiSeba + :alt: PicchiSeba + +Current `maintainers `__: + +|maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba| + +This module is part of the `OCA/sale-promotion `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_coupon_reward_fixed_price_order_line_link/__init__.py b/sale_coupon_reward_fixed_price_order_line_link/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_coupon_reward_fixed_price_order_line_link/__manifest__.py b/sale_coupon_reward_fixed_price_order_line_link/__manifest__.py new file mode 100644 index 000000000..343c8e0bf --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/__manifest__.py @@ -0,0 +1,20 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Coupon Reward Fixed Price Order Line Link", + "version": "14.0.1.0.0", + "summary": "Bridge module to track promotions on SOL " "with the discount in field", + "author": "PyTech SRL, Odoo Community Association (OCA)", + "maintainers": ["aleuffre", "renda-dev", "PicchiSeba"], + "license": "AGPL-3", + "category": "Sales Management", + "website": "https://github.com/OCA/sale-promotion", + "depends": [ + "sale_coupon_order_line_link", + "sale_coupon_reward_fixed_price", + ], + "demo": [], + "data": [], + "installable": True, + "application": False, +} diff --git a/sale_coupon_reward_fixed_price_order_line_link/i18n/sale_coupon_reward_fixed_price_order_line_link.pot b/sale_coupon_reward_fixed_price_order_line_link/i18n/sale_coupon_reward_fixed_price_order_line_link.pot new file mode 100644 index 000000000..f5441be11 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/i18n/sale_coupon_reward_fixed_price_order_line_link.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_coupon_reward_fixed_price_order_line_link +# +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: sale_coupon_reward_fixed_price_order_line_link +#: model:ir.model.fields,field_description:sale_coupon_reward_fixed_price_order_line_link.field_sale_order__display_name +msgid "Display Name" +msgstr "" + +#. module: sale_coupon_reward_fixed_price_order_line_link +#: model:ir.model.fields,field_description:sale_coupon_reward_fixed_price_order_line_link.field_sale_order__id +msgid "ID" +msgstr "" + +#. module: sale_coupon_reward_fixed_price_order_line_link +#: model:ir.model.fields,field_description:sale_coupon_reward_fixed_price_order_line_link.field_sale_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: sale_coupon_reward_fixed_price_order_line_link +#: model:ir.model,name:sale_coupon_reward_fixed_price_order_line_link.model_sale_order +msgid "Sales Order" +msgstr "" diff --git a/sale_coupon_reward_fixed_price_order_line_link/models/__init__.py b/sale_coupon_reward_fixed_price_order_line_link/models/__init__.py new file mode 100644 index 000000000..6aacb7531 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/sale_coupon_reward_fixed_price_order_line_link/models/sale_order.py b/sale_coupon_reward_fixed_price_order_line_link/models/sale_order.py new file mode 100644 index 000000000..1cd889e06 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/models/sale_order.py @@ -0,0 +1,13 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _set_reward_fixed_price_for_lines(self, program): + lines = super()._set_reward_fixed_price_for_lines(program) + if lines: + lines.write({"coupon_program_id": program.id}) + return lines diff --git a/sale_coupon_reward_fixed_price_order_line_link/readme/CONTRIBUTORS.rst b/sale_coupon_reward_fixed_price_order_line_link/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..c61dbfcd9 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ + +* `PyTech SRL `__: + + * Alessandro Uffreduzzi diff --git a/sale_coupon_reward_fixed_price_order_line_link/readme/DESCRIPTION.rst b/sale_coupon_reward_fixed_price_order_line_link/readme/DESCRIPTION.rst new file mode 100644 index 000000000..de4fee7be --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Bridge module between Sale Coupon Order Line Link and +Sale Coupon Reward Fixed Price diff --git a/sale_coupon_reward_fixed_price_order_line_link/readme/USAGE.rst b/sale_coupon_reward_fixed_price_order_line_link/readme/USAGE.rst new file mode 100644 index 000000000..69c962d56 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/readme/USAGE.rst @@ -0,0 +1 @@ +No action necessary, module works out of the box. diff --git a/sale_coupon_reward_fixed_price_order_line_link/static/description/icon.png b/sale_coupon_reward_fixed_price_order_line_link/static/description/icon.png new file mode 100755 index 000000000..3a0328b51 Binary files /dev/null and b/sale_coupon_reward_fixed_price_order_line_link/static/description/icon.png differ diff --git a/sale_coupon_reward_fixed_price_order_line_link/static/description/index.html b/sale_coupon_reward_fixed_price_order_line_link/static/description/index.html new file mode 100644 index 000000000..eb13f2c8b --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/static/description/index.html @@ -0,0 +1,431 @@ + + + + + +Coupon Reward Fixed Price Order Line Link + + + + + + diff --git a/sale_coupon_reward_fixed_price_order_line_link/tests/__init__.py b/sale_coupon_reward_fixed_price_order_line_link/tests/__init__.py new file mode 100644 index 000000000..3df23b3e0 --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/tests/__init__.py @@ -0,0 +1 @@ +from . import test_promotion_discount_in_field diff --git a/sale_coupon_reward_fixed_price_order_line_link/tests/test_promotion_discount_in_field.py b/sale_coupon_reward_fixed_price_order_line_link/tests/test_promotion_discount_in_field.py new file mode 100644 index 000000000..fad0a497f --- /dev/null +++ b/sale_coupon_reward_fixed_price_order_line_link/tests/test_promotion_discount_in_field.py @@ -0,0 +1,38 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import SavepointCase + + +class TestSaleCouponRewardFixedPriceOrderLineLink(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product = cls.env.ref("product.product_product_25_product_template") + cls.partner = cls.env.ref("base.res_partner_3") + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "order_line": [(0, 0, {"product_id": cls.product.id})], + } + ) + + cls.coupon = cls.env["coupon.program"].create( + { + "name": "10%", + "promo_code_usage": "no_code_needed", + "reward_type": "fixed_price", + "program_type": "promotion_program", + "discount_type": "percentage", + "discount_percentage": 10.0, + "discount_apply_on": "cheapest_product", + } + ) + + def test_program_reward_fixed_price_specific_product(self): + """ + Test that when adding a coupon of reward type "discount_line" + the coupon program is correctly tracked on the SOL + """ + self.assertFalse(self.order.order_line.coupon_program_id) + self.order.recompute_coupon_lines() + self.assertTrue(self.order.order_line.coupon_program_id) diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index 61f619470..bd4023d01 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -14.0.20230728.0 \ No newline at end of file +14.0.20240607.0 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index d88127976..836902fad 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -23,6 +23,7 @@ 'odoo14-addon-sale_coupon_product_exclude', 'odoo14-addon-sale_coupon_reward_add_product', 'odoo14-addon-sale_coupon_reward_fixed_price', + 'odoo14-addon-sale_coupon_reward_fixed_price_order_line_link', 'odoo14-addon-sale_promotion_discount_in_field', ], classifiers=[ diff --git a/setup/sale_coupon_reward_fixed_price_order_line_link/odoo/addons/sale_coupon_reward_fixed_price_order_line_link b/setup/sale_coupon_reward_fixed_price_order_line_link/odoo/addons/sale_coupon_reward_fixed_price_order_line_link new file mode 120000 index 000000000..ae5eae5dd --- /dev/null +++ b/setup/sale_coupon_reward_fixed_price_order_line_link/odoo/addons/sale_coupon_reward_fixed_price_order_line_link @@ -0,0 +1 @@ +../../../../sale_coupon_reward_fixed_price_order_line_link \ No newline at end of file diff --git a/setup/sale_coupon_reward_fixed_price_order_line_link/setup.py b/setup/sale_coupon_reward_fixed_price_order_line_link/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/sale_coupon_reward_fixed_price_order_line_link/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)