Skip to Content
Odoo Menu
  • Sign in
  • 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
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Odoo v13 @api decoration Error

Subscribe

Get notified when there's activity on this post

This question has been flagged
buttonserrrordecoratorsodooV13@api.multi
6 Replies
7541 Views
Avatar
Kirill

Is anyone stumble over situation when in module you start put any @api decorator and it crashes odoo?

I have module with states. I'm trying to signed button function to change state. But when i writing any @api decorator
and restart server, reload web page, it pushes me to form of choosing database or shows continious messages about connection lost and retrieve.

When i comment @api it works fine up to moment of button click.

Here is my simple model:

from odoo import models, fields, api

class la_shipping(models.Model):
_name = 'tralalal'
_description = 'Tralala'
@api.multi
def button_done(self):
for rec in self:
rec.write({'state', 'done'})
state = fields.Selection([('sent', 'Sent'),('done','Done')],
required =True, default='sent')
<header>
    <button name="button_done" string="Done" states="sent" class="oe_highlight" type="object"></button>
    <button name="button_sent" string="Sent" states="sent,done" class="oe_highlight" type="object"></button>
    <field name="state" widget="statusbar"></field>
</header>
0
Avatar
Discard
Niyas Raphy (Walnut Software Solutions)

https://www.youtube.com/watch?v=YfJK6thy2s0

Midhun

Hi Kirill,

We no need to use any @api decorators for handling multiple records it's by default handling in Odoo 13.

Avatar
Paresh Wagh
Best Answer

Hi Kirill: 

@api.multi has been deprecated in odoo13. 

Are you facing these issues with any of the other @api values ?

EDIT:

In your case, use ​@api.model  if the action will be performed on a record. If the action is not on a specific record, you don't need a decorator.

If you still encounter issues, another way of doing this would be to configure a Server Action using the UI (​Settings > Technical > Server Actions) and link it to the button using the server action id in the XML.

You may find the following video helpful. Even though it's based on v12, the concepts are applicable to v13.

Odoo V12 - Creating Buttons & Server Actions

2
Avatar
Discard
Avatar
Kirill
Author Best Answer

Hi Paresh:

Yes, doesn't matter which @api I use as far as " @api " written in model odoo stop working. By the way is it any other ways to assign function to button?

0
Avatar
Discard
Midhun

You face issues in handling onchange @api?

Paresh Wagh

Hi Kirill: I've edited my original response based on your clarification.

Avatar
Reema Rajput
Best Answer

Hello!!!

From 0doo-13 @api.multi is deprecated. For making any function to button you don't need to use any @api, but if you want to pass any args or values in that funtion than you have to use @api.model for that..


0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
How i can remove edit function on my page?I need do this from python. Solved
python buttons edit odoo odooV13
Avatar
Avatar
Avatar
4
Mar 21
5059
Odoov13 UI suddenly stop working
odooV13
Avatar
Avatar
1
Nov 24
2167
i have a new develop enviorment in odoo 13 but when i try to fet in give me this error please Help
odooV13
Avatar
Avatar
1
Apr 23
3491
Custom stat button (eo_stat_button) for a custom field on a partner
buttons
Avatar
Avatar
Avatar
2
Mar 23
11326
Cacher le bouton "créer" d'une liste Solved
buttons
Avatar
Avatar
2
Mar 23
3357
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