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
    Restauration & Hôtellerie
    • 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
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & 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
    Parcourir toutes les 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 pour partenaires
    • 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

how could i make an auto_increment system for each order form (One2many field)

S'inscrire

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

Cette question a été signalée
one2manyauto_incrementodoo10.0
3696 Vues
Avatar
mlk took

I have created an order form that contain a one2many list to identify the products featured in this order ,and i want to make a autoincrement field to reference the products inside the order form 
 for ex : an order may contain 3 products , the first will be number "1" ,the second   number"2" ... ,and i want it to be the same for every order
this is my .py file , but what i ve tried didn't work


#stapp

from openerp import models, fields

from odoo import api import xmlrpclib

server = "http://localhost:8069"

database = "test01"

usr = "malek"

pwd ="malek93/"

common = xmlrpclib.ServerProxy("{}/xmlrpc/2/common" .format(server))

uid = common.authenticate(database,usr,pwd, {})

odapi = xmlrpclib.ServerProxy("{}/xmlrpc/2/object" .format(server))

class bon_de_versement(models.Model):

     _name = 'bondeversement'

     imgg = fields.Binary(string="image" , filters=None)

     name = fields.Char("Nom Complet")

     prix = fields.Float(string="Prix",readonly=True, store=True, compute="_calcprix")

     date = fields.Date("Date de debut")

     note = fields.Text("Note")

    nutrient_ids = fields.One2many('versement', 'product_id' , 'Nutrient')

     article_ids = fields.One2many('bondeversement.article', 'product_id' , 'Article')

     reste = fields.Float(string="Le reste", readonly=True ,store=True , compute="_reste")

     @api.one

     @api.depends('article_ids', 'article_ids.prix_article')

     ids = odapi.execute_kw(db, uid, password,'bondeversement.article', 'search',

    [[['product_id', '=', 'article_ids.product_id']]])

     [record] = odapi.execute_kw(database, uid, pwd,'bondeversement.article', 'read', [ids])

     nb = 1

     for it in [record]:

          ajout = odapi.execute_kw(database, uid, pwd, 'bondeversement.article', 'write',[[it], [{'article_nb': nb}])

          nb+= 1

     def _calcprix(self):

          total = 0

          for unit in self.article_ids:

               total += unit.prix_article

          self.prix = total

     @api.one

     @api.depends('nutrient_ids', 'nutrient_ids.montant')

     def _reste(self):

          restee = self.prix

      for mealitem in self.nutrient_ids:

           restee -= mealitem.montant

      self.reste = restee

class versements(models.Model):

     _name = 'versement'

     product_id = fields.Integer("PID")

     montant = fields.Float("Versement")

     date = fields.Datetime("Date de versement")

class bondeversement_article(models.Model):

     _name = 'bondeversement.article'

     product_id = fields.Integer("PID")

     article_nb = fields.Integer("Nb")

     namee = fields.Selection(selection =[('bague','Bague'),('boucle','Boucle'),('bracelet','Bracelet'),('ceinture','Ceinture'),('chaine','Chaine'),('ensemble','Ensemble'),('gourmette','Gourmette'),('msayess','Msayess'),('parrure','Parrure'),('pendentif','Pendentif'),('wiz','El-Wiz'),('article_bebe','Article bebe'),('autre','Autre')], string='Article')

     poids_article = fields.Float("Poids")

     prix_article = fields.Float("Prix") 

0
Avatar
Ignorer
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é
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
janv. 25
2944
count number of records based on condition Résolu
odoo10.0
Avatar
Avatar
1
nov. 24
21251
How to install odoo 10 in ubuntu 20.04? Résolu
odoo10.0
Avatar
Avatar
1
sept. 23
4045
Question about action_confirm
odoo10.0
Avatar
Avatar
Avatar
3
mai 23
6612
How to see the and activate the developer mode in odoo version 10 Résolu
odoo10.0
Avatar
Avatar
Avatar
Avatar
Avatar
7
avr. 23
50130
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