Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Hide Button according to the current date

By
Gustavo
on 9/25/13, 2:13 PM 1,686 views

Hi, I'm trying to become invisible a button when the current date is not the same as the date of a field, I mean I need to show the button only when the current date will be the same as the date of a field.

I'm trying to use to do this in the xml the context_today () but I could not do it, my syntax for hidden button is:

attrs = "{'invisible': [('f_inicio', '!=', ((context_today ()). strftime ('%% Y-%% m-%% d')))]}"

The error message I get is "NameError: name 'context_today' is not defined".

I tried also with the following code:

attrs = "{'invisible': [('f_inicio', '!=', __import__ ('time'). strftime ('%% Y-%% m-%% d'))]}"

With the latter does not give me errors but does not do what is required, hide the button when the f_inicio not equal to the current date.

If I can lend a hand is the greatly appreciate,

Note: The "f_inicio" is of type "datetime" and the button I want to hide this placing in the section "header" of the view.

0

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 9/26/13, 5:46 AM

It seems that the tag attrs does not allow python code (at least it is not used in any of the addons). You can do it this way:

  • Create a hidden function field today of type date, which returns the current date
  • Then use the following code attrs = "{'invisible': [('f_inicio','!=','today')]}"

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 9/25/13, 2:13 PM
Seen: 1686 times
Last updated: 3/16/15, 8:10 AM