From 57070794e00108da64a209ae94e7509479a16061 Mon Sep 17 00:00:00 2001 From: docker-odoo Date: Wed, 24 Apr 2024 16:13:53 +0000 Subject: [PATCH] [ADD] website_sale_three_discounts: add new module closes ingadhoc/website#281 Related: ingadhoc/sale#815 Signed-off-by: matiasperalta1 --- website_sale_three_discounts/README.rst | 67 +++++++++++++++++++ website_sale_three_discounts/__init__.py | 5 ++ website_sale_three_discounts/__manifest__.py | 29 ++++++++ .../models/__init__.py | 5 ++ .../models/sale_order.py | 16 +++++ 5 files changed, 122 insertions(+) create mode 100644 website_sale_three_discounts/README.rst create mode 100644 website_sale_three_discounts/__init__.py create mode 100644 website_sale_three_discounts/__manifest__.py create mode 100644 website_sale_three_discounts/models/__init__.py create mode 100644 website_sale_three_discounts/models/sale_order.py diff --git a/website_sale_three_discounts/README.rst b/website_sale_three_discounts/README.rst new file mode 100644 index 00000000..c190bd44 --- /dev/null +++ b/website_sale_three_discounts/README.rst @@ -0,0 +1,67 @@ +.. |company| replace:: ADHOC SA + +.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png + :alt: ADHOC SA + :target: https://www.adhoc.com.ar + +.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png + +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +================================= +Website Sale Three Discounts +================================= + +Fix the discounts coming from the website + +Installation +============ + +To install this module, you need to: + +#. Just install this module. + +Configuration +============= + +To configure this module, you need to: + +#. No configuration needed. + +Usage +===== + +To use this module, you need to: + +#. Just use the module. + + +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 smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* |company| |icon| + +Contributors +------------ + +Maintainer +---------- + +|company_logo| + +This module is maintained by the |company|. + +To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/website_sale_three_discounts/__init__.py b/website_sale_three_discounts/__init__.py new file mode 100644 index 00000000..d0337769 --- /dev/null +++ b/website_sale_three_discounts/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import models diff --git a/website_sale_three_discounts/__manifest__.py b/website_sale_three_discounts/__manifest__.py new file mode 100644 index 00000000..ce79fccd --- /dev/null +++ b/website_sale_three_discounts/__manifest__.py @@ -0,0 +1,29 @@ +############################################################################## +# +# Copyright (C) 2015 Moldeo Interactive and ADHOC SA +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Website Sale Three Discounts', + 'category': 'Hidden', + 'version': "16.0.1.0.0", + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'depends': ['website_sale', 'sale_three_discounts'], + 'installable': True, +} diff --git a/website_sale_three_discounts/models/__init__.py b/website_sale_three_discounts/models/__init__.py new file mode 100644 index 00000000..fbc46b61 --- /dev/null +++ b/website_sale_three_discounts/models/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import sale_order diff --git a/website_sale_three_discounts/models/sale_order.py b/website_sale_three_discounts/models/sale_order.py new file mode 100644 index 00000000..f5d56e4f --- /dev/null +++ b/website_sale_three_discounts/models/sale_order.py @@ -0,0 +1,16 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from odoo import models + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + def _cart_update_order_line(self, product_id, quantity, order_line, **kwargs): + order_line = super()._cart_update_order_line(product_id, quantity, order_line, **kwargs) + if order_line: + order_line._compute_discount() + order_line.discount1 = order_line.discount + return order_line