This question has been flagged
1 Reply
2060 Views

Hi guys

I just created a new model picking.process in a custom module.
Something strange happens. If someone can help me it would be great.

When i do this : 

class PickingProcess(models.Model):
    _inherit = "mail.thread"
    _name = 'picking.process'

    input_action = fields.Char("Action" ,store=True)

    @api.onchange("input_action")
    def on_change_input_action(self):
      _logger.error("ooooooooooooooooooooo")
        if self.input_action != self.input_action2 :
            self.pick = 4909
            _logger.error(self.pick)
            for pack in self.pick.pack_operation_ids:
      pack.qty_done = 1

the qty_done is not save BUT if i do pack.write({"qty_done":1}) it works. 

If i do that on a _compute with a for record in self: .....

it s the same thing so i imagine it s not the on_change the mistake. 


Could you explain me why? and what can i do for correct this bug it works perfectly in others model i made  :( 


Thanks a lot 

Avatar
Discard
Best Answer

Hi Thomas,

from your code it seems 'input_action' is a compute field and will get changed based on its compute function.


Try to create 'qty_done' as a compute field.


@api.depends(input_action, input_action2)

def _compute_qty_done(self):

logic here..



Hope this will work

Regards,




Email:     odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Discard