add project_task_analytic_account_sync
This commit is contained in:
parent
5247938b86
commit
0f2c8c0565
9 changed files with 203 additions and 0 deletions
20
project_task_analytic_account_sync/models/project_project.py
Normal file
20
project_task_analytic_account_sync/models/project_project.py
Normal 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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue