diff --git a/addons/account/models/product.py b/addons/account/models/product.py index e2c55571dff..87f02749c38 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from odoo import api, fields, models, _ +from odoo.tools import format_amount ACCOUNT_DOMAIN = "['&', '&', '&', ('deprecated', '=', False), ('internal_type','=','other'), ('company_id', '=', current_company_id), ('is_off_balance', '=', False)]" @@ -24,6 +25,7 @@ class ProductTemplate(models.Model): taxes_id = fields.Many2many('account.tax', 'product_taxes_rel', 'prod_id', 'tax_id', help="Default taxes used when selling the product.", string='Customer Taxes', domain=[('type_tax_use', '=', 'sale')], default=lambda self: self.env.company.account_sale_tax_id) + tax_string = fields.Char(compute='_compute_tax_string') supplier_taxes_id = fields.Many2many('account.tax', 'product_supplier_taxes_rel', 'prod_id', 'tax_id', string='Vendor Taxes', help='Default taxes used when buying the product.', domain=[('type_tax_use', '=', 'purchase')], default=lambda self: self.env.company.account_purchase_tax_id) property_account_income_id = fields.Many2one('account.account', company_dependent=True, @@ -58,6 +60,23 @@ class ProductTemplate(models.Model): fiscal_pos = self.env['account.fiscal.position'] return fiscal_pos.map_accounts(accounts) + @api.depends('taxes_id', 'list_price') + def _compute_tax_string(self): + for record in self: + currency = record.currency_id + res = record.taxes_id.compute_all(record.list_price) + joined = [] + included = res['total_included'] + if currency.compare_amounts(included, record.list_price): + joined.append(_('%s Incl. Taxes', format_amount(self.env, included, currency))) + excluded = res['total_excluded'] + if currency.compare_amounts(excluded, record.list_price): + joined.append(_('%s Excl. Taxes', format_amount(self.env, excluded, currency))) + if joined: + record.tax_string = f"(= {', '.join(joined)})" + else: + record.tax_string = " " + class ProductProduct(models.Model): _inherit = "product.product" diff --git a/addons/account/views/product_view.xml b/addons/account/views/product_view.xml index db4a4aa7946..9aaebfea5f7 100644 --- a/addons/account/views/product_view.xml +++ b/addons/account/views/product_view.xml @@ -9,7 +9,7 @@ - + @@ -72,6 +72,9 @@ + + + diff --git a/addons/event_sale/models/product.py b/addons/event_sale/models/product.py index a3a93497f21..da6b544c5ea 100644 --- a/addons/event_sale/models/product.py +++ b/addons/event_sale/models/product.py @@ -15,6 +15,11 @@ class ProductTemplate(models.Model): self.type = 'service' self.invoice_policy = 'order' + def _compute_show_service_fields(self): + super()._compute_show_service_fields() + for record in self: + record.show_service_fields |= record.type == 'event' + class Product(models.Model): _inherit = 'product.product' diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 829cb9e4db0..294e1fbeb92 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -153,12 +153,12 @@