I have two modules, each have their own state. I am trying to change state of other module's specific record. But my code changes the state of every record in that class. How can i change state of only the specified record.
My class look like this
@api.multi
def _create_load_up(self):
if self.state=='load':
inv_obj = self.env['loading.slip']
rec=inv_obj.search(self.so_no=='so_no')
if rec:
slip=rec.update({
'state':'load'
})
return slip
here I am trying o change the state of loading.slip table to load state when so_no are same of both table( recent table and loading_slip table)
But this changes every record's state to load in loading.slip.
Hi ,
As you told that all the record get updated there it should generate singleton error as per your code. make sure that search method returns a single record. If the search method returns more than one record please use for loop to update the state.
Also the search method is wrong, i mean the syntax. You can correct it as Amal or jignesh mentioned
Thank you guys for your reply, I have implemented the recommended method but when i use this method, before model changes its state to load, loading_slip model auto changes its state to load(i.e _create_load_up method is initially called what can i do for that.
Try changing method name to "create_load_up", also please check are you calling this function from any where