Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from . import sale_order_line
from . import product_pricelist_item

View File

@@ -0,0 +1,14 @@
# Copyright 2023 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PricelistItem(models.Model):
_inherit = "product.pricelist.item"
show_surcharge = fields.Boolean(
default=False,
help="If enabled, when the price is computed "
"will show the customer the surcharge.",
)

View File

@@ -0,0 +1,31 @@
# Copyright 2023 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
@api.depends("product_id", "product_uom", "product_uom_qty")
def _compute_discount(self):
res = super()._compute_discount()
for line in self:
if (
not line.discount
and line.order_id.pricelist_id
and line.pricelist_item_id
and line.pricelist_item_id.show_surcharge
):
pricelist_price = line._get_pricelist_price()
base_price = line._get_pricelist_price_before_discount()
if base_price != 0: # Avoid division by zero
line.discount = (base_price - pricelist_price) / base_price * 100
return res
def _get_display_price(self):
res = super()._get_display_price()
if self.pricelist_item_id and self.pricelist_item_id.show_surcharge:
return self._get_pricelist_price_before_discount()
return res