From 8d128b651e80a8669a47a628fde1a49b443a6f59 Mon Sep 17 00:00:00 2001 From: Abdellatif BENZBIRIA Date: Tue, 17 Mar 2026 11:37:43 +0000 Subject: [PATCH] =?UTF-8?q?Revert=20"TA#83121=20[IMP]=20project=5Ftask=5Fa?= =?UTF-8?q?nalytic=5Flines=20:=20compute=20project=20from=20ori=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f9711f9c64444f476d74c5d6f55cc7159ca86b44. --- project_task_analytic_lines/__manifest__.py | 2 +- .../migrations/14.0.1.3.0/post-migration.py | 39 ------------------- .../models/account_analytic_line.py | 9 ----- project_task_analytic_lines/tests/common.py | 10 +---- 4 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 project_task_analytic_lines/migrations/14.0.1.3.0/post-migration.py diff --git a/project_task_analytic_lines/__manifest__.py b/project_task_analytic_lines/__manifest__.py index b851e2f7..0e9cadf3 100644 --- a/project_task_analytic_lines/__manifest__.py +++ b/project_task_analytic_lines/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Project Task Analytic Lines', - 'version': '14.0.1.3.0', + 'version': '14.0.1.2.1', 'author': 'Numigi', 'maintainer': 'Numigi', 'website': 'https://numigi.com/', diff --git a/project_task_analytic_lines/migrations/14.0.1.3.0/post-migration.py b/project_task_analytic_lines/migrations/14.0.1.3.0/post-migration.py deleted file mode 100644 index 9f1ed868..00000000 --- a/project_task_analytic_lines/migrations/14.0.1.3.0/post-migration.py +++ /dev/null @@ -1,39 +0,0 @@ -# © Numigi (tm) and all its contributors (https://numigi.com/r/home) -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -import logging - -_logger = logging.getLogger(__name__) - - -def migrate(cr, version): - """ - Post-migration script to update the project_id on existing analytic lines. - It uses raw SQL for better performance on large tables. - """ - if not version: - return - - _logger.info("Starting the update of project_id on analytic lines...") - - # Set project_id from task_id if available - cr.execute(""" - UPDATE account_analytic_line aal - SET project_id = pt.project_id - FROM project_task pt - WHERE aal.project_id IS NULL - AND aal.task_id = pt.id - AND pt.project_id IS NOT NULL - """) - - # Set project_id from origin_task_id if task_id did not provide a project - cr.execute(""" - UPDATE account_analytic_line aal - SET project_id = pt.project_id - FROM project_task pt - WHERE aal.project_id IS NULL - AND aal.origin_task_id = pt.id - AND pt.project_id IS NOT NULL - """) - - _logger.info("Analytic lines successfully updated.") diff --git a/project_task_analytic_lines/models/account_analytic_line.py b/project_task_analytic_lines/models/account_analytic_line.py index db4d1ee7..817d145d 100644 --- a/project_task_analytic_lines/models/account_analytic_line.py +++ b/project_task_analytic_lines/models/account_analytic_line.py @@ -15,15 +15,6 @@ class AnalyticLine(models.Model): "project.task", "Origin Task", ondelete="restrict", index=True ) - @api.depends('task_id', 'task_id.project_id', 'origin_task_id', - 'origin_task_id.project_id') - def _compute_project_id(self): - for line in self.filtered(lambda line: not line.project_id): - if line.task_id.project_id: - line.project_id = line.task_id.project_id - if not line.task_id.project_id and line.origin_task_id.project_id: - line.project_id = line.origin_task_id.project_id - @api.model def search(self, args, offset=0, limit=None, order=None, count=False): args = args or [] diff --git a/project_task_analytic_lines/tests/common.py b/project_task_analytic_lines/tests/common.py index 0cbf7dea..4a434960 100644 --- a/project_task_analytic_lines/tests/common.py +++ b/project_task_analytic_lines/tests/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © Numigi (tm) and all its contributors (https://numigi.com/r/home) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). @@ -15,11 +14,7 @@ def setUpClass(cls): "login": "account_user", "email": "account_user@test.com", "groups_id": [ - (4, cls.env.ref("account.group_account_invoice").id), - (4, cls.env.ref("analytic.group_analytic_accounting").id), - (4, cls.env.ref("project.group_project_manager").id), - (4, cls.env.ref("hr_timesheet.group_timesheet_manager").id), - ], + (4, cls.env.ref("account.group_account_invoice").id)], } ) @@ -115,5 +110,4 @@ def _get_invoice_line_vals(cls, **kwargs): def _validate_invoice(self): self.invoice.invoice_date = '2023-01-01' - # In Odoo 14, use .with_user(user) instead of the deprecated .sudo(user) - self.invoice.with_user(self.account_user).action_post() + self.invoice.sudo(self.account_user).action_post()