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

Compute field to store in DB

S'inscrire

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

Cette question a été signalée
computed-fieldsv15
1 Répondre
4038 Vues
Avatar
Ibrahim Boudmir

hi, 

Anyone knows how to stop odoo from computing stored field after running the server?


In my case, when adding store=True to sale_order_count field, the system goes down after several minutes because it hits the timeout limit (Odoo.sh) ( trying to compute and store value for ~800K records).


AFAIK, when you stop the server and then restart it, Odoo should not launch the computation of the field again. but in my case, it does it after every restart...leading to timeout each time.


--UPDATE-- 


I don't want to add search attribute. I just remember that Odoo support told me to call a method that prevents triggering compute field after restarting the system but they did not tell me its name.. So i assume someone in the community would know about it.


Thanks.

0
Avatar
Ignorer
Avatar
shubham shiroya
Meilleure réponse

when you have a stored computed field with store=True, the system will attempt to compute and store the value of the field for all existing records when you first start the server after adding or modifying the field. This behavior can be problematic if you have a large number of records, as it can lead to timeouts or performance issues.

from odoo import models, fields, api

class MyModel(models.Model):
_name = 'my.model'

# Dependent fields
field1 = fields.Char()
field2 = fields.Integer()

# Computed field
computed_field = fields.Integer(compute='_compute_field', store=True, depends=['field1', 'field2'])

@api.depends('field1', 'field2')
def _compute_field(self):
for record in self:
# Compute the value for the field
record.computed_field = record.field1 + record.field2


In the example above, the computed_field depends on field1 and field2. When you start the server, Odoo will check if the values of fields 1 and field2 have changed since the last computation. If they haven't, it will skip the computation of the computed_field. This can help prevent the timeouts you're experiencing.

0
Avatar
Ignorer
Ibrahim Boudmir
Auteur

thanks for your reply,

I don't agree with you regarding skipping compute if fields 1 and field2 didn't change after Server restart.

Adding depends does not skip the computation after server restart. knowing that depends fields are not changed since the last computation as you mentioned.

The compute function is a bit tricky in my case, you can check "_compute_sale_order_count" in Partners and tell me what depends you want to add ?

Thanks.

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é
computed field doesnt work with a domain
fleet computed-fields v15
Avatar
0
avr. 24
2340
odoo 15 compute days differance Résolu
attributeerror computed-fields v15
Avatar
Avatar
Avatar
2
sept. 22
3401
Prevent navigation if records are not save
v15
Avatar
Avatar
Avatar
2
oct. 25
3307
Creating user creates duplicated partner_id
v15
Avatar
Avatar
1
sept. 25
3215
ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR
computed-fields
Avatar
Avatar
1
juin 25
17088
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