Here i try to update users value to one2many field (incentive_users_ids),but only last user value is updating ,not updating all the users details. i am getting below outupt
https://prnt.sc/h46n5u
(only one user listing) ,i have 5 users in user list
class IncentiveDetails(models.Model):
_name='incentive.details'
to_date=fields.Date('To')
incentive_users_ids=fields.One2many('incentive.users','incentive_id','Incentive Details')
@api.onchange('to_date')
def _onchange_date(self):
result=[] ######updated code now its working
for all_users in self.env['res.users'].search([]):
result.append((0,0,{'sales_user_id':all_users.id}))
for record in self:
record.incentive_users_ids=result
class IncentiveUsers(models.Model):
_name='incentive.users'
incentive_id=fields.Many2one('incentive.details')
sales_user_id=fields.Many2one('res.users','Sales Person')
If you give result=[] inside the loop, how do you expect to get all users value appended to your list?
yes.. correct