Ul
unread,Apr 25, 2017, 12:16:03 PM4/25/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to try...@googlegroups.com
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.
The other try was using a fouth parameter in the domain with even worse
result:
supplier_lot = fields.Many2One('stock.lot', 'Supplier Lot',
domain=[ ('origin', '=',
Eval('context', {}).get('supplier', -1),
'party.party'
),
('product', '=', Eval('product'))
])
this way i get an Error in the Server when i start typing in the
'supplier_lot'-field, when it is trying to find sugestions:
Traceback (most recent call last):
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/protocols/dispatcher.py",
line 160, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelstorage.py",
line 381, in search_read
records = cls.search(domain, offset=offset, limit=limit, order=order)
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelsql.py",
line 1120, in search
tables, expression = cls.search_domain(domain)
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelsql.py",
line 1299, in search_domain
expression = convert(domain)
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelsql.py",
line 1297, in convert
domain[1:] if domain[0] == 'AND' else domain)))
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelsql.py",
line 1296, in <genexpr>
return And((convert(d) for d in (
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/modelsql.py",
line 1287, in convert
expression = field.convert_domain(domain, tables, cls)
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/fields/reference.py",
line 132, in convert_domain
return super(Reference, self).convert_domain(domain, tables, Model)
File
"/home/uha4/Computer/programmieren/python/trytond/trytond/model/fields/field.py",
line 300, in convert_domain
name, operator, value = domain
ValueError: too many values to unpack
thanks for any help...
Ulrich
PS: I'm using trytond 4.2 souces pulled from github