# Price list sequence / quantity

**URL:** <https://discuss.tryton.org/t/price-list-sequence-quantity/5386>\
**Category:** User\
**Created:** [June 25, 2022, 7:30am UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386 "2022-06-25T07:30:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lars\_wuerfel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/lars_wuerfel/32/2794_2.png) [@lars\_wuerfel](https://discuss.tryton.org/u/lars_wuerfel)\
**Post date:** [June 25, 2022, 7:30am UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/1 "2022-06-25T07:30:04Z")

</div>

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:

 ![20220625_091655](https://discuss-cdn.tryton.org/uploads/default/original/2X/2/2123647ac2213e6cfaf508d85fee0b38f39692fe.png)

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

 ![20220625_092023](https://discuss-cdn.tryton.org/uploads/default/original/2X/c/ced2b2e1347db820fa4b4d28a51c73054dd23539.png)

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?

---

<div class="post-metadata">

**Author:** ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)\
**Post date:** [June 25, 2022, 12:36pm UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/2 "2022-06-25T12:36:38Z")

</div>

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

 ![2022-06-25_14-35](https://discuss-cdn.tryton.org/uploads/default/original/2X/d/d85b249d1779e1db53e95afa3b34502e115fe454.png)

---

<div class="post-metadata">

**Author:** ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)\
**Post date:** [June 25, 2022, 9:43pm UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/3 "2022-06-25T21:43:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [June 26, 2022, 7:01am UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/4 "2022-06-26T07:01:59Z")

</div>

> [@SISalp](#):
>
> remember correctly the logic, first condition is evaluated, if true, calculate price and exit, if fault, go to next line

That’s exactly how price list work

---

<div class="post-metadata">

**Author:** ![lars\_wuerfel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/lars_wuerfel/32/2794_2.png) [@lars\_wuerfel](https://discuss.tryton.org/u/lars_wuerfel)\
**Post date:** [June 26, 2022, 11:44am UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/5 "2022-06-26T11:44:59Z")

</div>

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,

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

```

would give the correct result as the first matching line.

I tried to extend the class PriceListLine, adding

```auto
  _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!

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [June 26, 2022, 7:55pm UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/6 "2022-06-26T19:55:44Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![jeromarquez](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jeromarquez/32/452_2.png) [@jeromarquez](https://discuss.tryton.org/u/jeromarquez)\
**Post date:** [June 26, 2022, 9:41pm UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/7 "2022-06-26T21:41:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lars\_wuerfel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/lars_wuerfel/32/2794_2.png) [@lars\_wuerfel](https://discuss.tryton.org/u/lars_wuerfel)\
**Post date:** [June 27, 2022, 6:30am UTC](https://discuss.tryton.org/t/price-list-sequence-quantity/5386/8 "2022-06-27T06:30:56Z")

</div>

> [@ced](#):
>
> 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`.

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!
