This question has been flagged
3 Replies
6615 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?

Avatar
Discard
Best Answer

See: How to reorder lines in a quotation? 

UPDATE:

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'

 


Avatar
Discard
Author

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

Author

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.

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

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

Author

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.

Author

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.

answer updated

Author

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

Author

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)

Author

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

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!

Author

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

Author Best Answer


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)?



Avatar
Discard

the same we are facing at Odoo 11

Best Answer

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

 

 

Avatar
Discard