parent
3c123069af
commit
a7aec6b257
15
babi.py
15
babi.py
|
@ -417,7 +417,14 @@ class Filter(DeactivableMixin, ModelSQL, ModelView):
|
|||
expression_error = fields.Char('Expression Error', readonly=True, states={
|
||||
'invisible': ~Bool(Eval('expression_error')),
|
||||
})
|
||||
context = fields.Char('Context')
|
||||
context = fields.Char('Context',
|
||||
help="A dict to eval context:\n"
|
||||
"- date: eval string to date. Format: %Y-%m-%d.\n"
|
||||
" Example: {'stock_date_end': date('2023-12-01')}\n"
|
||||
"- datetime: eval string to date time. Format %Y-%m-%d %H:%M:%S.\n"
|
||||
" Example: {'name': datetime('2023-12-01 10:00:00')}\n"
|
||||
"- today: eval current date\n"
|
||||
" Example: {'stock_date_end': today}")
|
||||
parameters = fields.One2Many('babi.filter.parameter', 'filter',
|
||||
'Parameters',
|
||||
states={
|
||||
|
@ -1504,11 +1511,15 @@ class ReportExecution(ModelSQL, ModelView):
|
|||
})
|
||||
|
||||
def get_context(self):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
|
||||
if self.report.filter and self.report.filter.context:
|
||||
context = self.replace_parameters(self.report.filter.context)
|
||||
ev = EvalWithCompoundTypes(names={}, functions={
|
||||
'date': lambda x: datetime.strptime(x, '%Y-%m-%d').date(),
|
||||
'datetime': lambda x: datetime.strptime(x, '%Y-%m-%d'),
|
||||
'datetime': lambda x: datetime.strptime(x, '%Y-%m-%d %H:%M:%S'),
|
||||
'today': Date.today(),
|
||||
})
|
||||
context = ev.eval(context)
|
||||
return context
|
||||
|
|
18
locale/ca.po
18
locale/ca.po
|
@ -881,6 +881,24 @@ msgstr ""
|
|||
"- \"ym()\": Retorna l'any-mes (com a text)\n"
|
||||
"- \"ymd()\": Retorna l'any-mes-dia (com a text).\n"
|
||||
|
||||
msgctxt "help:babi.filter,context:"
|
||||
msgid ""
|
||||
"A dict to eval context:\n"
|
||||
"- date: eval string to date. Format: %Y-%m-%d.\n"
|
||||
" Example: {'stock_date_end': date('2023-12-01')}\n"
|
||||
"- datetime: eval string to date time. Format %Y-%m-%d %H:%M:%S.\n"
|
||||
" Example: {'name': datetime('2023-12-01 10:00:00')}\n"
|
||||
"- today: eval current date\n"
|
||||
" Example: {'stock_date_end': today}"
|
||||
msgstr ""
|
||||
"Un diccionari per evaluar el context:\n"
|
||||
"- date: evalua un text a data. Format: %Y-%m-%d.\n"
|
||||
" Exemple: {'stock_date_end': date('2023-12-01')}\n"
|
||||
"- datetime: evalua un text a data i hora. Format %Y-%m-%d %H:%M:%S.\n"
|
||||
" Exemple: {'name': datetime('2023-12-01 10:00:00')}\n"
|
||||
"- today: evalua la data d'avui\n"
|
||||
" Exemple: {'stock_date_end': today}"
|
||||
|
||||
msgctxt "help:babi.filter,python_expression:"
|
||||
msgid ""
|
||||
"The python expression introduced will be evaluated. If the result is True "
|
||||
|
|
18
locale/es.po
18
locale/es.po
|
@ -881,6 +881,24 @@ msgstr ""
|
|||
"- \"ym()\": Devuelve el año-mes (como texto)\n"
|
||||
"- \"ymd()\": Devuelve el año-mes-día (como texto)"
|
||||
|
||||
msgctxt "help:babi.filter,context:"
|
||||
msgid ""
|
||||
"A dict to eval context:\n"
|
||||
"- date: eval string to date. Format: %Y-%m-%d.\n"
|
||||
" Example: {'stock_date_end': date('2023-12-01')}\n"
|
||||
"- datetime: eval string to date time. Format %Y-%m-%d %H:%M:%S.\n"
|
||||
" Example: {'name': datetime('2023-12-01 10:00:00')}\n"
|
||||
"- today: eval current date\n"
|
||||
" Example: {'stock_date_end': today}"
|
||||
msgstr ""
|
||||
"A diccionario para evaluar el context:\n"
|
||||
"- date: evalua un texto a fecha. Formato: %Y-%m-%d.\n"
|
||||
" Ejemplo: {'stock_date_end': date('2023-12-01')}\n"
|
||||
"- datetime: evalua un texto a fecha i hora. Formato %Y-%m-%d %H:%M:%S.\n"
|
||||
" Ejemplo: {'name': datetime('2023-12-01 10:00:00')}\n"
|
||||
"- today: evalua la fecha de hoy\n"
|
||||
" Ejemplo: {'stock_date_end': today}"
|
||||
|
||||
msgctxt "help:babi.filter,python_expression:"
|
||||
msgid ""
|
||||
"The python expression introduced will be evaluated. If the result is True "
|
||||
|
|
Loading…
Reference in New Issue