Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

increment sale order line sequence by 10

Odoberať

Get notified when there's activity on this post

This question has been flagged
sequenceincrementorder.line
1 Odpoveď
13969 Zobrazenia
Avatar
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
Avatar
Zrušiť
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.

Avatar
Anil Kesariya
Best Answer

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
Avatar
Zrušiť
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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Auto Generated Increment ID - V8
sequence sales.order increment
Avatar
0
júl 17
4983
Sequence (Auto Increment No.) Solved
sequence sequencenumber increment applicants
Avatar
Avatar
1
mar 15
14686
Sequence Prefix
sequence
Avatar
0
feb 23
6155
How to customize the invoice,bill and journal name sequence
sequence
Avatar
0
jan 23
95
skip the section and note while creating a serial number in order line
sequence serial_number note order.line section
Avatar
Avatar
Avatar
2
okt 22
5708
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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