From fa034b2a646d9bc761246db62f9e96d565671ce8 Mon Sep 17 00:00:00 2001 From: wan Date: Wed, 11 Aug 2021 10:15:27 +0000 Subject: [PATCH] [IMP] *: product back2basics 15.0 Rework the whole view, generally. task-2605931 Part-of: odoo/odoo#75862 --- addons/account/models/product.py | 19 +++ addons/account/views/product_view.xml | 5 +- addons/event_sale/models/product.py | 5 + addons/hr_expense/views/hr_expense_views.xml | 21 +--- addons/l10n_ar/demo/product_product_demo.xml | 16 +-- addons/l10n_cl/data/product_data.xml | 2 +- addons/mrp/data/mrp_data.xml | 2 +- addons/mrp/data/mrp_demo.xml | 28 ++--- .../test_warehouse_multistep_manufacturing.py | 9 +- addons/mrp/views/product_views.xml | 2 +- .../data/mrp_subcontracting_data.xml | 3 +- addons/point_of_sale/models/pos_config.py | 2 +- addons/point_of_sale/views/product_view.xml | 16 +-- addons/product/data/product_demo.xml | 54 ++++----- addons/product/models/product.py | 6 +- addons/product/models/product_attribute.py | 35 +++++- addons/product/models/product_template.py | 61 ++++++++-- addons/product/populate/product.py | 2 +- .../product/views/product_attribute_views.xml | 40 +++--- .../product/views/product_template_views.xml | 8 +- addons/product/views/product_views.xml | 91 ++++++++------ .../views/product_views.xml | 2 +- .../data/product_matrix_demo.xml | 8 +- addons/purchase/models/purchase.py | 2 +- addons/purchase/views/product_views.xml | 16 +-- .../tests/test_purchase_mrp_flow.py | 3 +- .../tests/test_reordering_rule.py | 13 +- addons/sale/models/product_template.py | 5 +- addons/sale/views/product_views.xml | 13 +- addons/sale/views/sale_views.xml | 16 +-- .../sale_expense/models/product_template.py | 4 - addons/sale_mrp/tests/test_sale_mrp_flow.py | 4 +- .../tests/test_sale_mrp_procurement.py | 8 +- .../views/sale_views.xml | 15 +-- .../views/product_template_views.xml | 12 +- addons/sale_project/models/product.py | 39 +++++- addons/sale_project/views/product_views.xml | 8 +- .../sale_purchase/models/product_template.py | 2 +- addons/sale_stock/models/sale_order.py | 2 +- addons/sale_timesheet/models/product.py | 114 ++++++++++++------ addons/sale_timesheet/models/sale_order.py | 2 - .../tests/test_upsell_warning.py | 1 - addons/sale_timesheet/views/product_views.xml | 16 ++- addons/stock/data/stock_demo2.xml | 2 +- addons/stock/models/product.py | 12 ++ addons/stock/models/stock_move.py | 4 +- addons/stock/tests/test_move.py | 12 +- addons/stock/tests/test_report.py | 8 +- addons/stock/views/product_views.xml | 20 +-- addons/stock_dropshipping/data/stock_data.xml | 2 +- .../tests/test_lifo_price.py | 4 +- .../tests/test_procurement_exception.py | 2 +- .../stock_landed_costs/models/account_move.py | 2 +- .../views/product_views.xml | 10 +- .../data/product_demo.xml | 4 +- .../website_sale/models/product_template.py | 4 +- addons/website_sale/views/product_views.xml | 47 +++----- .../data/product_demo.xml | 2 +- .../views/product_views.xml | 4 +- .../website_sale_slides/data/product_demo.xml | 4 +- .../static/tests/tours/main_flow.js | 14 +-- 61 files changed, 524 insertions(+), 365 deletions(-) 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 @@