diff --git a/product_pricelist/__init__.py b/product_pricelist/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_pricelist/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_pricelist/__manifest__.py b/product_pricelist/__manifest__.py new file mode 100644 index 00000000000..ceef87d3db7 --- /dev/null +++ b/product_pricelist/__manifest__.py @@ -0,0 +1,18 @@ +{ + 'name': "Book Price (Pricelist Price)", + 'version': '1.0', + 'depends': ['sale_management'], + 'author': "ppch", + 'category': 'Category', + 'description': """ + Book Price (Pricelist Price) on sales order lines and invoice lines + which will be used to compare between Book Price (Pricelist Price) and + manually adjusted price on the lines. + """, + 'license': "LGPL-3", + 'data': [ + 'views/sale_order_line_views.xml', + 'views/account_move_line_views.xml', + ], + 'installable': True, +} diff --git a/product_pricelist/models/__init__.py b/product_pricelist/models/__init__.py new file mode 100644 index 00000000000..f8e68897cfa --- /dev/null +++ b/product_pricelist/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move_line +from . import sale_order_line diff --git a/product_pricelist/models/account_move_line.py b/product_pricelist/models/account_move_line.py new file mode 100644 index 00000000000..7dd49fdcae0 --- /dev/null +++ b/product_pricelist/models/account_move_line.py @@ -0,0 +1,7 @@ +from odoo import api, fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + book_price = fields.Float(related='sale_line_ids.book_price') diff --git a/product_pricelist/models/sale_order_line.py b/product_pricelist/models/sale_order_line.py new file mode 100644 index 00000000000..7e9d18db78e --- /dev/null +++ b/product_pricelist/models/sale_order_line.py @@ -0,0 +1,22 @@ +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') + + @api.depends('product_id', 'product_uom_qty', 'order_id.pricelist_id') + def _compute_book_price(self): + for record in self: + if not record.product_id: + record.book_price = 0.0 + continue + + pricelist = record.order_id.pricelist_id if record.order_id else None + if pricelist: + record.book_price = pricelist._get_product_price( + record.product_id, record.product_uom_qty + ) + else: + record.book_price = record.product_id.lst_price diff --git a/product_pricelist/views/account_move_line_views.xml b/product_pricelist/views/account_move_line_views.xml new file mode 100644 index 00000000000..4c04d086f2d --- /dev/null +++ b/product_pricelist/views/account_move_line_views.xml @@ -0,0 +1,13 @@ + + + + account.move.form.inherite.book.price + account.move + + + + + + + + diff --git a/product_pricelist/views/sale_order_line_views.xml b/product_pricelist/views/sale_order_line_views.xml new file mode 100644 index 00000000000..9e077fde905 --- /dev/null +++ b/product_pricelist/views/sale_order_line_views.xml @@ -0,0 +1,13 @@ + + + + sale.order.form.inherite.book.price + sale.order + + + + + + + +