Odoo Help


Lines in Sale Orders don't respect order in which they are entered

on 12/2/14, 7:45 AM 1,304 views

When I enter new lines in Sale Orders they are ordered correctly, but as soon as I click either the update or save buttons, the sequence in which the lines where ordered gets messed up.

I would like the lines to respect the order in which I enter them. How can I accomplish this? or am I the only one this issue?



| 6 4 7
Lodz, Poland

On 4/4/15, 7:39 AM

See: How to reorder lines in a quotation? 


or you change default sort oder for sale.order.line from

_order = 'order_id desc, sequence, id' 

 to other, which suits you. For example:

class sale_order_line(models.Model): 
   _inherit = 'sale.order.line'
   _order = 'order_id desc, id'


Thanks zbik, I already saw that, and use it on a daily basis, but that does not solve the core problem I have.

on 4/4/15, 7:43 AM

My problem is that the lines do not maintain the order in which they are entered. I initially thought it was a misbehavior caused by one of the modules I had installed, but I created a new empty database with the very basic official modules installed and the same problem appeared to occur....so I'm really surprised I'm the only one complaining about it.

on 4/4/15, 7:46 AM

@Rachid answer is for you, sequence field value determines order.

on 4/4/15, 8:18 AM

... and ... if you drag and drop the default sequence value change.

on 4/4/15, 8:25 AM

The behavior I've noticed is the following, if you enter each product line continuously by clicking "Add an item" and add all items one after another without abandoning the "Create: Order Lines" form by clicking "Save & New", once you're done entering them all this way and click "(update)" or "Save" the Sale Order, the items respect the order in which they where entered. BUT, if for example you add an item by clicking "Add an item" then click "Save & Close" on the ""Create: Order Lines", once you start adding items again, any new items you add will appear after the first line entered in the Sale Order one you save or update it, instead of being places after the LAST line in the sequence they have been added. This behaviour is very annoying specially when creating a quotation with many items, it can get all messed up and you have to drag and drop each item to place them in the intended order.

on 4/4/15, 8:45 AM

Yes, if I drag and drop the sequence changes....but I shouldn't have to drag and drop! that's the thing. The lines should be respect the order in which they are entered...one after the other. Dragging and dropping should only be used if you want to modify the intended sequence later on.

on 4/4/15, 8:51 AM

answer updated

on 4/4/15, 9:34 AM

Thanks. I had tried that as well, that way the order of the lines work as it should....but, drag and drop does not work, since the sequence of the lines isn't taken into account. So I discarded that option as well....

on 4/4/15, 9:49 AM

I have been further troubleshooting this, and there's some kind of obvious bug in the way the sequencing works. If you look in the database (PGAdmin3) in sale_order_line table, you'll see that if you add several items, the sequence increments, for example 10 (Item 1), 11 (Item 2), 12 (Item 3), 13 (Item 4)....but once you save or update the Sale Order, and then edit and add new lines, the sequence always starts at 11, for example 10 (Item 1), 11 (Item 5), 12 (Item 6), 13 (Item 2), 14 (Item 3), 15 (Item 4) .......when it should be as follows 10 (Item 1), 11 (Item 2), 12 (Item 3), 13 (Item 4), 14 (Item 5), 15 (Item 6)

on 4/4/15, 9:58 AM

Does anyone else have this issue...or is it just me? As I mentioned earlier, I tried on a new empty database...and the same issue applies, so I don't think it's only me....

on 4/4/15, 10:01 AM

In my system V8 all sequences value = 10, without drag and drop. V7 or V8? Field sequence is INTEGER can not change for no reason!

on 4/4/15, 10:12 AM

Ok, you are right zbik, I narrowed it down to the module "nan_product_pack" being the one causing this misbehavior. The module increments the sequence per line, and in the process messes up the order. For some reason I installed this module in the new database as well and forgot I had done so later on....sorry for all the fuss, and thanks for you help zbik and Rachid, I'll try to figure out how to fix "nan_product pack" as it's an essential module in our business...

on 4/4/15, 1:12 PM
On 12/2/14, 11:52 AM

Hi Rachid (sorry, I can't comment your post, as I need 50 karma points to do so),

I'm aware of the default sequence number, and that you can change it in sales.py file...or through a module. I'm also aware that you can reorder the lines by dragging and dropping them manually after they've been messed up. But what I don't understand is why the lines don't stay in the order I've added them by default.

For example, I add:

Line 1

Line 2

Line 3

I expect it to stay as:

Line 1

Line 2 

Line 3

and not as this, which is the actual behaviour:

Line 1

Line 3

Line 2

There doesn't seem to be much logic behind this default behaviour.

So far I haven't found many posts complaining about this issue, so I'm starting to suspect it might be a behaviour specific to my OpenERP installation. Is anyone else facing this issue (line order being messed upon save or update of the order/invoice/picking)?

Qamar Soft
On 12/2/14, 10:54 AM

you can sort them with using the sequence field

the sequence take a default number=10

so if you want to make a line first you can put a minum sequence number like:

1st line : sequence=8

2nd line : sequence=9

3rd line : sequence=10



About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/2/14, 7:45 AM
Seen: 1304 times
Last updated: 4/4/15, 8:41 PM