Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
5174 Переглядів

Hello !


Not so long ago i've started developping on Odoo Community v14.


I've created a module where projects needs to have unique ID.


Thus, i've added a unique custom sequence number that increments itself each time a project is created by users.


One thing i've noticed is that, each time i upgrade the module, this sequence number is resetted. Problem is the next time a project is created, the user won't be able to save it because the sequence number already exists. I have to manually go to Technical > Sequence and update it to the last number used.


I would have expected it to automatically carry on with the serie.

Is there a way to somehow retrieve the last number used and update it in the sequence number entry ?


What would be the best way to implement this ?

Through database request to grab the last record and add +1 ?


Thanks a lot in advance !



Аватар
Відмінити


Bonjour,

Merci pour votre e-mail.
Actuellement absent, je prendrais connaissance de votre message à mon retour le 21 Août.
En cas d'urgence, vous pouvez joindre le standard de CVS au 0141140450.
 
Julien DENARD
CVS ENGINEERING
+33678958485
 
 
 
Hello,
Thank you for your e-mail.
I am out of office until the 21st of August
In an emergency, you can contact CVS at +33141140450.
 
Julien DENARD
CVS ENGINEERING
+33678958485
 

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

Alright...


Seems i've found my issue :


    <record id="seq_code_affaire" model="ir.sequence">
        <field name="name">Sequence Code Affaire</field>
        <field name="code">cvs.affaire</field>
        <field name="active">TRUE</field>
        <field name="prefix">1</field>
        <field name="suffix"></field>
        <field name="padding">3</field>
        <field name="number_next">1</field>
        <field name="number_increment">1</field>
    </record>


I've deleted "number_next" / "number_increment" and now it seems to work properly !

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

Hi, 

Just for the future guys who will search for an answer on this. The above solution is not working and I have found an answer on the discord channel from "Younis".  

In the xml file where you define the sequence, add

Check the default odoo modules sequence xml files for examples


Here is the example on sales.order sequence 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<!-- Sequences for sale.order -->
<record id="seq_sale_order" model="ir.sequence">
<field name="name">Sales Order</field>
<field name="code">sale.order</field>
<field name="prefix">S</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
</record>

</data>
</odoo>





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

The noupdate="1" has changed in odoo 18. This is how sale order sequence is done from odoo 18 GitHub

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

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

noupdate="1" is put inside the odoo tag, not data anymore

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

Hi 
Same case happened with me 
just Remove the number_next from your XML sequence definition. and it works fine
Or add  <data noupdate="1">

Аватар
Відмінити