From f228ac33bd88fb5ffbd407b1bf596145efa39ca2 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 15 Feb 2021 14:34:10 +0100 Subject: [PATCH] [IMP] sale_timesheet: removes pricing_type in _check_sale_line_type Since the pricing_type is compute non_stored field and the fixed_rate value of this is set when the sale_line_id is defined in the project. The condition checks if the pricing_type='fixed_rate' is useless. task-2442683 closes odoo/odoo#66181 --- addons/sale_timesheet/models/project.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index a09e6ccb53a..7bd201035b2 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -140,14 +140,13 @@ class Project(models.Model): for project in self.filtered(lambda p: not p.project_overview): project.project_overview = project.allow_billable or project.allow_timesheets - @api.constrains('sale_line_id', 'pricing_type') + @api.constrains('sale_line_id') def _check_sale_line_type(self): - for project in self: - if project.pricing_type == 'fixed_rate': - if project.sale_line_id and not project.sale_line_id.is_service: - raise ValidationError(_("A billable project should be linked to a Sales Order Item having a Service product.")) - if project.sale_line_id and project.sale_line_id.is_expense: - raise ValidationError(_("A billable project should be linked to a Sales Order Item that does not come from an expense or a vendor bill.")) + for project in self.filtered(lambda project: project.sale_line_id): + if not project.sale_line_id.is_service: + raise ValidationError(_("A billable project should be linked to a Sales Order Item having a Service product.")) + if project.sale_line_id.is_expense: + raise ValidationError(_("A billable project should be linked to a Sales Order Item that does not come from an expense or a vendor bill.")) @api.onchange('allow_billable') def _onchange_allow_billable(self):