This question has been flagged

Hello Community,

i have one many2one field at project.project and one at account.analytic.account I would like to pass the value from project to analytic account object whenever the project is created.

Kindly assist.


Avatar
Discard
Best Answer

Hey! Just a heads up, to pass the value from your project.project many2one field to account.analytic.account, you'll need to tweak the create method in the project.project model a bit. Make sure you update the related account.analytic.account record with the value from your project when it's created.

Avatar
Discard
Best Answer

Years ago but, at least in Odoo 15 it could be overriding project function where account.analytic.account is created, something like:

def _create_analytic_account_from_values(self, values):
    analytic_account = self.env['account.analytic.account'].create({
        'name': values.get('name', _('Unknown Analytic Account')),
        'company_id': values.get('company_id') or self.env.company.id,
        'partner_id': values.get('partner_id'),
        'active': True,
        'new_field1': values.get('project_field1'),
})
return analytic_account 

Don't forget to import:
from odoo import _

Avatar
Discard