Hello ,
I have to try to perform two operation on one click. like first i am update a record on Table-1 one2many field and thats value is create in another Table-2 one2many table. but my task is when value is update on Table-1 than it's value create in Table-2 and Table-1 updated record is delete.
so my code is below in my code Table-1 is updated and Table-2 also updated but i am unable to delete record from Table-1
def action_assign_button(self):
active_ids = self._context.get('active_id')
res = self.env['weight.calculator'].browse(active_ids)
#Table-1
batch_obj = res.weight_cal_machine
for b_obj in batch_obj:
record_obj = b_obj.env['batch.num'].search([])
for record in record_obj:
if b_obj.select_pet == True: #select_pet = boolean field
#Record update in Table-1
b_obj.write({'batch_number': self.batch_no.batch_no})
if record.batch_no == b_obj.batch_number:
batch_history = { 'batch_obj': self.batch_no.id,
'process_opt':b_obj.process_opt.id,
'pet_load': res.sum,}
#Record create in Table-2
create_batch_history = self.env['batch.record'].create(batch_history)
print "batch_obj::::::::::::::;last", b_obj, b_obj.select_pet
b_obj.unlink()
So it's show error on unlink.
so any solution. ???
Thanks in Advanced.
It's show error on terminal
AttributeError: 'unicode' object has no attribute 'unlink'