Created Date domain on domain window tab

Hi, I’d like to display cancel invoices on a new tab, but only display the last seven days of cancelled invoices.

I try to use:

<field name="domain" eval="[('state', '=', 'cancel'), ('create_date', '>=', Date('delta_days'=-7))]" pyson="1"/>

But it does not work, it throws exception:

Traceback (most recent call last):
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/protocols/dispatcher.py", line 167, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelstorage.py", line 382, in search_count
    res = cls.search(domain, order=[], count=True)
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelsql.py", line 1187, in search
    tables, expression = cls.search_domain(domain)
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelsql.py", line 1377, in search_domain
    expression = convert(domain)
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelsql.py", line 1375, in convert
    domain[1:] if domain[0] == 'AND' else domain)))
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelsql.py", line 1374, in <genexpr>
    return And((convert(d) for d in (
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/modelsql.py", line 1365, in convert
    expression = field.convert_domain(domain, tables, cls)
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/fields/field.py", line 352, in convert_domain
    expression = Operator(column, self._domain_value(operator, value))
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/fields/field.py", line 329, in _domain_value
    return self.sql_format(value)
  File "/srv/samba/home/deployer/guke/nantic/trytond/trytond/model/fields/date.py", line 80, in sql_format
    datepart, timepart = value.split(" ")
ValueError: need more than 1 value to unpack

create_date is a Timestamp so it must be compared to a pyson.DateTime and delta_days should not be a string by a keyword.

Just for reference, the complete xml line will be something like this:

<record model="ir.action.act_window.domain" id="act_invoice_out_domain_cancel">
    <field name="name">Cancelled</field>
    <field name="sequence" eval="40"/>
    <field name="domain" eval="[('state', '=', 'cancel'), ('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_days=-7))]" pyson="1"/>
    <field name="count" eval="True"/>
    <field name="act_window" ref="account_invoice.act_invoice_out_form"/>
</record>
1 Like

A post was split to a new topic: SAX parser exception, not well-formed