diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..13bb971d627 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "xml.symbols.enabled": false, + "python.languageServer": "None" +} \ No newline at end of file diff --git a/estate_pricelist_imp/__init__.py b/estate_pricelist_imp/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/estate_pricelist_imp/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/estate_pricelist_imp/__manifest__.py b/estate_pricelist_imp/__manifest__.py new file mode 100644 index 00000000000..2e6cfc12490 --- /dev/null +++ b/estate_pricelist_imp/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Sales Pricelist", + "version": "19.0.0", + "category": "Tutorials", + "depends": ["sale", "account"], + "author": "hemeh", + "application": True, + "summary": "Estate Account", + "description": """ + Estate Pricelist Sales. + """, + "data": [ + "views/estate_pricelist.xml", + "views/estate_account_pricelist.xml", + ], + "website": "https://odoo.com", + "license": "LGPL-3", + "installable": True, +} diff --git a/estate_pricelist_imp/models/__init__.py b/estate_pricelist_imp/models/__init__.py new file mode 100644 index 00000000000..153b3062ece --- /dev/null +++ b/estate_pricelist_imp/models/__init__.py @@ -0,0 +1 @@ +from . import account_move_line, sale_order_line diff --git a/estate_pricelist_imp/models/account_move_line.py b/estate_pricelist_imp/models/account_move_line.py new file mode 100644 index 00000000000..980341ba53d --- /dev/null +++ b/estate_pricelist_imp/models/account_move_line.py @@ -0,0 +1,15 @@ +from odoo import api, fields, models + + +class EstateAccountPrice(models.Model): + _inherit = 'account.move.line' + _description = "Invoicing Book Price" + book_price = fields.Monetary(compute="_compute_book_price", readonly=True) + + @api.depends('sale_line_ids.book_price') + def _compute_book_price(self): + for rec in self: + if rec.sale_line_ids: + rec.book_price = rec.sale_line_ids[0].book_price + else: + rec.book_price = 0.0 diff --git a/estate_pricelist_imp/models/sale_order_line.py b/estate_pricelist_imp/models/sale_order_line.py new file mode 100644 index 00000000000..f087bf5e6d5 --- /dev/null +++ b/estate_pricelist_imp/models/sale_order_line.py @@ -0,0 +1,24 @@ +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + book_price = fields.Monetary(compute="_compute_book_price", readonly=True) + + @api.depends('product_uom_qty', 'product_id', 'order_id.pricelist_id') + def _compute_book_price(self): + for line in self: + if not line.product_id: + line.book_price = 0.0 + continue + + pricelist = line.order_id.pricelist_id + + if pricelist: + line.book_price = pricelist._get_product_price( + product=line.product_id, + quantity=line.product_uom_qty, + ) + else: + line.book_price = line.product_id.list_price diff --git a/estate_pricelist_imp/views/estate_account_pricelist.xml b/estate_pricelist_imp/views/estate_account_pricelist.xml new file mode 100644 index 00000000000..89758ae4ff4 --- /dev/null +++ b/estate_pricelist_imp/views/estate_account_pricelist.xml @@ -0,0 +1,13 @@ + + + + account.move.line.form.inherit.book.price + account.move + + + + + + + + diff --git a/estate_pricelist_imp/views/estate_pricelist.xml b/estate_pricelist_imp/views/estate_pricelist.xml new file mode 100644 index 00000000000..69382a46d74 --- /dev/null +++ b/estate_pricelist_imp/views/estate_pricelist.xml @@ -0,0 +1,13 @@ + + + + sale.order.form.inherit.book.price + sale.order + + + + + + + +