i need to invisible page after a specific date . so need to compare that date with create date.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
To make a page invisible after a specific date in Odoo 16, you can create a custom module and use the date_deadline field in the model to set the expiration date. You can then compare the date_deadline with the create_date of the record to check if the page should be visible or not.
In your model add fields,
date_deadline = fields.Date('Expiration Date')
is_visible = fields.Boolean('Is Visible', compute='_compute_is_visible')
@api.depends('create_date', 'date_deadline')
def _compute_is_visible(self):
for page in self:
if not page.date_deadline:
page.is_visible = True
else:
page.is_visible = fields.Date.today() <= page.date_deadline
Now you can add this field is_invisible in attrs for your page
//your fields inside page
Hope this will help you
Thanks
Thanks for your answer.
we don't want to do configure a date in each and every records we just want to invisible page for the records which are created after 25th of march 2023.
You can try like this:
<page string="Page 1" attrs="{'invisible': [('create_date', '>', '2023-03-25 23:59:59')]}" >
//your code
</page>
This solution worked .
Thank you
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden