Hello,
Someone can explain me what exactly do this code?
What means the "and True or False" at the end?
def _compute_is_employee(self):
for rec in self:
rec.is_employee = rec.employee_id and True or False
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
Someone can explain me what exactly do this code?
What means the "and True or False" at the end?
def _compute_is_employee(self):
for rec in self:
rec.is_employee = rec.employee_id and True or False
Three cases. this expression returns True if employee_id has integer greater than 0 else False
employee_id = 105
is_employee = employee_id and True or False
print(is_employee) -> True
employee_id = 0
is_employee = employee_id and True or False
print(is_employee) -> False
employee_id = ''
is_employee = employee_id and True or False
print(is_employee) -> False
Hello Michele,
rec.is_employee = rec.employee_id and True or False
This python code will work like bellow
If rec has employee_id means is_employee boolean field will get checked(True) otherwise unchecked(False).
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 | |
---|---|---|---|---|
|
2
thg 4 24
|
1665 | ||
|
1
thg 1 22
|
3032 | ||
|
2
thg 8 19
|
13440 | ||
|
0
thg 4 19
|
2482 | ||
|
2
thg 2 19
|
3260 |