Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
3033 Представления

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.


Аватар
Отменить
Лучший ответ

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.

Аватар
Отменить
Лучший ответ

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 _

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
апр. 17
5570
0
окт. 24
1036
1
авг. 23
2526
1
авг. 18
5674
0
авг. 19
4418