Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
onchangeproject.taskscheduleactivty
1 Odgovori
3607 Prikazi
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
Opusti
Avatar
Evan
Avtor Best Answer

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
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
AttributeError: 'NoneType' object has no attribute 'values' (Odoo 13)
onchange attributeerror project.task
Avatar
Avatar
Avatar
2
dec. 24
69852
How to restrict that only creators and assignees with permissions can see their own tasks in project?
project.task
Avatar
Avatar
Avatar
2
maj 25
3481
Make is_closed field for a task editable
project.task
Avatar
Avatar
Avatar
2
jul. 24
2521
trying to auto correct a wrong users value
onchange
Avatar
Avatar
1
okt. 23
2731
"Wrong value for %s: %r" % (self, value) Solved
onchange
Avatar
Avatar
2
okt. 23
2958
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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