When I click the checkbox in activity "Tick if you are a vegetarian", a custom Boolean field I made named vegetarian in that employee's record should be active. How can I achieve this?
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ờ
4
Trả lời
6018
Lượt xem
Hi,
You can achieve this by using BeautifulSoup python library to check if the activity was ticked or not inside the html field of activity.
If it is ticked, the class will be changed to "o_checked".
We can then change the boolean field "Vegetarian" to true or false based on this.
Kindly refer the code,
from odoo import api, fields, models, _from bs4 import BeautifulSoupclass HrEmployee(models.Model):
_inherit = 'hr.employee'
vegetarian = fields.Boolean("Vegetarian", default=False, readonly=True)
class HrPlanActivityType(models.Model):
_inherit = 'mail.activity'
def action_close_dialog(self):
"""
function used to check if the employee can be
rehire by the checkbox
"""
res = super(HrPlanActivityType, self).action_close_dialog()
employee_id = self.env['hr.employee'].search([('id', '=', self._context['default_res_id'])])
for line in employee_id.activity_ids:
if line.note:
soup = BeautifulSoup(line.note, 'html.parser')
if soup.find(id="checklist-re_hide-id-4", class_="o_checked"):
employee_id.write({"vegetarian": True})
else:
employee_id.write({"vegetarian": False})
return resRegards
This works. Thanks
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 | |
---|---|---|---|---|
|
7
thg 11 20
|
25269 | ||
|
11
thg 1 19
|
10227 | ||
|
1
thg 6 24
|
1728 | ||
|
1
thg 12 22
|
4385 | ||
|
1
thg 11 22
|
4124 |
Follow these tips: https://learnopenerp.blogspot.com