Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Real Estate
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Consulting
    • Accounting Firm
    • Партнер Odoo
    • Marketing Agency
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

How to create auto sequences for a new record?

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
sequenceprefixsequencenumberodoo
5 Відповіді
20531 Переглядів
Аватар
Haris Masqati

A CODE Char Field available analytic account module, when we create a new analytic account and save CODE with ABC Value it auto creates a new sequence with Code Value (ABC) Prefix (ABC0001). How to do it?

0
Аватар
Відмінити
Аватар
Mohammad Ahsan Maqbool
Найкраща відповідь

If you are looking for to create an auto sequence of Char field. You need to follow the following steps

  • Create a sequence in data directly in xml format as below:

    • id="sale_invoice_seq" model="ir.sequence">
      name="name">Sale Invoice Sequence
      name="code">account.move.invoice
      name="prefix">SI23-
      name="padding">6
      name="company_id" eval="False"/>

      id="seq_purchase_bill" model="ir.sequence">
      name="name">Purchase Bill Sequence
      name="code">account.move.bill
      name="prefix">BILL/
      name="padding">6
      name="company_id" eval="False"/>

    • In above you will see I am creating 2 sequences of in same model but with different move_type
  • Then you need to create a field in your respective model as follows and inheriting the create function to assign new sequence by next code as follows
    • custom_invoice_number = fields.Char('Custom Invoice Number')

      @api.model
      def create(self, vals):
      result = super(InheritInvoice, self).create(vals)

      if result['move_type'] == 'out_invoice':
      result['custom_invoice_number'] = self.env['ir.sequence'].next_by_code(
      'account.move.invoice')
      if result['move_type'] == 'in_invoice':
      result['custom_invoice_number'] = self.env['ir.sequence'].next_by_code(
      'account.move.bill')

      return result
    • In above code I have added a new field in account.move model by inheriting account.move model
    • Then you need to display your inherited field in your actual view where you want to show the generated sequence as follows
      • xml version="1.0" encoding="utf-8"?>

        id="view_invoice_company_logo_name" model="ir.ui.view">
        name="name">account.move.form
        name="model">account.move
        name="inherit_id" ref="account.view_move_form"/>
        name="arch" type="xml">
        expr="//form/sheet/div/span/field[@name='move_type']" position="after" >
        id="custom_invoice" string="Custom Invoice Seqence">


        name="custom_invoice_number" readonly="1"/>








        id="inherit_invoice_for_custom_field" model="ir.ui.view">
        name="name">account.move.inherit.custom.field

        name="model">account.move
        name="inherit_id" ref="account.view_account_invoice_filter" />
        name="arch" type="xml">
        name="name" position="after">
        name="custom_invoice_number"/>



      • In above code I have shown my custom field in account.move form and create a filter so that end user would be able to search record for that specific custom field.
      • I hope this will help you to understand the creation of sequence If the above code helps you just give me a like and let me know if you need clarification for any point

        Thanks
        Regards

        Muhammad Ahsan Maqbool

        1
        Аватар
        Відмінити
        Аватар
        Devintelle Consulting Services Pvt Ltd
        Найкраща відповідь

         HI , 

        You want to create auto sequence for new record so you can try below code

        •  Create Sequence.xml file.


          -  Add below code in your .py file of the object in which you want to create auto sequence.


        class AnalyticAccount(models.Model):

        _name=” analytic.account”


                        name = fields.Char(string=“Number”,default=“New”,readonly=True)

                        @api.model

              def create(self, vals):

            vals['name'] = self.env['ir.sequence'].sudo().next_by_code(‘analytic.account’) or 'New'

            res = super(AnalyticAccount,self).create(vals)

               return res


        • And access name field in view file like this ,

              


         I hope this is helpful to you.


         Thanks & Regards,

         Email: odoo@devintellecs.com

         Skype: devintelle



        0
        Аватар
        Відмінити
        Аватар
        Cybrosys Techno Solutions Pvt.Ltd
        Найкраща відповідь

        Hi,

        You can change the create function as follows,
        def create(self, vals):
            vals['name'] = self.code + self.env['ir.sequence'].next_by_code('my_sequence_code')
            return super(MyModel, self).create(vals)

        Add this data file, 

        <?xml version="1.0" encoding="utf-8"?>
        <odoo>
          <data noupdate="1">
            <record id="my_sequence_id" model="ir.sequence">
              <field name="name">My Sequence</field>
        <field name="code">my_sequence_code</field>
              <field name="prefix"></field>
              <field name="padding">5</field>
              <field name="number_next">1</field>
            </record>
          </data>
        </odoo>


        For more details, refer to the blog:

        https://www.cybrosys.com/blog/how-to-create-sequence-numbers-in-odoo-16

        Hope it helps

        0
        Аватар
        Відмінити
        Аватар
        Support GeminateCS
        Найкраща відповідь

        Hii Haris,
        If you want to create auto sequence in odoo it can be achieved by 'ir.sequence' model ,
        Take a look : https://geminatecs.com/blog/sales-editable-auto-sequence
        I Hope this information is helpful to you
        Feel Free for further assistance at contact@geminatecs.com
        Thank You,
        Geminate Consultancy Services,
        w : www.geminatecs.com

        0
        Аватар
        Відмінити
        Аватар
        Niyas Raphy (Walnut Software Solutions)
        Найкраща відповідь

        Hi,

        If you are looking for how to generate a sequential value for a field in Odoo, it can be done using the ir.sequence in Odoo.

        Either it can be done from the user interface using the developer mode or from the code side.

        The steps is as follows:

        1. Create a sequence in ir.sequence table

        2. Inherit the create method of corresponding model and assign sequential value from the created sequence.


        For reference:

        1. Generating Sequence from UI using sequence and automated action:  https://www.youtube.com/watch?v=Cz5eM5FDmTE

        2. Generating sequence from code: https://www.youtube.com/watch?v=69pCFI8uRIw&t=470s


        Thanks

        0
        Аватар
        Відмінити
        Haris Masqati
        Автор

        Thanks for your reply, I am looking for auto create a dynamic sequence for every new record like in the account.journal model.

        Niyas Raphy (Walnut Software Solutions)

        if you need similar to the journal sequence, set a many2one to ir.sequence from your master record and configure the sequence in it. then using the configured sequence you can get the next number

        Ramya

        I am autogenerating sequence similar to the journal sequence. I have a doubt, IN my scenario I want a new sequence record to be generated for every incident the user creates , so there is probability to have 100's and 1000's of sequence id's in ir.sequence table is that acceptable? Or Should I plan to have my autoincrement logic in my incident model itself?
        Which of the option is better. I just dont want the performance to be degraded when 100's of records get added to ir.sequence. or will making the ir.sequence active to false when incident is closed help ?

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

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

        Реєстрація
        Related Posts Відповіді Переглядів Дія
        How to change the Quotation, Order, Invoice sequence numbers ? Вирішено
        sequence sequencenumber
        Аватар
        Аватар
        Аватар
        2
        груд. 23
        29911
        Production Sequence error
        manufacturing sequence sequencenumber
        Аватар
        Аватар
        Аватар
        2
        жовт. 25
        458
        Sequence on invoices numbers not working anymore
        sequence prefix invoice_number
        Аватар
        Аватар
        1
        трав. 25
        3198
        Odoo Sequence Issue Across Multiple Companies
        sequence sequencenumber sequences
        Аватар
        0
        січ. 25
        2025
        Where is the configuration for the rental order number prefix?
        rental sequence prefix
        Аватар
        Аватар
        1
        вер. 24
        2039
        Спільнота
        • Навчальний посібник
        • Документація
        • Форум
        Open Source
        • Завантаження
        • Github
        • Runbot
        • Переклади
        Послуги
        • Хостинг Odoo.sh
        • Підтримка
        • Оновлення
        • Кастомні доробки
        • Навчання
        • Знайдіть бухгалтера
        • Знайдіть партнера
        • Стати партнером
        Про нас
        • Наша компанія
        • Торгові активи
        • Зв'яжіться з нами
        • Вакансії
        • Події
        • Подкаст
        • Блог
        • Клієнти
        • Юридичні документи • Конфіденційність
        • Безпека
        الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

        Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

        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