diff --git a/models/sale_order.py b/models/sale_order.py index 8c78f1bcff65e8c98cbea8c521659fbfb7e9c8b9..082944379d287c47fcc215d6408a67b52f66999e 100644 --- a/models/sale_order.py +++ b/models/sale_order.py @@ -26,7 +26,7 @@ class SaleOrder(models.Model): @api.onchange("partner_id", "order_line") def _project_name_to_create(self): so_line_new_project_with_tasks = self.mapped('order_line').filtered( - lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_new_project') + lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_in_project') if not so_line_new_project_with_tasks: self.project_tracking = False elif so_line_new_project_with_tasks and self.partner_id: @@ -45,7 +45,7 @@ class SaleOrder(models.Model): self.project_id_linked = None if not self.project_name_to_create: so_line_new_project_with_tasks = self.mapped('order_line').filtered( - lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_new_project') + lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_in_project') if so_line_new_project_with_tasks and self.partner_id: self.project_name_to_create = self.partner_id.name + str(' - ') @@ -53,7 +53,7 @@ class SaleOrder(models.Model): # on différencie so_line_new_project (dans _timesheet_service_generation) de so_line_new_project_with_tasks # car on laisse le fonctionnement natif pour les articles où on crée le projet sans les tâches so_line_new_project_with_tasks = self.mapped('order_line').filtered( - lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_new_project') + lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_in_project') if (so_line_new_project_with_tasks and not self.project_id_linked) and ( so_line_new_project_with_tasks and not self.project_name_to_create): raise ValidationError( @@ -73,14 +73,14 @@ class SaleOrder(models.Model): class SaleOrderLine(models.Model): _inherit = "sale.order.line" - def _convert_qty_company_hours(self): + def _convert_qty_company_hours(self, dest_company): """ Reprise de la fonction native pour changer le mode de calcul des heures planifiées dans timesheet """ - company_time_uom_id = self.env.user.company_id.project_time_mode_id + company_time_uom_id = dest_company.project_time_mode_id taux_horaire = self.order_id.taux_horaire if self.product_uom.id != company_time_uom_id.id \ and self.product_uom.category_id.id == company_time_uom_id.category_id.id: - planned_hours = super(SaleOrderLine, self)._convert_qty_company_hours + planned_hours = super(SaleOrderLine, self)._convert_qty_company_hours(dest_company) else: planned_hours = (self.product_uom_qty * self.price_unit) / taux_horaire return planned_hours @@ -115,7 +115,7 @@ class SaleOrderLine(models.Model): so_line_task_global_project = self.filtered( lambda sol: sol.is_service and sol.product_id.service_tracking == 'task_global_project') so_line_new_project = self.filtered( - lambda sol: sol.is_service and sol.product_id.service_tracking in ['project_only', 'task_new_project']) + lambda sol: sol.is_service and sol.product_id.service_tracking in ['project_only', 'task_in_project']) # search so lines from SO of current so lines having their project generated, in order to check if the # current one can create its own project, or reuse the one of its order. @@ -123,11 +123,11 @@ class SaleOrderLine(models.Model): if so_line_new_project: order_ids = self.mapped('order_id').ids so_lines_with_project = self.search([('order_id', 'in', order_ids), ('project_id', '!=', False), ( - 'product_id.service_tracking', 'in', ['project_only', 'task_new_project']), + 'product_id.service_tracking', 'in', ['project_only', 'task_in_project']), ('product_id.project_template_id', '=', False)]) map_so_project = {sol.order_id.id: sol.project_id for sol in so_lines_with_project} so_lines_with_project_templates = self.search([('order_id', 'in', order_ids), ('project_id', '!=', False), ( - 'product_id.service_tracking', 'in', ['project_only', 'task_new_project']), + 'product_id.service_tracking', 'in', ['project_only', 'task_in_project']), ('product_id.project_template_id', '!=', False)]) map_so_project_templates = {(sol.order_id.id, sol.product_id.project_template_id.id): sol.project_id for sol in so_lines_with_project_templates} @@ -153,7 +153,7 @@ class SaleOrderLine(models.Model): if map_sol_project.get(so_line.id): so_line._timesheet_create_task(project=map_sol_project[so_line.id]) - # project_only, task_new_project: use the project linked to the sale_order. May be create a task too. + # project_only, task_in_project: use the project linked to the sale_order. May be create a task too. for so_line in so_line_new_project: project = so_line.project_id # on récupère les variables de classes créées @@ -178,7 +178,7 @@ class SaleOrderLine(models.Model): map_so_project_templates.get((so_line.order_id.id, so_line.product_id.project_template_id.id)) or map_so_project.get(so_line.order_id.id) ) - if so_line.product_id.service_tracking == 'task_new_project': + if so_line.product_id.service_tracking == 'task_in_project': if not project: if so_line.product_id.project_template_id: project = map_so_project_templates[