我在模型analytic_account_id
中有sale_order_line
,如何从project_id
获得analytic_account_id
相关信息? (我想在相关project_id
的{{1}}填充sale_order_line
上添加字段功能by project_id
,我不知道怎么做Odoo-10,帮帮我请...
答案 0 :(得分:0)
我不知道这是否是最佳方法,但可以帮助您:
在sale.order.line
模型中定义:
project_id = fields.Many2one('project.project', compute='compute_project_id')
@api.one
@api.depends('analytic_account_id')
def compute_project_id(self):
project_id = self.env['project.project'].search([('analytic_account_id', '=', self.analytic_account_id.id)], limit=1)
self.project_id = project_id and project_id.id or False
我希望这对你有所帮助。