From 234231afdad828e74ae077cb0cf6833b82200393 Mon Sep 17 00:00:00 2001 From: Laetitia Da Costa Date: Wed, 20 Sep 2023 17:15:48 +0200 Subject: [PATCH 1/2] [FIX]project_parent_tasks:change behaviour of autocomplete task sale line --- project_parent_task/__init__.py | 1 + project_parent_task/__manifest__.py | 2 +- project_parent_task/models/__init__.py | 1 + project_parent_task/models/project_task.py | 21 +++++++++++++++++++++ project_parent_task/views/project_task.xml | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 project_parent_task/models/__init__.py create mode 100644 project_parent_task/models/project_task.py diff --git a/project_parent_task/__init__.py b/project_parent_task/__init__.py index e69de29..0650744 100644 --- a/project_parent_task/__init__.py +++ b/project_parent_task/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_parent_task/__manifest__.py b/project_parent_task/__manifest__.py index f855af4..ccaad95 100644 --- a/project_parent_task/__manifest__.py +++ b/project_parent_task/__manifest__.py @@ -3,7 +3,7 @@ { "name": "project_parent_tasks", - "version": "14.0.1.0.0", + "version": "14.0.1.1.0", "author": "Elabore", "website": "https://elabore.coop", "maintainer": "Laetitia Da Costa", diff --git a/project_parent_task/models/__init__.py b/project_parent_task/models/__init__.py new file mode 100644 index 0000000..cfd8e16 --- /dev/null +++ b/project_parent_task/models/__init__.py @@ -0,0 +1 @@ +from . import project_task \ No newline at end of file diff --git a/project_parent_task/models/project_task.py b/project_parent_task/models/project_task.py new file mode 100644 index 0000000..73f9300 --- /dev/null +++ b/project_parent_task/models/project_task.py @@ -0,0 +1,21 @@ + +from odoo import models, fields, api + +class Task(models.Model): + _inherit = "project.task" + + #overwrite others def _compute_sale_line(self) + #we want to skip _compute_sale_line in /home/laetitia/elabore/odoo/OCB/addons/sale_timesheet/models/project.py file + + @api.depends('commercial_partner_id', 'sale_line_id.order_partner_id.commercial_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id') + def _compute_sale_line(self): + for task in self: + # check sale_line_id and customer are coherent + if task.sale_line_id.order_partner_id.commercial_partner_id != task.partner_id.commercial_partner_id: + task.sale_line_id = False + if not task.sale_line_id: + task.sale_line_id = task.parent_id.sale_line_id or task.project_id.sale_line_id + + @api.onchange('parent_id') + def _onchange_parent_id(self): + self.sale_line_id = self.parent_id.sale_line_id or self.project_id.sale_line_id \ No newline at end of file diff --git a/project_parent_task/views/project_task.xml b/project_parent_task/views/project_task.xml index 816e3dd..97d09e8 100644 --- a/project_parent_task/views/project_task.xml +++ b/project_parent_task/views/project_task.xml @@ -6,7 +6,7 @@ - [('project_id','=', active_id)] + [('project_id','=', project_id)] -- 2.49.1 From ec074f365b237863690fbb8f5c01f63583b2ba6d Mon Sep 17 00:00:00 2001 From: LaetitiaElabore <144997989+LaetitiaElabore@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:50:52 +0200 Subject: [PATCH 2/2] Update project_task.py --- project_parent_task/models/project_task.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_parent_task/models/project_task.py b/project_parent_task/models/project_task.py index 73f9300..5cf9c23 100644 --- a/project_parent_task/models/project_task.py +++ b/project_parent_task/models/project_task.py @@ -5,7 +5,7 @@ class Task(models.Model): _inherit = "project.task" #overwrite others def _compute_sale_line(self) - #we want to skip _compute_sale_line in /home/laetitia/elabore/odoo/OCB/addons/sale_timesheet/models/project.py file + #we want to skip _compute_sale_line in sale_timesheet/models/project.py file @api.depends('commercial_partner_id', 'sale_line_id.order_partner_id.commercial_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id') def _compute_sale_line(self): @@ -18,4 +18,4 @@ class Task(models.Model): @api.onchange('parent_id') def _onchange_parent_id(self): - self.sale_line_id = self.parent_id.sale_line_id or self.project_id.sale_line_id \ No newline at end of file + self.sale_line_id = self.parent_id.sale_line_id or self.project_id.sale_line_id -- 2.49.1