diff --git a/sale_order_general_discount_triple/README.rst b/sale_order_general_discount_triple/README.rst new file mode 100644 index 00000000000..b9fc196abd1 --- /dev/null +++ b/sale_order_general_discount_triple/README.rst @@ -0,0 +1,124 @@ +================================== +Sale Order General Discount Triple +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9502220f43d26c8443a56e4a753256f3433f79f01813c46c31067126fb8ac1b9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/17.0/sale_order_general_discount_triple + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_order_general_discount_triple + :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-workflow&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +A bridge between Sale Order General +Discount(https://github.com/OCA/sale-workflow/tree/14.0/sale_order_general_discoun) +and Sale Triple +Discount(https://github.com/OCA/sale-workflow/tree/14.0/sale_triple_discount) +module to set the general discount on any of the 3 discount field on +sale order lines. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use features of this module, you need to: + +1. Go to Settings > General Settings > Pricing +2. Under pricing section, select your prefered Discount type from + 'General Discount' field and the same for 'Pricelist Discount'. +3. Option 'No apply' will disable functionality, so this kind of + discount type won't be applied on lines. +4. The selected global discount type among the 3 discounts will be + automatically parsed on sale order line while using 'Discount %' text + field. +5. If pricelist has a discount, it will be applied on the selected + pricelist discount. +6. If 'General Discount' and 'Pricelist Discount' have the same discount + field, 'General Discount' will be applied. + +Issues +------ + +If you want to use pricelist discount its recomended, in order to avoid +conflicts with other modules, to put it in first discount field. + +Changelog +========= + +14.0.1.0.0 +---------- + +- Initial release + +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 +------- + +* Ashish Hirpara +* Ooops + +Contributors +------------ + +- `Ooops `__: + + - Ashish Hirpara + +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-ashishhirapara| image:: https://github.com/ashishhirapara.png?size=40px + :target: https://github.com/ashishhirapara + :alt: ashishhirapara + +Current `maintainer `__: + +|maintainer-ashishhirapara| + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_order_general_discount_triple/__init__.py b/sale_order_general_discount_triple/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_order_general_discount_triple/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_order_general_discount_triple/__manifest__.py b/sale_order_general_discount_triple/__manifest__.py new file mode 100644 index 00000000000..fc586c0bbb8 --- /dev/null +++ b/sale_order_general_discount_triple/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2022 Ooops - Ashish Hirpara +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Sale Order General Discount Triple", + "summary": "General discount per sale order with triple", + "version": "17.0.1.0.0", + "category": "Sales", + "website": "https://github.com/OCA/sale-workflow", + "author": "Ashish Hirpara, Ooops, Odoo Community Association (OCA)", + "license": "AGPL-3", + "maintainers": ["ashishhirapara"], + "installable": True, + "depends": ["sale", "sale_order_general_discount", "sale_triple_discount"], + "data": [ + "views/res_config_settings.xml", + ], +} diff --git a/sale_order_general_discount_triple/i18n/es.po b/sale_order_general_discount_triple/i18n/es.po new file mode 100644 index 00000000000..343803a8b78 --- /dev/null +++ b/sale_order_general_discount_triple/i18n/es.po @@ -0,0 +1,73 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_general_discount_triple +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-09 07:41+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: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_res_config_settings +msgid "Config Settings" +msgstr "Configuración de Ajustes" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount2 +msgid "Disc. 2 (%)" +msgstr "Desc. 2 (%)" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount3 +msgid "Disc. 3 (%)" +msgstr "Desc. 3 (%)" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount +msgid "Discount" +msgstr "Descuento" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount2 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount2 +msgid "Discount 2" +msgstr "Descuento 2" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount3 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount3 +msgid "Discount 3" +msgstr "Descuento 3" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__general_discount +msgid "General Discount" +msgstr "Descuento General" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__pricelist_discount +msgid "Pricelist Discount" +msgstr "Descuento en la lista de precios" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order +msgid "Sales Order" +msgstr "Órdenes de Venta" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de Órdenes de Venta" + +#~ msgid "Discount (%)" +#~ msgstr "(%) Descuento" diff --git a/sale_order_general_discount_triple/i18n/it.po b/sale_order_general_discount_triple/i18n/it.po new file mode 100644 index 00000000000..b9c4a5696e5 --- /dev/null +++ b/sale_order_general_discount_triple/i18n/it.po @@ -0,0 +1,82 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_general_discount_triple +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-01 15:35+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 4.17\n" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount2 +msgid "Disc. 2 (%)" +msgstr "Sconto 2 (%)" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount3 +msgid "Disc. 3 (%)" +msgstr "Sconto 3 (%)" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount +msgid "Discount" +msgstr "Sconto" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount2 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount2 +msgid "Discount 2" +msgstr "Sconto 2" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount3 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount3 +msgid "Discount 3" +msgstr "Sconto 3" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__general_discount +msgid "General Discount" +msgstr "Sconto Generale" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__pricelist_discount +msgid "Pricelist Discount" +msgstr "Sconto listino" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" + +#~ msgid "Discount (%)" +#~ msgstr "Sconto (%)" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/sale_order_general_discount_triple/i18n/sale_order_general_discount_triple.pot b/sale_order_general_discount_triple/i18n/sale_order_general_discount_triple.pot new file mode 100644 index 00000000000..45d9be7ffd6 --- /dev/null +++ b/sale_order_general_discount_triple/i18n/sale_order_general_discount_triple.pot @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_general_discount_triple +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_sale_order_line__discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount +msgid "Discount" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount2 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount2 +msgid "Discount 2" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__general_discount__discount3 +#: model:ir.model.fields.selection,name:sale_order_general_discount_triple.selection__res_config_settings__pricelist_discount__discount3 +msgid "Discount 3" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__general_discount +msgid "General Discount" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model.fields,field_description:sale_order_general_discount_triple.field_res_config_settings__pricelist_discount +msgid "Pricelist Discount" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_order_general_discount_triple +#: model:ir.model,name:sale_order_general_discount_triple.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/sale_order_general_discount_triple/models/__init__.py b/sale_order_general_discount_triple/models/__init__.py new file mode 100644 index 00000000000..fbc5ca3c89b --- /dev/null +++ b/sale_order_general_discount_triple/models/__init__.py @@ -0,0 +1,3 @@ +from . import res_config_settings +from . import sale_order_line +from . import sale_order diff --git a/sale_order_general_discount_triple/models/res_config_settings.py b/sale_order_general_discount_triple/models/res_config_settings.py new file mode 100644 index 00000000000..ec91613c5fc --- /dev/null +++ b/sale_order_general_discount_triple/models/res_config_settings.py @@ -0,0 +1,24 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + general_discount = fields.Selection( + [ + ("discount", "Discount"), + ("discount2", "Discount 2"), + ("discount3", "Discount 3"), + ], + required=False, + config_parameter="sale_order_general_discount_triple.general_discount", + ) + pricelist_discount = fields.Selection( + [ + ("discount", "Discount"), + ("discount2", "Discount 2"), + ("discount3", "Discount 3"), + ], + required=False, + config_parameter="sale_order_general_discount_triple.pricelist_discount", + ) diff --git a/sale_order_general_discount_triple/models/sale_order.py b/sale_order_general_discount_triple/models/sale_order.py new file mode 100644 index 00000000000..c9285f09dd5 --- /dev/null +++ b/sale_order_general_discount_triple/models/sale_order.py @@ -0,0 +1,26 @@ +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.onchange("general_discount") + def onchange_general_discount(self): + general_discount = ( + self.env["ir.config_parameter"] + .sudo() + .get_param( + "sale_order_general_discount_triple.general_discount", "discount" + ) + ) + if general_discount != "no_apply": + for record in self: + record.order_line.update({general_discount: record.general_discount}) + + def _create_delivery_line(self, carrier, price_unit): + res = super()._create_delivery_line(carrier, price_unit) + for line in self.order_line: + line._compute_discount() + line._compute_discount2() + line._compute_discount3() + return res diff --git a/sale_order_general_discount_triple/models/sale_order_line.py b/sale_order_general_discount_triple/models/sale_order_line.py new file mode 100644 index 00000000000..f03d24965e2 --- /dev/null +++ b/sale_order_general_discount_triple/models/sale_order_line.py @@ -0,0 +1,104 @@ +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + discount2 = fields.Float(compute="_compute_discount2", store=True, readonly=False) + discount3 = fields.Float(compute="_compute_discount3", store=True, readonly=False) + + @api.depends("product_id", "product_uom", "product_uom_qty") + def _compute_discount(self): + pricelist_discount = self._get_discount_field_position("pricelist_discount") + general_discount = self._get_discount_field_position("general_discount") + if "discount" not in [pricelist_discount, general_discount]: + for line in self: + if line._check_is_reward_line(): + continue + line.update({"discount": 0.0}) + return + for line in self: + if line._check_is_reward_line(): + continue + if pricelist_discount == "discount": + line.update({"discount": line._get_pricelist_discount()}) + elif ( + general_discount == "discount" + and not line.product_id.bypass_general_discount + ): + line.update({"discount": line.order_id.general_discount}) + return + + @api.depends("product_id", "product_uom", "product_uom_qty") + def _compute_discount2(self): + pricelist_discount = self._get_discount_field_position("pricelist_discount") + general_discount = self._get_discount_field_position("general_discount") + if "discount2" not in [pricelist_discount, general_discount]: + for line in self: + if line._check_is_reward_line(): + continue + line.update({"discount2": 0.0}) + return + for line in self: + if line._check_is_reward_line(): + continue + if pricelist_discount == "discount2": + line.update({"discount2": line._get_pricelist_discount()}) + elif ( + general_discount == "discount2" + and not line.product_id.bypass_general_discount + ): + line.update({"discount2": line.order_id.general_discount}) + + @api.depends("product_id", "product_uom", "product_uom_qty") + def _compute_discount3(self): + pricelist_discount = self._get_discount_field_position("pricelist_discount") + general_discount = self._get_discount_field_position("general_discount") + if "discount3" not in [pricelist_discount, general_discount]: + for line in self: + if line._check_is_reward_line(): + continue + line.update({"discount3": 0.0}) + return + for line in self: + if line._check_is_reward_line(): + continue + if pricelist_discount == "discount3": + line.update({"discount3": line._get_pricelist_discount()}) + elif ( + general_discount == "discount3" + and not line.product_id.bypass_general_discount + ): + line.update({"discount3": line.order_id.general_discount}) + + def _check_is_reward_line(self): + self.ensure_one() + if "is_reward_line" not in self._fields: + return False + return self.is_reward_line + + def _get_pricelist_discount(self): + if not self.product_id or self.display_type: + return 0.0 + if not ( + self.order_id.pricelist_id + and self.order_id.pricelist_id.discount_policy == "without_discount" + ): + return 0.0 + if not self.pricelist_item_id: + return 0.0 + self = self.with_company(self.company_id) + pricelist_price = self._get_pricelist_price() + base_price = self._get_pricelist_price_before_discount() + if base_price != 0: + discount = ((base_price - pricelist_price) / base_price) * 100 + if (discount > 0 and base_price > 0) or (discount < 0 and base_price < 0): + return discount + return 0.0 + + def _get_discount_field_position(self, field_name): + return ( + self.env["ir.config_parameter"] + .sudo() + .get_param(f"sale_order_general_discount_triple.{field_name}", "discount") + ) diff --git a/sale_order_general_discount_triple/pyproject.toml b/sale_order_general_discount_triple/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_order_general_discount_triple/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_order_general_discount_triple/readme/CONTRIBUTORS.md b/sale_order_general_discount_triple/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..1c35e648030 --- /dev/null +++ b/sale_order_general_discount_triple/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Ooops](https://www.ooops404.com): + - Ashish Hirpara diff --git a/sale_order_general_discount_triple/readme/DESCRIPTION.md b/sale_order_general_discount_triple/readme/DESCRIPTION.md new file mode 100644 index 00000000000..8da2c8c44c3 --- /dev/null +++ b/sale_order_general_discount_triple/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +A bridge between Sale Order General +Discount() +and Sale Triple +Discount() +module to set the general discount on any of the 3 discount field on +sale order lines. diff --git a/sale_order_general_discount_triple/readme/HISTORY.md b/sale_order_general_discount_triple/readme/HISTORY.md new file mode 100644 index 00000000000..a6871c38d09 --- /dev/null +++ b/sale_order_general_discount_triple/readme/HISTORY.md @@ -0,0 +1,3 @@ +## 14.0.1.0.0 + +- Initial release diff --git a/sale_order_general_discount_triple/readme/USAGE.md b/sale_order_general_discount_triple/readme/USAGE.md new file mode 100644 index 00000000000..8b8fc491823 --- /dev/null +++ b/sale_order_general_discount_triple/readme/USAGE.md @@ -0,0 +1,19 @@ +To use features of this module, you need to: + +1. Go to Settings \> General Settings \> Pricing +2. Under pricing section, select your prefered Discount type from + 'General Discount' field and the same for 'Pricelist Discount'. +3. Option 'No apply' will disable functionality, so this kind of + discount type won't be applied on lines. +4. The selected global discount type among the 3 discounts will be + automatically parsed on sale order line while using 'Discount %' + text field. +5. If pricelist has a discount, it will be applied on the selected + pricelist discount. +6. If 'General Discount' and 'Pricelist Discount' have the same + discount field, 'General Discount' will be applied. + +## Issues + +If you want to use pricelist discount its recomended, in order to avoid +conflicts with other modules, to put it in first discount field. diff --git a/sale_order_general_discount_triple/static/description/icon.png b/sale_order_general_discount_triple/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_order_general_discount_triple/static/description/icon.png differ diff --git a/sale_order_general_discount_triple/static/description/index.html b/sale_order_general_discount_triple/static/description/index.html new file mode 100644 index 00000000000..46c4fc8ed08 --- /dev/null +++ b/sale_order_general_discount_triple/static/description/index.html @@ -0,0 +1,471 @@ + + + + + +Sale Order General Discount Triple + + + +
+

Sale Order General Discount Triple

+ + +

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

+

A bridge between Sale Order General +Discount(https://github.com/OCA/sale-workflow/tree/14.0/sale_order_general_discoun) +and Sale Triple +Discount(https://github.com/OCA/sale-workflow/tree/14.0/sale_triple_discount) +module to set the general discount on any of the 3 discount field on +sale order lines.

+

Table of contents

+ +
+

Usage

+

To use features of this module, you need to:

+
    +
  1. Go to Settings > General Settings > Pricing
  2. +
  3. Under pricing section, select your prefered Discount type from +‘General Discount’ field and the same for ‘Pricelist Discount’.
  4. +
  5. Option ‘No apply’ will disable functionality, so this kind of +discount type won’t be applied on lines.
  6. +
  7. The selected global discount type among the 3 discounts will be +automatically parsed on sale order line while using ‘Discount %’ text +field.
  8. +
  9. If pricelist has a discount, it will be applied on the selected +pricelist discount.
  10. +
  11. If ‘General Discount’ and ‘Pricelist Discount’ have the same discount +field, ‘General Discount’ will be applied.
  12. +
+
+

Issues

+

If you want to use pricelist discount its recomended, in order to avoid +conflicts with other modules, to put it in first discount field.

+
+
+
+

Changelog

+
+

14.0.1.0.0

+
    +
  • Initial release
  • +
+
+
+
+

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

+
    +
  • Ashish Hirpara
  • +
  • Ooops
  • +
+
+
+

Contributors

+
    +
  • Ooops:
      +
    • Ashish Hirpara
    • +
    +
  • +
+
+
+

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:

+

ashishhirapara

+

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

+

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

+
+
+
+ + diff --git a/sale_order_general_discount_triple/tests/__init__.py b/sale_order_general_discount_triple/tests/__init__.py new file mode 100644 index 00000000000..d9b96c4fa5a --- /dev/null +++ b/sale_order_general_discount_triple/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/sale_order_general_discount_triple/tests/test_module.py b/sale_order_general_discount_triple/tests/test_module.py new file mode 100644 index 00000000000..ae92506e921 --- /dev/null +++ b/sale_order_general_discount_triple/tests/test_module.py @@ -0,0 +1,49 @@ +from odoo.tests.common import Form, TransactionCase + + +class TestModule(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create( + {"name": "Test Partner", "sale_discount": 10} + ) + cls.product = cls.env.ref("product.product_product_4") + cls.pricelist = cls.env["product.pricelist"].create( + { + "name": "Test multi-currency", + "discount_policy": "without_discount", + "currency_id": cls.env.ref("base.USD").id, + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "percentage", + "percent_price": 20, + }, + ), + ], + } + ) + setting_form = Form(cls.env["res.config.settings"]) + setting_form.general_discount = "discount2" + setting_form.pricelist_discount = "discount" + setting_form.group_discount_per_so_line = True + setting_form.save().set_values() + + def test_action_result(self): + sale_order = self.env["sale.order"].create( + { + "partner_id": self.partner.id, + "pricelist_id": self.pricelist.id, + } + ) + sale_form = Form(sale_order) + with sale_form.order_line.new() as line: + line.product_id = self.product + sale = sale_form.save() + for line in sale.order_line: + self.assertEqual(line.discount2, 10) + self.assertEqual(line.discount, 20) diff --git a/sale_order_general_discount_triple/views/res_config_settings.xml b/sale_order_general_discount_triple/views/res_config_settings.xml new file mode 100644 index 00000000000..e6614eeebc0 --- /dev/null +++ b/sale_order_general_discount_triple/views/res_config_settings.xml @@ -0,0 +1,25 @@ + + + + res.config.settings.form.view + res.config.settings + + + + +
+
+
+
+
+
+
+
+
diff --git a/test-requirements.txt b/test-requirements.txt index 66bc2cbae3f..26396e54931 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,3 @@ odoo_test_helper +odoo-addon-sale_order_general_discount @ git+https://github.com/OCA/sale-workflow.git@refs/pull/3030/head#subdirectory=sale_order_general_discount +odoo-addon-sale_triple_discount @ git+https://github.com/OCA/sale-workflow.git@refs/pull/3406/head#subdirectory=sale_triple_discount