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
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

Calling Activity_feedback in an @api.onchange() causes error.

S'inscrire

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

Cette question a été signalée
onchangeproject.taskscheduleactivty
1 Répondre
3623 Vues
Avatar
Evan

I want to mark scheduled activities a project task as over if it has been moved to a different stage(stage_id).

Scheduled Activity Creation

def_timesheet_create_task(self, project):
#send notification when task is created
    task = super()._timesheet_create_task(project)
    fornotified_userintask.stage_id.task_create_notified_groups.users:
        task.activity_schedule('mail.mail_activity_data_todo', user_id=notified_user.id)

Scheduled Activity Removal

@api.onchange("stage_id")
def_onchange_stage_id(self):
    self.activity_feedback(['mail.mail_activity_data_todo']) # Completes the acitivity but Throws error. 
It seems like the error is being triggered because the front-end is trying to read mail.message but fails because the mail.activity is gone due to onchange being run before it.

Console output

2022-08-03 02:13:20,600 47312 INFO odoo-dev4 werkzeug: 127.0.0.1 - - [03/Aug/2022 02:13:20] "POST /web/dataset/call_kw/project.task/onchange HTTP/1.1" 200 - 120 0.101 0.108

2022-08-03 02:13:20,608 47312 INFO odoo-dev4 werkzeug: 127.0.0.1 - - [03/Aug/2022 02:13:20] "POST /longpolling/poll HTTP/1.1" 200 - 11 0.016 7.770

2022-08-03 02:13:20,609 47312 INFO odoo-dev4 werkzeug: 127.0.0.1 - - [03/Aug/2022 02:13:20] "POST /longpolling/poll HTTP/1.1" 200 - 12 0.013 7.788

2022-08-03 02:13:20,610 47312 INFO odoo-dev4 werkzeug: 127.0.0.1 - - [03/Aug/2022 02:13:20] "POST /longpolling/poll HTTP/1.1" 200 - 11 0.015 7.777

2022-08-03 02:13:20,625 47312 INFO odoo-dev4 werkzeug: 127.0.0.1 - - [03/Aug/2022 02:13:20] "POST /web/dataset/call_kw/mail.message/read HTTP/1.1" 200 - 5 0.010 0.006

2022-08-03 02:13:20,655 47312 WARNING odoo-dev4 odoo.http: Record does not exist or has been deleted.

(Record: mail.activity(73,), User: 2) 

0
Avatar
Ignorer
Avatar
Evan
Auteur Meilleure réponse

I managed to figure out the issue as well as find a solution. (sort of, i found a way to bypass the root cause)

Problem

If we unlink the activities in the onchange function, the subsequent call which is made to update the record using write(vals) will fail because for some reason vals will include the now-deleted activity.

Solution

Specific to my use case I was able to move the unlink from the onchange method to the write(self,val) method which I overrode.

defwrite(self, vals):
""" override write function so as to remove and re-attach new scheduled activities """
self.activity_feedback(['mail.mail_activity_data_todo']) #remove automated activities attached to task
super().write(vals)
#Add sheduled activities on the new user group
fornotified_userinself.stage_id.task_create_notified_groups.users:
self.activity_schedule('mail.mail_activity_data_todo', user_id=notified_user.id)

Each time the task is editted(using write). It unlinks the activity via activity_feedback() and creates a new one with the new user group computed from the task.

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é
AttributeError: 'NoneType' object has no attribute 'values' (Odoo 13)
onchange attributeerror project.task
Avatar
Avatar
Avatar
2
déc. 24
69873
How to restrict that only creators and assignees with permissions can see their own tasks in project?
project.task
Avatar
Avatar
Avatar
2
mai 25
3494
Make is_closed field for a task editable
project.task
Avatar
Avatar
Avatar
2
juil. 24
2532
trying to auto correct a wrong users value
onchange
Avatar
Avatar
1
oct. 23
2751
"Wrong value for %s: %r" % (self, value) Résolu
onchange
Avatar
Avatar
2
oct. 23
2970
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