Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

create sequence with button to increment it

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
sequencebutton
4 Réponses
2730 Vues
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
Ignorer
Avatar
Mohamed Rizwan
Meilleure réponse

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
Ignorer
Oliver
Auteur

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)
Meilleure réponse

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
Ignorer
Avatar
Oliver
Auteur Meilleure réponse

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
Ignorer
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
Meilleure réponse

Hi,


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

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



Hope it helps

0
Avatar
Ignorer
Oliver
Auteur

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.

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Sequence Prefix
sequence
Avatar
0
févr. 23
6446
Opening new window with button in OpenERP Résolu
button
Avatar
Avatar
1
janv. 24
15313
How to customize the invoice,bill and journal name sequence
sequence
Avatar
0
janv. 23
95
What is the best (correct) way to create sequence ? py or xml? Résolu
sequence
Avatar
Avatar
1
oct. 22
5207
Deleted a sequence
sequence
Avatar
0
avr. 22
3612
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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