Hello everybody
I need to add python code for my field:
I want have a toggle boolean, true if today - "warranty date"
can you help me?
thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello everybody
I need to add python code for my field:
I want have a toggle boolean, true if today - "warranty date"
can you help me?
thanks
sorry, but my message was truncated.
I'd like a boolean_toggle field that is set to true if warranty date - current date is less than 2 years.
i have modified the answer please check to see if work or not
You can try something like this:
1. define your field:
from odoo.tools import relativedelta
toggle_field = fields.Boolean(string="Your Toggle field", compute="_compute_toggle_field", store=True)
2. Create a compute method for your field
@api.depends("warranty_date")
def _compute_toggle_field(self):
for r in self:
if r.warranty_date and (r.warranty_date - fields.Date.today()
r.toggle_field = True
else:
r.toggle_field = False
3. Finally bring your field to the xml file
Hope this help
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.