Hie,

I have this code (is a wizard view)

class ShipmentOutPicking(ModelView):
    __name__ = 'stock.shipment.out.picking'
    shipment = fields.Many2One('stock.shipment.out', 'Shipment', required=True)
    moves = fields.One2Many('stock.move', None, 'Moves', readonly=True)

    def on_change_shipment(self, name=None):
        res = {}
        if self.shipment:
            res['moves'] = [m.id for m in self.shipment.inventory_moves]
        return res


1- Show moves

When select a shipment, add all shipment inventory moves in moves
field. I show moves in this field.

- v3.4

This code work successfully. It's ok.

- v3.8

This code doesn't work successfully

When on_change, the client get record2.id a negative id and add in
to_create list.
In v3.4 I recibe a positive id and add in to_add. Is the reason v3.4
work successfully and v3.8 not.

(1) to_add/to_create when record2.id > 0

Why am I missing in v3.8? or is a bugin v3.8?

Finally I changed "on_change_shipment()" to "on_change_with_moves()"
and v3.4 and v3.8 are working successfully.

2- Remove moves

How to remove records in moves filed (o2m) ?

I try this code:

    @fields.depends('shipment')
    def on_change_with_moves(self, name=None):
        if self.shipment:
            return [m.id for m in self.shipment.inventory_moves]
        else:
            return [] # what am I missing?

- v3.4

When remove shipment call "on_change" and enter in else.
But don't remove records. (nothing).

- v3.8

When remove shipment call "on_change" and enter in else.
Change black moves records to grey color (remove).

My wish list:

Is it possible to delete records in moves field when deselect a
shipment (reload)?

(1) 
http://hg.tryton.org/tryton/file/ed92378d8fdc/tryton/gui/window/view_form/model/field.py#l527

Thanks

-- 
Raimon

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/CAN2HbXVZGrxZfVNTthF-1oExv%2BbMTWwoTwuchsyvZW70tEZdfA%40mail.gmail.com.

Reply via email to