odoo 10产品货币

时间:2017-07-17 14:23:27

标签: python inheritance currency odoo-10

原始代码:

class name= "product.template"
currency_id = fields.Many2one(
        'res.currency', 'Currency', compute='_compute_currency_id')

我只想从product_template类继承currency_id。你可以从图片中看到。

class product_price_currency(models.Model):
      _inherit = 'product.template'
      currency_id = fields.Many2one('res.currency', 'Currency', required=True)

如你所见,我刚刚删除了计算功能,它应该可以正常工作而不需要调用计算功能,但它不起作用。仍然调用计算功能。我找不到问题出在哪里。我希望有人可以帮助我。

谢谢。

2 个答案:

答案 0 :(得分:0)

你需要写store = True

class product_price_currency(models.Model):
      _inherit = 'product.template'
      currency_id = fields.Many2one('res.currency', 'Currency', required=True,store=True)

因为在基本模块中,此字段为 store = False ,并且您在没有 store = True 的情况下继承,因此odoo仍在考虑 store = False < / strong> field。

这可能会对你有帮助。

答案 1 :(得分:-1)

您可以尝试类似

的内容
class product_price_currency(models.Model):
  _inherit = 'product.template'
  currency_id = fields.Many2one('res.currency', 'Currency', required=True,store=True,readonly=False)