Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

[8.0] API - When Inheriting a Model Written in old API, Do I Need to Use the Old API?

api
By
John
on 12/17/14, 6:07 AM 439 views

I would like to inherit purchase.order to add a custom action method for a workflow.  Do I need to code everything in the old API like

self.write(cr, uid, ids, {'state': 'approved'})

or can I code things like

self.state='approved'

?  Is there a standard way to do this?

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 12/17/14, 6:35 AM

In new API you should use

self.write({'state': 'approved'})

or

self.state='approved'

If you write many values better way (only one trigger a write action) is:

self.write({’x’:1,’y’:2,’z’:4})

See:
https://media.readthedocs.org/pdf/odoo-new-api-guide-line/latest/odoo-new-api-guide-line.pdf
https://github.com/nbessi/odoo_new_api_guideline
https://www.odoo.com/documentation/8.0/reference/orm.html

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/17/14, 6:07 AM
Seen: 439 times
Last updated: 3/16/15, 8:10 AM