Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

create sequence with button to increment it

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
sequencebutton
4 Respuestas
2751 Vistas
Avatar
Oliver

Hello all,

i am new in Odoo and i try my first steps to create a sequece and a button to increment it on button click.

I created my own module and added my files.

Here my files:

debit_card.py

from odoo import models, fields, api, _

class DebitCard(models.Model):
_name="debit.card"
_description="Debit Card"

debit_seq = fields.Char(
string="Debit Card Datev Sequence",
required=True,
copy=False,
readonly=True,
index=True,
default=lambda self: _("New"))

@api.model
def create(self, vals):
if vals.get('debit_seq', _('New')) == _('New'):
vals['debit_seq'] = self.env['ir.sequence'].next_by_code('debit.card.sequence.code') or _('New')
result = super(DebitCard, self).create(vals)
return result

debit_card_view.xml (can´t post correct code. don´t know why...)


        (record id="debit_card_form_view" model="ir.ui.view")
            (field name="name")debit.card.form.view(/field)
            (field name="model")debit.card(/field)
            (field name="arch")type="xml"(/field)
             (form string="Debit Card")
                    (div)Hello World! (/div)
                    (field name="debit_seq" style="font-size:22px;font-weight:bold;"/)
             (/form)
          (/field)
        (/record)
       
   

sequence.xml

(odoo)
(data noupdate="1")
(!-- Sequence for debit.card //--)
(record id="debit_card_datev_sequence" model="ir.sequence")
(field name="name")Debit Card Datev Sequence(/field)
(field name="code")debit.card.sequence.code(/field)
(field name="padding")7(/field)
(field name="number_next")62071(/field)
(field name="number_increment")1(/field)
(field name="company_id" eval="False"/)
(/record)
(/data)
(/odoo)


Now, if i call the debit card it shows me: "Hello World!"

But no sequence but "New"


I found many "examples" on web search but nothing helps me.


Where is the issue for not showing the sequence?

And how to implement a button to increment the sequence on click?

1
Avatar
Descartar
Avatar
Mohamed Rizwan
Mejor respuesta

Hi,

you can create a button like

def seq_increment(self):
​for rec in self:
​ ​rec.debit_seq = self.env['ir.sequence'].next_by_code('debit.card.sequence.code')

and xml would like

(record id="debit_card_form_view" model="ir.ui.view")
            (field name="name")debit.card.form.view(/field)
            (field name="model")debit.card(/field)
            (field name="arch")type="xml"(/field)
             (form string="Debit Card")
                    (header)
​ ​ ​ ​ ​(button name="seq_increment" type="object" string="Increment" class="oe_highlight" id="button_seq_increment"/)
​ ​ ​ ​(/header)
             (/form)
          (/field)
        (/record)


thanks

2
Avatar
Descartar
Oliver
Autor

Thank you very much. It works fine but it doesn`t use the next_number. I changed the field name next_number to next_number_actual because in Settings-Technical-Sequences the field name for the next number is: next_number_actual.
And if i call the "page" debit card first, it always shows "New". Is this because in the field declaration is the default value lambda self: _("New")? If yes, how may i show the current value of the sequence?

Avatar
Niyas Raphy (Walnut Software Solutions)
Mejor respuesta

Hi,
If you already have a sequence record and if you need to increment the sequence value on a button click, inside the button function, you can add below line of code to get next number from the sequence.

Code: self.env['ir.sequence'].next_by_code('code_Value_of_Sequence')


Thanks

0
Avatar
Descartar
Avatar
Oliver
Autor Mejor respuesta

The titel changed the value after clicking on the "increment button" and i don`t know why.

Can anyone explain me this behavior?

befor click:

after clicked.


0
Avatar
Descartar
Mohamed Rizwan

by default, odoo is taking field 'name' as the record name, if your model doesnt have a field called 'name' it will shows as model_name,record_id, in your case it is debit.card,11.

if you need to show any other field as the record name, kindly provide that field in _rec_name after declaring the model name.

ie;
_name = 'debit.card'
_description = 'Debit Card Details'
_rec_name = 'seq_increment'

this will solve your issue.

thanks

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,


You should declare your sequence field in XML view to display it.

Like this, <field name="name"/>



Hope it helps

0
Avatar
Descartar
Oliver
Autor

The sequence field is declared in the xml view but it displayed always "New".
I need help for adding a button to increment the sequence and update the field output.

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Sequence Prefix
sequence
Avatar
0
feb 23
6462
Opening new window with button in OpenERP Resuelto
button
Avatar
Avatar
1
ene 24
15322
How to customize the invoice,bill and journal name sequence
sequence
Avatar
0
ene 23
95
What is the best (correct) way to create sequence ? py or xml? Resuelto
sequence
Avatar
Avatar
1
oct 22
5218
Deleted a sequence
sequence
Avatar
0
abr 22
3616
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones empresariales de código abierto que cubre todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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