[MIG] hr_expense_analytic_account_preselect_with_projec: migrate to 18.0

This commit is contained in:
Stéphan Sainléger
2026-05-05 17:26:12 +02:00
parent 69bc951b3e
commit ca1a5981b2
7 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import hr_expense

View File

@@ -0,0 +1,14 @@
from odoo import api, fields, models
class HrExpense(models.Model):
_inherit = "hr.expense"
project_id = fields.Many2one("project.project", string="Projet", required=True)
@api.onchange("project_id")
def set_analytic_account(self):
if self.project_id.account_id:
self.analytic_distribution = {str(self.project_id.account_id.id): 100}
else:
self.analytic_distribution = {}