Hello everyone,
I'm new to the Odoo development and I'm having quite a hard time understanding how inheritance works, or, better said, why inheritance is not working (for me).
The module I'm creating allows to create loyalty cards for customers. So for now I'm creating two very simple models: one of them is the loyalty card itself and the other one is a type of client who has the card. For this last model I'm trying to extend res_partner, which I think is the right call to do it:
class loyaltyCustomer(models.Model):
_name = 'loyalty.customer'
_inherit = 'res.partner'
comment = fields.Text()
loyaltyCard = fields.Many2one('loyalty.card', String="Tarjeta", required=False)
class loyaltyCard(models.Model):
_name = 'loyalty.card'
customer = fields.Many2one('loyalty.customer', String="Cliente")
barcode = fields.Char(String="", required=True)
loyaltyAmount = fields.Float()
returnsAmount = fields.Float()
After creating my views.xml I can create loyalty cards without any issue (I tried first using res_partner directly and it worked perfectly). But the moment I switch to use my custom model, using the same formview as res_partner, I get this error:
Odoo Server Error
Traceback (most recent call last):
[...a lot of lines...]
raise ValueError("Wrong value for %s: %r" % (self, value))
ValueError: Wrong value for loyalty.customer.commercial_partner_id: loyalty.customer(<odoo.models.NewId object at 0x10dde3c50>,)
And I really don't know what to do next to fix it, so any help would be really appreciated. I'm using Odoo 10.