Skip to Content
Menu
This question has been flagged
1 Reply
5260 Views



I have 2 tables

1- fci_assignment_stuff

2- fci_assignment pool 

i need when i change state in first table it should change in the other table too

Here is my code to change the other table  but it does not run  :(

def act_finish(self, cr, uid, ids, context=None):

if context is None:

context = {}

assignment_obj = self.pool.get("fci.assignment.pool")

for ass_data in assignment_obj.browse(cr, uid, ids, context=context):

ass_data.search(cr,uid,('code', '=', self.code)).write(cr, uid, {'state':'f'})

return True
 

Avatar
Discard
Author

sry @Cyril Gaspard (GEM) but it doesn't work :( it deosn't change the status in th other table i only change this assignment_obj.write(cr, uid, assignment_ids, {'state':'f'}, context=context) because it's the new status

Author

i edit it more ... it worked ... thanks :D

Best Answer

Hi, something like this :

def act_finish(self, cr, uid, ids, context=None):

    context = context or {}

    assignment_obj = self.pool.get('fci.assignment.pool')

    for record in self.browse(cr, uid, ids, context=context):

        if record.code:

            assignment_ids = assignment_obj.search(cr, uid, [('code', '=', record.code)], context=context)

            if assignment_ids:

                assignment_obj.write(cr, uid, assignment_ids, {'state': 'f'}, context=context)

return True

Bye
 

Avatar
Discard