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
    • Intelligence artificielle
    • 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
    • Supermarché
    • 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
    • Homme à tout faire
    • 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
    • Devenir 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
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

iterate and write new values in a model

S'inscrire

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

Cette question a été signalée
pythonmodulemodelscustom
6244 Vues
Avatar
Dominic Anyanna

i have the following models,production  data is uploaded to dlc.pdata via excel without workstations with zero production so i created a function to identify missing workstations and write a value of 0 but it does not write only those not present but all .


class ProductionData(models.Model):
_name = 'dlc.pdata'
_rec_name = 'start_date'
_description = 'New Description'

name = fields.Char()
start_date = fields.Date(string="From", required=False, )
end_date = fields.Date(string="To", required=False,)
production_details_ids = fields.One2many(comodel_name="dlc.pdetails", inverse_name="production_data_id", string="Production Details", required=False, )



@api.multi
@api.model_create_multi
def process_data(self, values):
workstation = self.env['dlc.workstation']
dlc = set(workstation.search([]))
pdlc = self.env['dlc.pdetails']
domain = [('production_data_id', '=', self.id)]
pdlct = pdlc.search(domain)
workeddlc = set(a.workstation_id.ids[0] for a in pdlct if a.workstation_id.id)
for x in dlc + workeddlc:
if x not in workeddlc:
nowork2 = x.ids
for line in nowork2:
values = {
'workstation_id': line,
'production_data_id': self.id,
'card_type': 'Office Total',
'cdl': 0,
'gdl': 0,
'msl': 0,
'pdl': 0,
'sdl': 0,
'ddl': 0,
'total': 0,
}

self.env['dlc.pdetails'].create(values)


class ProductionDetails(models.Model):
_name = 'dlc.pdetails'
_rec_name = 'workstation_id'

workstation_id = fields.Many2one(comodel_name="dlc.workstation", string="DLC", required=False, )
production_data_id = fields.Many2one(comodel_name="dlc.pdata", string="Production", required=False, )
card_type = fields.Selection(string="Card Type",
selection=[('Temporary', 'Temporary'), ('Office Total', 'Office Total'),
('Permanent', 'Permanent')], required=False, )
cdl = fields.Integer(string="CDL", required=False, )
gdl = fields.Integer(string="GDL", required=False, )
msl = fields.Integer(string="MSL", required=False, )
pdl = fields.Integer(string="PDL", required=False, )
sdl = fields.Integer(string="SDL", required=False, )
ddl = fields.Integer(string="DDL", required=False, )
total = fields.Integer(string="TOTAL", required=False, )

class WorkStation(models.Model):
_name = 'dlc.workstation'
_description = 'list of work station'

name = fields.Char()
dlc_operator = fields.Many2many("dlc.personnel",string="DLC Personnel")
lga = fields.Many2one('dlc.lga')
state = fields.Many2one('dlc.states')
dlc_supervisor = fields.Many2one('dlc.personnel')
issues_ids = fields.One2many(comodel_name="dlc.issues", inverse_name="dlc_id", string="Issues", required=False, )
status = fields.Selection(string="DLC Status", selection=[('active', 'Active'), ('inactive', 'Inactive'), ], required=False, default= 'active' )
total_dlc = fields.Integer(string="Total DLCs", required=False, compute='_total_dlc')
inactive_dlc = fields.Integer(string="Inactive DLCs", required=False, compute='_inactive_dlc')
dlc_cug = fields.Char(string="DLC CUG Number")


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é
Can't import a model in odoo view Résolu
python module models odoo10.0
Avatar
Avatar
Avatar
Avatar
Avatar
7
juil. 19
44738
Hello, how could I create a button that creates a new record in another model containing data from my current model? from my python module
python module models button records
Avatar
Avatar
Avatar
2
janv. 25
3150
Field doesn't exist in module when i upgrade the module
views module models custom estate
Avatar
Avatar
1
mai 24
2483
Custom Module Not Populating in Apps List Résolu
module custom
Avatar
Avatar
4
oct. 20
11568
How to use a model source code in different folder than module root? (i.e. inside directory "models") Résolu
python module models init odooV8
Avatar
Avatar
Avatar
3
mai 19
12456
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
  • Devenir 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 Svenska ภาษาไทย 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