【问题标题】:Odoo auto-fill fields when created from other form从其他表单创建时,Odoo 自动填充字段
【发布时间】:2017-11-16 15:06:29
【问题描述】:

知道当我从销售订单快速创建时如何填写产品页面上的某些字段。这些字段基于销售订单(名称和客户)。我需要将它们与上下文一起传递吗?

谢谢

【问题讨论】:

  • 你能详细解释一下你想要什么以及到目前为止你做了什么。

标签: python openerp field odoo-8


【解决方案1】:

是的,可以使用context 完成。在您的sale.order.line XML 视图中,您有一个名为product_id 的Many2one 字段(它指向product.product 模型)。

你必须为每个product.product字段指定你想要的默认值,提取当前视图的字段值(sale.order.line):

<xpath expr="//field[@name='product_id']" position="attributes">
    <attribute name="context">{'default_field_1': field_1, 'default_field_2': field_2}</attribute>
</xpath>

其中default_field_1 和default_field_2 是product.product 模型的字段,field_1 和field_2 是sale.order.line 模型的字段。

例子:

<xpath expr="//field[@name='product_id']" position="attributes">
    <attribute name="context">{'default_name': name}</attribute>
</xpath>

在上述情况下,当您从sale.order.line 树或表单视图创建新产品(单击Many2one 字段product_id 下拉列表的创建选项)时,product.product 表单将被打开name 字段自动填写当前销售订单行的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-01
    • 2012-02-18
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    • 2015-05-26
    • 2011-11-14
    相关资源
    最近更新 更多