콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
1623 화면

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

아바타
취소
베스트 답변

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