Search code examples
pythoninheritancecurrencyodoo-10

odoo 10 product currency


Original Code:

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

I just want to inherit currency_id from product_template class. You can see from the picture.

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

as you see i just deleted compute function and it should work fine without calling compute function but it does not work. still call compute function. I could not find where is the problem. I hope someone can help me.

Thank you.


Solution

  • You need to write store=True

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

    Because in base module this field is store=False and you have inherit without store=True, due to that reason odoo still considering store=False field.

    This may help you.