order_field over a function field

5 views
Skip to first unread message

vuk

unread,
Mar 2, 2012, 10:45:03 AM3/2/12
to tryton-dev
hi everybody, I have this situation:

modelA
code = fields.Integer()
model_Bs = fields.One2Many('modelB','model_A')

modelB
model_A = fields.Many2One(modelA)
model_Cs = fields.One2Many('modelC','model_B')

modelC
model_B = fields.Many2One(modelB)
modelA_code = fields.Function(fields.Integer('model A
code'),'get_model_A_code')

So in modelC tree view I can display the model A code related to each
model C.
In this tree view I want to let user order by modelA_code and I
understand that I have to set the order_field property over
modelA_code field. but I'm not able to figure out the correct value
(if it's possible...)

I tried:

modelA_code = fields.Function(fields.Integer('model A
code',order_field='<modelA-table-name>.code %
(order)s'),'get_model_A_code')

where <modelA-table-name> is the name of the modelA db table but I get
the error "missing FROM-clause entry for table <modelA-table-name>":
of course, modelA table is not directly involved into the query (i
guess function field values are retrieved later by the getter
function)

any suggestions?
thanks
Reply all
Reply to author
Forward
0 new messages