Odoo18-Base/addons/project_hr_expense/models/hr_expense.py
2025-03-10 10:52:11 +07:00

15 lines
521 B
Python

from odoo import models
class HrExpense(models.Model):
_inherit = 'hr.expense'
def _compute_analytic_distribution(self):
project_id = self.env.context.get('project_id')
if not project_id:
super()._compute_analytic_distribution()
else:
analytic_account = self.env['project.project'].browse(project_id).analytic_account_id
for expense in self:
expense.analytic_distribution = expense.analytic_distribution or {analytic_account.id: 100}