Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3010 Lượt xem

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.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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 _

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 17
5564
0
thg 10 24
1035
1
thg 8 23
2516
1
thg 8 18
5672
0
thg 8 19
4412