Am 25.04.2017 um 18:14 schrieb Ul:
> Hello,
>
> i have a Problem with domains on a fields.Reference:
>
> I want to restrict the value of a Many2One field depending on a
> fields.Reference in the target.
>
> The target is a stock.lot that i extended with a field.Reference called
> 'origin'.
>
> Now i want to restrict the lots in a M2O-field in another Model to a
> certain lot.origin.
>
> One try was giving the value of the Reverence as a tuple:
>
> supplier_lot = fields.Many2One('stock.lot', 'Supplier Lot',
> domain=[ ('origin', '=',
> ('party.party', Eval('context', {}).get('supplier', -1))
> ),
> ('product', '=', Eval('product'))
> ])
>
> This way it works fine when creating:
> - only the right Lots are sugested in the search
> - creating new lots the origin fields are filled with the right values
> - the new lot is saved to all right with the right origin
> but when i want to save the record with the field 'supplier_lot'
> containing the domain, i get a popup stating that i cant save because of
> a domain mismach in this field. Did i miss anything here, or is this a
> bug? Unfortunaltelly i was not able to spot the very place this domain
> is validated and fails.
>
I've solved my Problem and, as often, it was hidden in a slightly
different place than expected:
In the domain i used a custom value of the context, that wasn't properly
set.
I had set it in the __setup__ method:
cls.incoming_moves.context.update({'supplier': Eval('supplier', -1)})
so the client was aware of it and filled the fields, and filtered well.
But i missed to set it in the server, so the validation failed, because
in the domain the server used to validate the record id of the reference
field wasn't set.
Anyway thanks for your help
Ulrich
--
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/06de4930-799e-36d7-d2ea-62610e07a57b%40gmx.de.