Skip to Content
Menu
This question has been flagged
3 Replies
4930 Views

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 !



Avatar
Discard
Author Best Answer

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 !

Avatar
Discard
Best Answer

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">

Avatar
Discard
Best Answer

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>





Avatar
Discard