Define ordering for a Function field with many origins

I’m trying to define the ordering method of a custom Function field in invoice line. This field has a getter method that gets value from different models depending on invoice line origin.
Let’s explain it more in detail:

  • the function field is an “origin_date” and is visible in standalone invoice lines.
  • when the origin is a purchase, the value is the purchase_date of the purchase
  • when the origin is an stock move, the value is the effective date of the move.

Define the ordering for each case is clear to me, but not how to combine them.
Is it possible? Any help will be appreciated.

You probably need to use a CASE clause based on multiple LEFT joins.

That is! Thanks a lot.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.