From 71fa10368af2929d9831c46436d53cdca3cb3544 Mon Sep 17 00:00:00 2001 From: utpat-odoo Date: Tue, 9 Dec 2025 11:30:38 +0530 Subject: [PATCH] [ADD] sale_pricelist: add book price to sale order and invoice lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose: Client requires the ability to see the original pricelist on sale order lines and invoice order lines. This will used to compare between pricelist and any manually adjusted price on the lines. Technical changes: 1. Add a new field book_price on both sale.order.line and account.move.line models. 2. Display the book_price field: - On the Sales Order form (order lines). - On the Account Move form (invoice lines). - In Account Move, the field is visible only when move.type is a Customer Invoice. 3. Business Logic for book_price Calculation: - If no product is not exist then book_price should be 0.0. - If a product exists but is not included in the selected pricelist, book_price should be set to the product’s original sales price. - If the product exists in the selected pricelist, compute book_price based on the pricelist rule, using Selected pricelist, product, quantity task-5382732 --- sale_pricelist/__init__.py | 1 + sale_pricelist/__manifest__.py | 18 ++++++++++++++++++ sale_pricelist/models/__init__.py | 2 ++ sale_pricelist/models/account_move_line.py | 7 +++++++ sale_pricelist/models/sale_order_line.py | 17 +++++++++++++++++ sale_pricelist/views/account_move_views.xml | 13 +++++++++++++ sale_pricelist/views/sale_order_views.xml | 13 +++++++++++++ 7 files changed, 71 insertions(+) create mode 100644 sale_pricelist/__init__.py create mode 100644 sale_pricelist/__manifest__.py create mode 100644 sale_pricelist/models/__init__.py create mode 100644 sale_pricelist/models/account_move_line.py create mode 100644 sale_pricelist/models/sale_order_line.py create mode 100644 sale_pricelist/views/account_move_views.xml create mode 100644 sale_pricelist/views/sale_order_views.xml 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 + + + + + + + +