diff --git a/sale_pricelist/__init__.py b/sale_pricelist/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_pricelist/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_pricelist/__manifest__.py b/sale_pricelist/__manifest__.py new file mode 100644 index 00000000000..df3c8148425 --- /dev/null +++ b/sale_pricelist/__manifest__.py @@ -0,0 +1,18 @@ +{ + 'author': 'Odoo S.A.', + 'name': 'Sale Pricelist', + 'description': """ + Add a "Book Price" field on Sales Order Lines and Invoice Lines to display the original + pricelist price of a product. This helps users compare the standard pricelist amount + with any manually adjusted line price, ensuring pricing transparency and better control + over discount or custom price modifications. + """, + 'depends': ['sale_management'], + 'license': 'LGPL-3', + 'data': [ + 'views/sale_order_views.xml', + 'views/account_move_views.xml', + ], + 'application': True, + 'installable': True +} diff --git a/sale_pricelist/models/__init__.py b/sale_pricelist/models/__init__.py new file mode 100644 index 00000000000..ea3d9579546 --- /dev/null +++ b/sale_pricelist/models/__init__.py @@ -0,0 +1,2 @@ +from . import sale_order_line +from . import account_move_line diff --git a/sale_pricelist/models/account_move_line.py b/sale_pricelist/models/account_move_line.py new file mode 100644 index 00000000000..0f2f8ea5bd9 --- /dev/null +++ b/sale_pricelist/models/account_move_line.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + book_price = fields.Float(related="sale_line_ids.book_price", readonly=True) diff --git a/sale_pricelist/models/sale_order_line.py b/sale_pricelist/models/sale_order_line.py new file mode 100644 index 00000000000..d8b1b64ea58 --- /dev/null +++ b/sale_pricelist/models/sale_order_line.py @@ -0,0 +1,17 @@ +from odoo import models, fields, api + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + book_price = fields.Float(compute="_compute_pricelist", readonly=True) + + @api.depends("product_id", "product_uom_qty", "order_id.pricelist_id", "product_template_id.list_price") + def _compute_pricelist(self): + for record in self: + if not record.product_id: + record.book_price = 0.0 + elif not record.order_id.pricelist_id: + record.book_price = record.product_template_id.list_price + else: + record.book_price = record.order_id.pricelist_id._get_product_price(record.product_id, record.product_uom_qty) diff --git a/sale_pricelist/views/account_move_views.xml b/sale_pricelist/views/account_move_views.xml new file mode 100644 index 00000000000..a9a028be3ae --- /dev/null +++ b/sale_pricelist/views/account_move_views.xml @@ -0,0 +1,13 @@ + + + + account.move.view.form.inherit + account.move + + + + + + + + diff --git a/sale_pricelist/views/sale_order_views.xml b/sale_pricelist/views/sale_order_views.xml new file mode 100644 index 00000000000..8e9fadd503a --- /dev/null +++ b/sale_pricelist/views/sale_order_views.xml @@ -0,0 +1,13 @@ + + + + sale.order.view.form.inherit + sale.order + + + + + + + +