如何从哪个类中知道另一个类的方法在odoo中被调用

问题描述 投票:1回答:1

我有2个型号

  • 1:example.orderline
  • 2:product.product

在单独的类中]

example.orderline中有many2one字段“ stock”stock = fields.Many2one(“ product.product”,“ Product”)

我想为字段“ stock”覆盖模型“ product.product”的name_get方法我成功完成的工作:

def name_get(self):
     result = []
     for record in self:
        default_code = record.default_code
        result.append((record.id, default_code))

    return result

但是以上内容也适用于销售订单和采购订单。如何命名get方法仅适用于example.orderline模型?

我有2个模型1:example.orderline 2:product.product,它们在不同的类中,在example.orderline stock = fields.many2one(“ product.product”,“ Product”)中有many2one字段“ stock” ...

python odoo odoo-10
1个回答
1
投票

您可以在context模型视图侧使用example.orderline属性来处理上述情况。

© www.soinside.com 2019 - 2024. All rights reserved.