I'm working on a v8 module that adds a field 'customer_group' to partners.
When I change this field on a Company, I want all Contacts connected to this company to also get the same value in their 'customer_group' field. I cannot for the life of me manage to change the 'customer_group' field on the childs of a partner. I am able to change other fields (as a test) on the childs, but not this specific field.
What's wrong with my code?
from openerp import models, fields, api
class CustomerGroup(models.Model):
_name = 'dummy.customergroup'
name = fields.Char('Group name', required=True)
description = fields.Text()
class ResPartner(models.Model):
_inherit = 'res.partner'
customer_group = fields.Many2one('dummy.customergroup', 'Customer group')
@api.onchange('customer_group')
def _update_contact_customer_group(self):
for id in self.child_ids:
id.street = "TESTSTREET" # AS A TEST, THIS WORKS
id.title = 1 # AS A TEST, THIS WORKS
# NONE OF THE BELOW WORKS, I'M TRYING AS A TEST TO SET GROUP NUMBER 3 (I HAVE 5 GROUPS CREATED)id.customer_group = 3
id.customer_group = self.env['dummy.customergroup'].browse([3])
id.customer_group = self.env['dummy.customergroup'].browse(3)