diff --git a/sale_pricelist_price/__init__.py b/sale_pricelist_price/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_pricelist_price/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_pricelist_price/__manifest__.py b/sale_pricelist_price/__manifest__.py new file mode 100644 index 00000000000..5a481c4d045 --- /dev/null +++ b/sale_pricelist_price/__manifest__.py @@ -0,0 +1,11 @@ +{ + "name": "Pricelist Price", + "description": "Client will have the ability to see the original price(book price) on sale order and incoice line.", + "depends": ["sale_management"], + "data": [ + "views/sale_order_views.xml", + "views/account_move_views.xml", + ], + "installable": True, + "license": "LGPL-3", +} diff --git a/sale_pricelist_price/models/__init__.py b/sale_pricelist_price/models/__init__.py new file mode 100644 index 00000000000..ea3d9579546 --- /dev/null +++ b/sale_pricelist_price/models/__init__.py @@ -0,0 +1,2 @@ +from . import sale_order_line +from . import account_move_line diff --git a/sale_pricelist_price/models/account_move_line.py b/sale_pricelist_price/models/account_move_line.py new file mode 100644 index 00000000000..0b1ccb5d1ce --- /dev/null +++ b/sale_pricelist_price/models/account_move_line.py @@ -0,0 +1,9 @@ +from odoo import fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + book_price = fields.Float( + string="Book Price", related="sale_line_ids.book_price", readonly=True + ) diff --git a/sale_pricelist_price/models/sale_order_line.py b/sale_pricelist_price/models/sale_order_line.py new file mode 100644 index 00000000000..51e36cfb6d7 --- /dev/null +++ b/sale_pricelist_price/models/sale_order_line.py @@ -0,0 +1,19 @@ +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + book_price = fields.Float( + string="Book Price", compute="_compute_book_price", store=True + ) + + @api.depends("product_id", "product_uom_qty", "order_id.pricelist_id") + def _compute_book_price(self): + for line in self: + if line.product_id and line.order_id.pricelist_id: + line.book_price = line.order_id.pricelist_id._get_product_price( + product=line.product_id, quantity=line.product_uom_qty + ) + else: + line.book_price = 0.0 diff --git a/sale_pricelist_price/views/account_move_views.xml b/sale_pricelist_price/views/account_move_views.xml new file mode 100644 index 00000000000..de06f7d0512 --- /dev/null +++ b/sale_pricelist_price/views/account_move_views.xml @@ -0,0 +1,13 @@ + + + + view.move.form.inherit.sale.pricelist.price + account.move + + + + + + + + diff --git a/sale_pricelist_price/views/sale_order_views.xml b/sale_pricelist_price/views/sale_order_views.xml new file mode 100644 index 00000000000..f41c147c22f --- /dev/null +++ b/sale_pricelist_price/views/sale_order_views.xml @@ -0,0 +1,17 @@ + + + + sale.order.form.inherit.sale.pricelist.price + sale.order + + + + + + + price_unit > book_price + price_unit < book_price + + + +