Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

[18.0] How can I add a sequence to the lines in my sale order, invoice or purchase order?

1 备注
形象
丢弃
形象
odoo
-

Good afternoon, 

Thanks a lot for all the explaination. I need it also for my order.

I have a small difference compare to the original asking, I need to start from 10 and increase each line by 10.

For example line 1 will be 10, line 2 will be 20, etc. Is it possible to make it ? I search all the day for it... 

I'm on odoo sh.

Thanks for your help and have a nice day.

Jeremy

1 答案
0
形象
odoo
最佳答案

Part 1: (V.18) Add the sequence number for each item/product in the sales.order.line model. 


  1. From the sales.order model go to Studio.

2. Click on the “Edit list view” button to go to the sale.order.line model 


3. Add a related field to “sequence”.

4. Activate the Developer Mode

5. (Best practice) Change the label and then the technical name. 

Extra tip: When you finish typing the label, type "enter", wait for studio to load and it's coppied to the technical name.



6. Go to the a Sale Order and add a product in the sale lines to see how it works. 

We haven´t finished! The sequence starts with the number 10 and we need it to start from 1) Please go to the next step



7. In order to predefine the number 1 for the sequence as the default. Go to Settings / Technical / Actions / Use-defined defaults

8. Create a new User-defined Default 

  • Add the field: Sequence (Sales Order Line) -> You might need to search for it on the "search more" option
  • Default value: 1

If you don't find the field "search more" with these values: field: sequence, model: sale.order.line


9. Go to the sale.order model and see how it works. 


Note: You need to save it, in order to have a correct sequence. If you don't save it, you will always have the number 1 in the sequence field. 

Once it's saved you will have the correct sequence. 



Forum post part 2:

(V.18) How to add the sequence to the PDF?

  1. From the sale.order model go to Studio and find the reports you want to add the sequence field.


2. Insert a field 


3. Change the name of the field

4. In the rectangle below Type “/” and select “field”

5. Add the native field of Sequence (integer): 

6. Don´t forget to Save it 


7. Print the PDF and the sequence field will be shown.



3 注释
形象
丢弃
形象
odoo
-

I followed the same steps but it shows 1 , 1 , 1 for the line items then when i save it shows again 10,11,12
i compare the field: sequence which you made with mine, your screenshot shows the type is Base Field but mine shows it's Custom Field.
Could that be the problem?

形象
odoo
-

The Base Field is used on the pdf. It's already shown on the Form View but with a drag handle to re-sequence lines, so a new related field is added.

Probably you are trying to set the default value to 1 on the new related field, it needs to be on the Base field.

形象
odoo
-

Thank you, your solution is great. I followed it, but when I save, the sequence still stays as 1, 1, 1. It only reorders automatically when I drag and drop a line. How can I make it automatically adjust the sequence numbers 1, 2, 3 when I save the SO?