Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

increment sale order line sequence by 10

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
sequenceincrementorder.line
1 Răspunde
13976 Vizualizări
Imagine profil
Wided Kefi

I'd like that every time, I add an item in a sale order, the sequence field is automatically incremented by 10.

What I did:

class sale_order_line(osv.osv):

    _inherit = 'sale.order.line'

    _columns = {
       'sequence': fields.char('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),
               }

    _defaults = {
       'sequence':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'sale.order.line'),    
            }

sale_order_line()

 <record id="seq_type_sale_order_line" model="ir.sequence.type">
     <field name="name">Sale Order Line</field>
     <field name="code">sale.order.line</field>
</record>
<record id="seq_sale_order_line" model="ir.sequence">
     <field name="name">Sale Order Line</field>
     <field name="code">sale.order.line</field>            
     <field name="padding">3</field>
     <field name="number_increment">10</field>
     <field name="number_next">10</field>
 </record> 

The sequence is incremented, but when I create a new sale order, it doesn't reset to 10. If I have SO1 with 3 sale lines, I have sequences 010, 020 and 030. But in SO2, I have 040 and 050, instead of 010 and 020.

How can I modify my code?

0
Imagine profil
Abandonează
Emipro Technologies Pvt. Ltd.

It doesn't reset automatically. It will continuously increases everytime you fetch the record. Why do you need to start from '10' everytime?

Kalpana Hemnani

You can use functional field in sales order line for creating a sequence as '010' instead using ir.sequence. Else you can reset sequence every time when a sales order created.

Wided Kefi
Autor

Thanks for your answers. I need to start from '10' everytime because it's clearer, if I have many sales orders with many lines increasing everytime, I would attend numbers like 653240, and it would be difficult to distinguish which line has the lowest sequence. I tried using an onchange method, but I cannot call it in xml file because I should call it in sale.order model () but the onchange method is defined in sale.order model.

Imagine profil
Anil Kesariya
Cel mai bun răspuns

Hello Wided,

Here you don't need to create ir.sequence record ,because it will always incremented.

better solution is to override default_get method of sale order line.

I have already given answer for this. Have a look on this answer it will help you.

https://www.odoo.com/forum/help-1/question/how-to-generate-automatic-sequence-number-in-one2many-field-67834#answer-67880

Regards,

Anil.

2
Imagine profil
Abandonează
Wided Kefi
Autor

Thanks Anil Kesariya, I've tried your code, but I always have 10 in my field "sequence", after debugging, I found that the line: if len(context.get('order_line')) > 0 is not executed, because context.get('order_line')=[], so len ( context.get('order_line')) is always 0. I don't understand context in openerp very well, I don't know how to change the code to work.

Anil Kesariya

you need to pass your one2many field on context. whatever fields name is for eg. if sale order line than pass . you need to inherit the sale view and add context on sale order line field than it will work. so our default get method will get the line value. if any line added in your current sale order record.

Wided Kefi
Autor

I did that: But I still get always 10 in sequence field.

Wided Kefi
Autor

I've found that the function is working when I use "add an item", but it's not working when I use "save and create". I'm trying to make it work when using "save and create".

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Auto Generated Increment ID - V8
sequence sales.order increment
Imagine profil
0
iul. 17
4988
Sequence (Auto Increment No.) Rezolvat
sequence sequencenumber increment applicants
Imagine profil
Imagine profil
1
mar. 15
14694
Sequence Prefix
sequence
Imagine profil
0
feb. 23
6163
How to customize the invoice,bill and journal name sequence
sequence
Imagine profil
0
ian. 23
95
skip the section and note while creating a serial number in order line
sequence serial_number note order.line section
Imagine profil
Imagine profil
Imagine profil
2
oct. 22
5711
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now