Skip to Content
मेन्यू
This question has been flagged
1 Reply
1614 Views

i need to invisible page after a specific date . so need to compare that date with create date.

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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>

Author

This solution worked .
Thank you