Odoo Help

0
4
Avatar

Janeesh

--Janeesh--

4345
| 5 3 6
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 9/24/17, 5:17 AM

If the dictionary vals has a key 'xxx', then it will return vals['xxx']. If the dictionary doesn't have a key 'xxx', then 'yyy' will be returned.

1
Avatar

Ray Carnes

--Ray Carnes--
20332
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 5/26/17, 9:28 PM

vals is just a standard Python dictionary.

dict.get(key, default=None)

used with key - it will return the value that matches

used with default - it will return the value that matches, or the default (None)


In the example you have posted, vals.get('sequence','New') will return the value of the key sequence, or New.  So: the code checks if there is a sequence key in vals, and if there isn't, creates one, and calls super after putting the newly created value into vals.


https://www.odoo.com/documentation/10.0/reference/orm.html

https://www.tutorialspoint.com/python/dictionary_get.htm

About This Community

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

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/26/17, 1:19 PM
Seen: 2900 times
Last updated: 9/24/17, 5:18 AM