Python odoo 10产品货币

Python odoo 10产品货币,python,inheritance,currency,odoo-10,Python,Inheritance,Currency,Odoo 10,原始代码: class name= "product.template" currency_id = fields.Many2one( 'res.currency', 'Currency', compute='_compute_currency_id') 我只想从产品模板类继承货币id。你可以从照片上看到 class product_price_currency(models.Model): _inherit = 'product.template' c

原始代码:

class name= "product.template"
currency_id = fields.Many2one(
        'res.currency', 'Currency', compute='_compute_currency_id')
我只想从产品模板类继承货币id。你可以从照片上看到

class product_price_currency(models.Model):
      _inherit = 'product.template'
      currency_id = fields.Many2one('res.currency', 'Currency', required=True)
正如你们所看到的,我刚刚删除了compute函数,不调用compute函数它应该可以正常工作,但它不工作。仍然调用计算函数。我找不到问题出在哪里。我希望有人能帮助我


谢谢。

您需要编写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字段


这可能会对您有所帮助。

您可以尝试以下方法

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