add project_task_analytic_account_sync

This commit is contained in:
Luis 2026-06-16 10:56:18 +02:00
parent 5247938b86
commit 0f2c8c0565
9 changed files with 203 additions and 0 deletions

View file

@ -0,0 +1,20 @@
# Copyright 2026 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class ProjectProject(models.Model):
_inherit = "project.project"
def write(self, vals):
res = super().write(vals)
if "analytic_account_id" in vals:
self.env["project.task"].with_context(active_test=False).search(
[("project_id", "in", self.ids)]
).write({"analytic_account_id": vals["analytic_account_id"]})
return res
# No need to override _create_analytic_account: the core method already
# calls project.write({'analytic_account_id': ...}) which triggers our
# write() override above and propagates the account to all tasks.