Hello guys,
I have created 4 new filters in account.invoice. Invoices of the day, invoices of the week, invoices of the month and invoices of the current year.
All works very well. But the week filter (Ventes hebdomadaires - CF) doesn't work and I don't know why.
My file filters.xml :
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="filters_lapagept.ventes_annuelles_cf" model="ir.filters">
<field name="name">Ventes annuelles - CF</field>
<field name="model_id">account.invoice</field>
<field name="is_default" eval="False" />
<field name="user_id" ref="" />
<field name="domain">[['invoice_year','=',time.strftime('%Y')]]</field>
<field name="context">{'group_by':['period_id']}</field>
</record>
<record id="filters_lapagept.ventes_mensuelles_cf" model="ir.filters">
<field name="name">Ventes mensuelles - CF</field>
<field name="model_id">account.invoice</field>
<field name="is_default" eval="False" />
<field name="user_id" ref="" />
<field name="domain">[['invoice_month','=',time.strftime('%m')]]</field>
<field name="context">{}</field>
</record>
<record id="filters_lapagept.ventes_hebdomadaires_cf" model="ir.filters">
<field name="name">Ventes hebdomadaires - CF</field>
<field name="model_id">account.invoice</field>
<field name="is_default" eval="False" />
<field name="user_id" ref="" />
<field name="domain">[['invoice_week','=',time.strftime('%U')]]</field>
<field name="context">{}</field>
</record>
<record id="filters_lapagept.ventes_quotidiennes_cf" model="ir.filters">
<field name="name">Ventes quotidiennes - CF</field>
<field name="model_id">account.invoice</field>
<field name="is_default" eval="False" />
<field name="user_id" ref="" />
<field name="domain">[['date_invoice','=',time.strftime('%Y-%m-%d')]]</field>
<field name="context">{}</field>
</record>
</data>
</openerp>
My file classes.py :
from openerp import models, fields, api, _
import logging
_logger = logging.getLogger(__name__)
import datetime
from datetime import datetime
class account_invoice(models.Model):
_inherit = "account.invoice"
invoice_year = fields.Char(compute='_findyear', string="Annee de la facture", store=True)
invoice_month = fields.Char(compute='_findmonth',string="Mois de la facture", store=True)
invoice_week = fields.Char(compute='_findweek',string="Semaine de la facture", store=True)
@api.depends('date_invoice')
def _findyear(self):
self.invoice_year = datetime.now().strftime('%Y')
@api.depends('date_invoice')
def _findmonth(self):
self.invoice_month = datetime.now().strftime('%m')
@api.depends('date_invoice')
def _findweek(self):
self.invoice_week = datetime.now().strftime('%U')
But I always get this error for the week filter :
Error: Failed to evaluate search criterions:
{"code":400,"message":"Evaluation Error","data":{"type":"local_exception","debug":"Local evaluation failure\nValueError: No known conversion for %U\n\n{\"domains\":[[[\"type\",\"=\",\"out_invoice\"]],\"[['invoice_week','=',time.strftime('%U')]]\"],\"contexts\":[{\"lang\":\"en_US\",\"tz\":\"America/Montreal\",\"uid\":1,\"default_type\":\"out_invoice\",\"type\":\"out_invoice\",\"journal_type\":\"sale\",\"params\":{\"action\":586}},\"{}\"],\"group_by_seq\":[\"{}\"]}"}}
http://cferalma.com/web/static/src/js/views.js:852
Thanks all for your idea!
Reported on Github : https://github.com/odoo/odoo/issues/9943