andreihondrari
andreihondrari

Reputation: 5833

stock.picking extension onchange for state not working

I have the following extension:

from openerp import models, api, fields

class MyExtension(models.Model):
    _inherit = 'stock.picking'

    some_instances = fields.One2many(comodel_name='some.some',
                                     inverse_name='return_picking')

    @api.onchange('state')
    def changed_return_picking_state(self):
        import ipdb; ipdb.set_trace()

When I transfer the picking or force it's availability, the onchange is not triggered.

Upvotes: 0

Views: 392

Answers (2)

PCatinean
PCatinean

Reputation: 106

Try using @api.depends instead, onchange operates as gurney alex mentioned

Upvotes: 1

gurney alex
gurney alex

Reputation: 13645

@api.onchange only works if the value is modified in a view in the web client. For stock.picking, the state attribute is generally modified on the server side by a call to write, therefore your decorated method is not called.

Upvotes: 1

Related Questions