Hi, I've made a custom module with two models, let's call them "a.py" and "b.py".
I'll write down the important part of the two models for context
A.PY
class A(models.Model):
_name = 'a'
codice = fields.Char(string="Codice del corso", required=True)
costo_a_persona = fields.Monetary(string="Costo (a persona)", required=True)
currency_id = fields.Many2one("res.currency", string="Valuta", required=True)
a_b = fields.One2many('b', 'b_a', string="Edizioni del corso erogate:")
B.PY
class B(models.Model):
_name = 'b'
number = fields.Text(string="Numero edizione", required=True) b_a = fields.Many2one('a', string="Edizione del corso:", required=True)
I would like to give to "b.py" the Monetary and currency_id field (I'll not explain why to simplify, I just need them there too), but if I try to do it in the following way then when I restart Odoo and upgrade the module it would give me back the error:
B.PY
class B(models.Model):
[...]currency_corso_id = fields.Many2one("res.currency", string="Valuta", required=True)
costo_corso_a_persona = fields.Monetary(related="b_a.costo_a_persona", string="Costo a persona", store=True)
-> AssertionError: Field b.costo_corso_a_persona with unknown currency_field None
@sonia thanks!! now it works :)