From 2a0b944a980e16328f066faa0e6c6a2cb3e056a7 Mon Sep 17 00:00:00 2001 From: "Soham Patil (sopat)" Date: Mon, 18 May 2026 15:36:09 +0530 Subject: [PATCH] [ADD] pricelist_price: add book price field based on pricelist - Added computed Book Price field on sale order lines - Computed Book Price from selected pricelist, product, and quantity - Added Book Price field on customer invoice lines - Synced invoice Book Price from related sale order line - Displayed Book Price in sale order and invoice line views --- pricelist_price/__init__.py | 1 + pricelist_price/__manifest__.py | 15 +++++++++++++++ pricelist_price/models/__init__.py | 2 ++ pricelist_price/models/account_move_line.py | 19 +++++++++++++++++++ pricelist_price/models/sale_order_line.py | 17 +++++++++++++++++ .../views/account_move_line_view.xml | 12 ++++++++++++ .../views/sale_order_line_view.xml | 12 ++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 pricelist_price/__init__.py create mode 100644 pricelist_price/__manifest__.py create mode 100644 pricelist_price/models/__init__.py create mode 100644 pricelist_price/models/account_move_line.py create mode 100644 pricelist_price/models/sale_order_line.py create mode 100644 pricelist_price/views/account_move_line_view.xml create mode 100644 pricelist_price/views/sale_order_line_view.xml diff --git a/pricelist_price/__init__.py b/pricelist_price/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/pricelist_price/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pricelist_price/__manifest__.py b/pricelist_price/__manifest__.py new file mode 100644 index 00000000000..1751008784f --- /dev/null +++ b/pricelist_price/__manifest__.py @@ -0,0 +1,15 @@ +{ + 'name': 'pricelist_price', + 'author': 'soham', + 'version': "1.0", + 'description': 'Added pricelist price', + 'depends': ['sale_management'], + 'license': 'LGPL-3', + 'data': [ + 'views/account_move_line_view.xml', + 'views/sale_order_line_view.xml' + ], + 'application': True, + 'installable': True, + 'auto-install': True, +} diff --git a/pricelist_price/models/__init__.py b/pricelist_price/models/__init__.py new file mode 100644 index 00000000000..ea3d9579546 --- /dev/null +++ b/pricelist_price/models/__init__.py @@ -0,0 +1,2 @@ +from . import sale_order_line +from . import account_move_line diff --git a/pricelist_price/models/account_move_line.py b/pricelist_price/models/account_move_line.py new file mode 100644 index 00000000000..6cdd189f00b --- /dev/null +++ b/pricelist_price/models/account_move_line.py @@ -0,0 +1,19 @@ +from odoo import api, fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + book_price = fields.Float( + string="Book Price", + compute="_compute_book_price", + readonly=True + ) + + @api.depends("sale_line_ids.book_price") + def _compute_book_price(self): + for line in self: + if line.sale_line_ids: + line.book_price = line.sale_line_ids[0].book_price + else: + line.book_price = 0.0 diff --git a/pricelist_price/models/sale_order_line.py b/pricelist_price/models/sale_order_line.py new file mode 100644 index 00000000000..d8b1b64ea58 --- /dev/null +++ b/pricelist_price/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/pricelist_price/views/account_move_line_view.xml b/pricelist_price/views/account_move_line_view.xml new file mode 100644 index 00000000000..6d92c683aad --- /dev/null +++ b/pricelist_price/views/account_move_line_view.xml @@ -0,0 +1,12 @@ + + + account.move.view.form.inherit + account.move + + + + + + + + diff --git a/pricelist_price/views/sale_order_line_view.xml b/pricelist_price/views/sale_order_line_view.xml new file mode 100644 index 00000000000..0fe6d27c2c5 --- /dev/null +++ b/pricelist_price/views/sale_order_line_view.xml @@ -0,0 +1,12 @@ + + + sale.order.view.form.inherit + sale.order + + + + + + + +