Price list sequence / quantity

I have the following situation when working with price lists:

when I define a price list with volume prices, I intuitively choose the sequence from low to high:

100 Pc → sequence 1
200 Pc → sequence 2
and so on, like so:

In this case the price for the first record (sequence 1) is always picked, prices for higher quantities are ignored:

When I reverse the sequence:
Sequence 1 → 300 Pc
Sequence 2 → 200 Pc
Sequence 3 → 100 Pc

then the correkt price is picked.

Is it intended, or a bug? Or some misunderstanding on my part?

In the price_list, you’ve to define a formula for the quantity using those variables: unit_price, cost_price or list_price.
Example: Formula: unit_price * 0.9

If I remember correctly the logic, first condition is evaluated, if true, calculate price and exit, if fault, go to next line
so the behavior you describe seems correct.

That’s exactly how price list work

Thank you, I understand the result now, and I see the benefit with formula based price lists for groups (few price list lines for a lot of products).

For my use case (individual volume prices for one single product) it would be great if the line with the highest quantity would be picked, if the sequence is null or equal.

In PostgreSQL,

[...] ORDER BY sequence ASC, quantity DESC

would give the correct result as the first matching line.

I tried to extend the class PriceListLine, adding

  _order = [('quantity', 'DESC')]

but this has no effect.

Is there a possibility to have a second order criteria (Quantity, descending) for the sequence ordered price list lines?

Thanks for all your help!

There are many criteria so the order can not be computed from only a single criteria. This is why we use a sequence.

But now as it seems you want to define a set of prices per individual product, it may be better to just store on each product a list of quantity/price and return the right price in Product._get_sale_unit_price. So your price list will be simpler and only contain general/global formula using unit_price.

Tried ordering exactly opposite than the example? This would work.

Yes, I think that is the way to go for this special use case; thank you for the hint to _get_sale_unit_price.
For now, I wrote a simple Proteus script which resets the sequence for all price list lines to the desired order (descending by quantity per product). I let the script run nightly, which is okay for now.

Next I will try to write a module as suggested by you.

Thank you all for your help!