如何解决如何将上下文从向导传递到视图奥多13
在向导中,我添加了一个字段 product_id
和按钮。
选择产品并单击按钮时,我想获得产品的 stock.quant
树视图。
如何在上下文中传递值?
class Wizard(models.TransientModel):
_name = 'wizard.wizard'
product_id = fields.Many2one('product.product',string="Product")
@api.model
def my_button(self):
return {
'name': _('Products'),'view_type': 'tree','view_mode': 'list','res_model': 'stock.quant','context': {},'type': 'ir.actions.act_window','target': 'new',}
解决方法
self
代表当前记录集。我们可以用 self.product_id
例如:
"context": {"default_product_id": self.product_id.id,"search_default_product_id": self.product_id.id},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。