如何让向导从模型中获取变量值?

How to make Wizards take a variable value from a model?

我有一个问题,但我找不到解决方案。我有一个用于 属性 管理的模块。我有三个一起工作的文件,一个是 infom,一个是向导,另一个是发票视图。该向导会获取一些信息并将其放置到发票树视图中。

我从模型中得到了非常具体的信息,该模型是 "product.template"inheritance,它有一个名为 incharge_id 的变量 (field: Many2one)。我需要将此变量带到处理发票树视图的向导。虽然没有运气,但我尝试了很多东西。这是 product.template.

中的字段
incharge_id = fields.Many2one('res.partner', string="In Charge")

我需要拿到这里:

invoice_obj.sudo().create({'partner_id': self.partner_id.id,
                                                   'currency_id': self.property_id.monedha2.id,
                                                   'incharge_id': incharge.id,
                                                   'account_id': self.partner_id.property_account_receivable_id.id,
                                                   'origin': self.property_id.id,
                                                   'date_invoice': invoice_date,
                                                   'from_property': True,
                                                   'selection': origin + ", " + str(selection) + ", " + str(pagesa),
                                                   'date_due': due_date,
                                                   'invoice_line_ids': [(0, 0, {
                                                       'product_id': product_id.id,
                                                       'name': product_id.name,
                                                       'price_unit': price,
                                                       'quantity': 1,
                                                       'origin': product_id.name + " " + origin,
                                                       'account_id': account_id,
                                                   })],
                                                   })

非常感谢您的帮助!

你已经考了 product_id 这意味着你也可以考 incharge_id。

'product_id': product_id.id

检查 product_id 是否来自 class product.product 或 product.template。

如果product.template -->

'incharge_id': product_id.incharge_id.id

incase product.product -->

'incharge_id': product_id.product_tmpl_id.incharge_id.id