i want to know that why we use "False" in vals.get('field name', False) in create method before super the method and also i'm confused between two statements which i mentioned in title
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1) "get" is a method of a python dictionary to fetch the value from a key. If the key does not exist in the dictionary, you can pass a default value as a 2nd parameter:
myDict = {'name': 'Odoo', 'work': 'ERP'}
# I will fetch the value of the key that does not exist in the dict
1) myDict.get('address', '') # if no address, return value passed in 2nd parameter
2) myDict.get('company_ref', False)
2) You can also fetch the value by simply passing a key:
Ex: myDict['name']
if myDict['name'] == False
# This means, if name is blank or has False as a value
I hope, this will help you at some point to clear your doubt.
thank you the way u describe is very helpful
Always use vals.get().
When you access the value by vals.get() method and the key is not found, you won't get an error. You can pass a default value as a 2nd parameter like vals.get("Field", None).
When you access the value by vals["Field"] and the key is not found, you will get a Key Error.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
16
thg 10 22
|
17466 | ||
|
4
thg 5 24
|
12918 | ||
|
1
thg 4 24
|
3507 | ||
|
0
thg 11 23
|
2186 | ||
|
1
thg 9 23
|
2353 |