Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Where are the sequences?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
v7sequence
2 Respostes
13194 Vistes
Avatar
Francesco OpenCode

I created a sequence for a class. This is the xml structure that create it:

    <record id="seq_type_report_review" model="ir.sequence.type">
        <field name="name">Report Review</field>
        <field name="code">management.reports_review</field>
    </record>

    <record id="seq_report_review" model="ir.sequence">
        <field name="name">Report Review</field>
        <field name="code">management.reports_review</field>
        <field name="prefix">%(year)s\</field>
        <field name="padding">3</field>
        <field name="company_id" eval="False"/>
    </record>

And this is the system I use to call the sequence in the class:

def create(self, cr, uid, vals, context=None):
    vals['review_number'] = self.pool.get('ir.sequence').get(cr, uid, 'management.reports_review') or ''
    return super(management_reports_review, self).create(cr, uid, vals, context)

If I create a new voice, the sequence increse by 1. It's ok for me but if I go in the Configuration section the next number voice is always on 1! Why? I would change it but if I change it the sequence go on with is old number.

1
Avatar
Descartar
Avatar
Brett Lehrer
Best Answer

Depends if you're using standard or no-gap sequence implementation. Check out this function in openerp/addons/base/ir/ir_sequence.py:

def _get_number_next_actual(self, cr, user, ids, field_name, arg, context=None):
    '''Return number from ir_sequence row when no_gap implementation,
    and number from postgres sequence when standard implementation.'''
    res = dict.fromkeys(ids)
    for element in self.browse(cr, user, ids, context=context):
        if  element.implementation != 'standard':
            res[element.id] = element.number_next
        else:
            # get number from postgres sequence. Cannot use
            # currval, because that might give an error when
            # not having used nextval before.
            statement = (
                "SELECT last_value, increment_by, is_called"
                " FROM ir_sequence_%03d"
                % element.id)
            cr.execute(statement)
            (last_value, increment_by, is_called) = cr.fetchone()
            if is_called:
                res[element.id] = last_value + increment_by
            else:
                res[element.id] = last_value
    return res

Using no-gap implementation, the current sequence should be listed directly in the table in ir_sequence. Otherwise, using something like pgAdmin, you can just look directly at the sequence value under "Sequences" -> "ir_sequence_<sequence id="">". Or, referring to that function, a SQL query like:

select last_value from ir_sequence_041;

Why you aren't seeing the updated number on the configuration page is odd. Something else must be going wrong there, but I don't know what. Using updated server source code?

1
Avatar
Descartar
Avatar
Rachid
Best Answer
   odoo 8: 
modify the file odoo/openerp/addons/base/ir/ir_sequence.py as bellow
 

`
def _predict_nextval(self, cr, seq_id):
"""Predict next value for PostgreSQL sequence without consuming it"""
# Cannot use currval() as it requires prior call to nextval()
query = """SELECT last_value,
(SELECT increment_by
FROM pg_sequences
WHERE sequencename = 'ir_sequence_%(seq_id)s'),
is_called
FROM ir_sequence_%(seq_id)s"""
if cr._cnx.server_version < 100000:
query = "SELECT last_value, increment_by, is_called FROM ir_sequence_%(seq_id)s"
cr.execute(query % {'seq_id': seq_id})
(last_value, increment_by, is_called) = cr.fetchone()
if is_called:
return last_value + increment_by
# sequence has just been RESTARTed to return last_value next time
return last_value


class ir_sequence(openerp.osv.osv.osv):

def _get_number_next_actual(self, cr, user, ids, field_name, arg, context=None):
'''Return number from ir_sequence row when no_gap implementation,
and number from postgres sequence when standard implementation.'''
res = dict.fromkeys(ids)
for element in self.browse(cr, user, ids, context=context):
if element.implementation != 'standard':
res[element.id] = element.number_next
else:
# get number from postgres sequence. Cannot use
# currval, because that might give an error when
# not having used nextval

seq_id = "%03d" % element.id
res[element.id] = _predict_nextval(self, cr, seq_id)
return res
`
0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
Problem initializing a field with a sequence
v7 sequence
Avatar
0
de març 15
6032
How to initialize the invoice sequence number every month ?
v7 sequence account.invoice
Avatar
Avatar
Avatar
Avatar
3
de des. 23
8180
Different sequence number of Quotations and sales order? Solved
sales v7 sequence
Avatar
1
de març 15
8257
Auto-increment Ref# in Journal Voucher
development v7 sequence
Avatar
0
de març 15
4916
Different sequence number of RFQ and Purchase Order? Solved
purchase v7 sequence
Avatar
1
de març 15
7186
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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