Skip to Content
Menu
This question has been flagged
2 Replies
3014 Zobrazenia

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
Zrušiť
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
Zrušiť
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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
apr 17
5566
0
okt 24
1036
1
aug 23
2516
1
aug 18
5672
0
aug 19
4412