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 Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • 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
Про цей форум
Допомога

Odoo 13 doesn't generate a sequence number

Підписатися

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

Це запитання позначене
2 Відповіді
12466 Переглядів
Аватар
Madara

hello i'm actually encountering a problem, I have followed the tutorial as shown in this link \https://www.youtube.com/watch?v=qyRhjyp1MeE and there is no error in code, but when i'm creating a new employee it doesn't generate a reference number. Reference number remains 'New' in tree view and form view for the created employee. Can anyone help me please?


hr.py :

    name_seq = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))

    @api.model

    def create(self, vals):

        if vals.get('name_seq', _('New')) == _('New'):

            vals['name_seq'] = self.env['ir.sequence'].next_by_code('hr.employee.sequence', sequence_date=seq_date) or _('New')

        result = super(HrEmployeePrivate, self).create(vals)

        return result

        

sequence.xml:


<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <data noupdate="1">


        <!-- Sequences for transfer.order -->

        <record id="seq_hr_employee" model="ir.sequence">

            <field name="name">Employee Sequence</field>

            <field name="code">hr.employee.sequence</field>

            <field name="prefix">EMP</field>

            <field name="padding">3</field>

            <field name="company_id" eval="False"/>

        </record>


    </data>

</odoo>


hr_views.xml :


                        <div class="oe_title">

                            <h1>

                                <field name="name_seq" readonly ="1"/>

                            </h1>

                            <h2>

                                <field name="name" placeholder="Employee's Name" required="True"/>

                            </h2>

                            <h3>

                                <field name="job_title" placeholder="Job Position" />

                            </h3>

                            <field name="category_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags"  groups="hr.group_hr_manager"/>

\\\Answer\\\
\CommentShare
0
Аватар
Відмінити
Аватар
MUHAMMAD Imran
Найкраща відповідь

In python file add a field in your model like the below code.


name = fields.Char(string="Service Number", readonly=True, required=True, copy=False, default='New')


Then add a function like in the following code.


@api.model
def create(self, vals):
   if vals.get('name', 'New') == 'New':
       vals['name'] = self.env['ir.sequence'].next_by_code(
           'self.service') or 'New'
   result = super(SelfService, self).create(vals)
   return result


After defining function,  you need to create a record for this. So create a record in the XML file .


<record id="sequence_self_service" model="ir.sequence">
   <field name="name">Self Service</field>
   <field name="code">self.service</field>
   <field name="active">TRUE</field>
   <field name="prefix">SS</field>
   <field name="padding">6</field>
   <field name="number_next">1</field>
   <field name="number_increment">1</field>
</record>


By doing this, a sequence number gets automatically generated, on creating a record in this model. 


> name- Name of the record created in the “ir.sequence” model

> code- Sequence code 

> active- A boolean field to indicate whether it is active or not

> prefix- A character field, where we can give the prefix of the sequence

> padding- sequence size

> number_next- next number that will be used

> number_increment- the next number of the sequence will be incremented by this.

 

In the below image -we can see a sequence number is generated for the record with prefix SS and number  000001(odoo will automatically add ‘0’s to the left side of the next number to get the required padding size-here we given padding size =6, so the first sequence number becomes 000001).


how-to-add-sequence-in-odoo12-cybrosys


We can configure the sequence number from the settings of odoo.


Go to Settings -> Technical -> Sequences & Identifiers -> Sequences


The below image shows the corresponding record of sequence number created using the above code.


how-to-add-sequence-in-odoo12-cybrosys


There are two types of the implementation method 

 1. No gap

 2. standard


No gap defines that there will be no gap in the numbering of records.


For example, if a self-service form is created, it will be numbered as SS000001. Then the second will be SS000002. If I deleted the second form and create a third one, then in case of 


> No gap- sequence  will be SS000002

> Standard- sequence will be SS000003


In the prefix and suffix field, you can add a prefix and suffix of the sequence. You can define the date range for sequence. For this, you have to check the “Use subsequences per date_range” field. 


For example, if you want to start sequence number from 1 at the start of every month, then define the date range in the from and to the field and next number as 1.


how-to-add-sequence-in-odoo12-cybrosys



2
Аватар
Відмінити
Don Githinji

Really great explanation Imran. I have been able to make this work but when I create a new record from a One2many tree view, the sequence number does not generate. Any idea how I could get it to work in such a case?

Аватар
Maximiliano Medina
Найкраща відповідь

Hello. Did you find a solution to the problem that it remains as "new"?

0
Аватар
Відмінити
Niyas Raphy (Walnut Software Solutions)

Please make sure that the sequence is created in the db with same sequence code that you are calling to get sequence number

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

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

Реєстрація
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
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