Hi,
I'm new to Odoo /OpenERP and I'm trying to extend the sale module by adding a new field "linked"
to another field. To be more clear, I want to populate the new field "company_contact_id" when the field "company_id" is modified.
Here's my code
class sale_order(models.Model):
_inherit = 'sale.order'
company_contact_id = fields.Many2one('res.partner', string='Company contact', required=False, ondelete='restrict')
@api.onchange('company_id')
def _onchange_company_id(self):
partner_ids = self.env['res.partner'].search([('parent_id', '=', self.company_id)])
return {'domain': {'company_contact_id': ['id', 'in', partner_ids]}}
After updating the field "company_contact_id" is created in the table "sale_order" but when I try to change the field "company_id"
I get the following error :
AssertionError: Invalid value res.company(3,) in domain term ('parent_id', '=', res.company(3,))
I have no idea how to fix this.
Any idea ? Thanks