Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3025 Widoki

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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 _

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
kwi 17
5568
0
paź 24
1036
1
sie 23
2521
1
sie 18
5674
0
sie 19
4416