From 52ed0be17e80aa6bcc24d59620dd3462b6d577c3 Mon Sep 17 00:00:00 2001 From: jdoutreloux Date: Thu, 7 Nov 2019 11:23:18 +0000 Subject: [PATCH] [IMP] uom : remove 'measure_type' field This removes the measure_type field which has become unused and causes issues when users try to add new uom categories. Task-2043927 closes odoo/odoo#41056 Related: odoo/enterprise#6945 Signed-off-by: Yannick Tivisse (yti) --- addons/hr_timesheet/models/res_company.py | 16 +++++----- .../l10n_it_edi/data/invoice_it_template.xml | 2 +- .../mrp/report/mrp_production_templates.xml | 5 ++-- .../report/mrp_zebra_production_templates.xml | 3 +- addons/point_of_sale/views/product_view.xml | 2 +- addons/stock/report/picking_templates.xml | 6 ++-- addons/uom/data/uom_data.xml | 14 ++++----- addons/uom/models/uom_uom.py | 29 ++++++++++--------- addons/uom/tests/test_uom.py | 8 +---- addons/uom/views/uom_uom_views.xml | 2 -- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/addons/hr_timesheet/models/res_company.py b/addons/hr_timesheet/models/res_company.py index 0d890a77108..8d48a0e4bb1 100644 --- a/addons/hr_timesheet/models/res_company.py +++ b/addons/hr_timesheet/models/res_company.py @@ -10,27 +10,29 @@ class ResCompany(models.Model): @api.model def _default_project_time_mode_id(self): uom = self.env.ref('uom.product_uom_hour', raise_if_not_found=False) + wtime = self.env.ref('uom.uom_categ_wtime') if not uom: - uom = self.env['uom.uom'].search([('measure_type', '=', 'working_time'), ('uom_type', '=', 'reference')], limit=1) + uom = self.env['uom.uom'].search([('category_id', '=', wtime.id), ('uom_type', '=', 'reference')], limit=1) if not uom: - uom = self.env['uom.uom'].search([('measure_type', '=', 'working_time')], limit=1) + uom = self.env['uom.uom'].search([('category_id', '=', wtime.id)], limit=1) return uom @api.model def _default_timesheet_encode_uom_id(self): uom = self.env.ref('uom.product_uom_hour', raise_if_not_found=False) + wtime = self.env.ref('uom.uom_categ_wtime') if not uom: - uom = self.env['uom.uom'].search([('measure_type', '=', 'working_time'), ('uom_type', '=', 'reference')], limit=1) + uom = self.env['uom.uom'].search([('category_id', '=', wtime.id), ('uom_type', '=', 'reference')], limit=1) if not uom: - uom = self.env['uom.uom'].search([('measure_type', '=', 'working_time')], limit=1) + uom = self.env['uom.uom'].search([('category_id', '=', wtime.id)], limit=1) return uom - + project_time_mode_id = fields.Many2one('uom.uom', string='Project Time Unit', - default=_default_project_time_mode_id, domain=[('measure_type', '=', 'working_time')], + default=_default_project_time_mode_id, help="This will set the unit of measure used in projects and tasks.\n" "If you use the timesheet linked to projects, don't " "forget to setup the right unit of measure in your employees.") timesheet_encode_uom_id = fields.Many2one('uom.uom', string="Timesheet Encoding Unit", - default=_default_timesheet_encode_uom_id, domain=[('measure_type', '=', 'working_time')], required=True, + default=_default_timesheet_encode_uom_id, domain=lambda self: [('category_id', '=', self.env.ref('uom.uom_categ_wtime').id)], help="""This will set the unit of measure used to encode timesheet. This will simply provide tools and widgets to help the encoding. All reporting will still be expressed in hours (default value).""") diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index 3138e2c8e5a..12c318cc3aa 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -19,7 +19,7 @@ - + diff --git a/addons/mrp/report/mrp_production_templates.xml b/addons/mrp/report/mrp_production_templates.xml index de1dfe3d523..f8c2704f925 100644 --- a/addons/mrp/report/mrp_production_templates.xml +++ b/addons/mrp/report/mrp_production_templates.xml @@ -108,6 +108,7 @@