Ordering function field depending of the "parent" of an origin field

12 views
Skip to first unread message

Maxime Richez

unread,
May 2, 2018, 10:00:25 AM5/2/18
to tryton-dev
Hi,

Here are some explanations before the questions:
The Purchase_Request could have as origin a PurchaseRequisition_Line which is depending of a PurchaseRequisition. I'm adding some function fields on my PurchaseRequest: those fields are employee and number from PurchaseRequisition.
But then, i wish ordering those function fields...

I saw some examples to redefine order but never with 3 models, it's often one join between 2 models and also in my case field origin involved in the join condition is a tuple... here's my code (not working for ordering, i got 'TypeError: tuple indices must be integers, not NoneType' and also i don't know if the "join" is correct).

https://pastebin.com/TkTcw2ZL

Thanks for help!

Cédric Krier

unread,
May 4, 2018, 3:25:06 AM5/4/18
to tryton-dev
Hi,

On 2018-05-02 07:00, Maxime Richez wrote:
> I saw some examples to redefine order but never with 3 models, it's often one join between 2 models and also in my case field origin involved in the join condition is a tuple... here's my code (not working for ordering, i got 'TypeError: tuple indices must be integers, not NoneType' and also i don't know if the "join" is correct).
>
> https://pastebin.com/TkTcw2ZL

It will be easier to have the full traceback.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Maxime Richez

unread,
May 4, 2018, 3:31:44 AM5/4/18
to tryton-dev
> It will be easier to have the full traceback.

https://pastebin.com/Derb7cna

Client traceback: https://pastebin.com/XkDAZt2V

Did i proceed correctly to join tables?

Cédric Krier

unread,
May 4, 2018, 5:10:06 AM5/4/18
to tryton-dev
The value for 'requisition' should again be a dictionary with a None key
etc.

Maxime Richez

unread,
May 4, 2018, 5:56:28 AM5/4/18
to tryton-dev
>
> The value for 'requisition' should again be a dictionary with a None key
> etc.

Ok that solves the tuple error :-)

Now, my error is about the correct column for sorting : https://pastebin.com/q3MvMtEc

How to specify sort on the correct column "c.employee" instead of "b.employee"?


Maxime Richez

unread,
May 4, 2018, 8:04:17 AM5/4/18
to tryton-dev

> How to specify sort on the correct column "c.employee" instead of "b.employee"?
In the convert_order method in fields.py, it's using:
table, _ = tables[None]

but in my case it should use
table, _ = tables['requisition'] to use the correct column for the order ???

Cédric Krier

unread,
May 4, 2018, 8:40:05 AM5/4/18
to tryton-dev
So pass the right dictionary to convert_order

Maxime Richez

unread,
May 4, 2018, 9:19:35 AM5/4/18
to tryton-dev
> So pass the right dictionary to convert_order
Understood :-)

Here's a working example:

https://pastebin.com/BHVTQ6qR

Thanks for your help !


Reply all
Reply to author
Forward
0 new messages