Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Why does my week filter not work in account.invoice?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
filterweek_numberaccount.invoice
4 Respostes
6352 Vistes
Avatar
Pascal Tremblay

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!


0
Avatar
Descartar
Pascal Tremblay
Autor

Reported on Github : https://github.com/odoo/odoo/issues/9943

Avatar
Pascal Tremblay
Autor Best Answer

Here is the domain we really needed :


<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">[('date_invoice','&gt;=', ((context_today()).strftime('%Y-%m-%d'))), ('date_invoice','&lt;=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]</field>

        <field name="context">{'group_by':'date_invoice'}</field>

</record>


This way, we get only invoice of the actual week. Not invoices from the last week.


0
Avatar
Descartar
Axel Mendoza

That domain is for another scenario, not for your original question problem that was answered ok by my answer, or not? That answer should be the accepted one and up voted, not your resumed and extended answer with new particular problems solved. Just my opinion

Pascal Tremblay
Autor

Axel, your domain returns also invoice for the last week. With my python function, I really put the number of the current week in my database. I never talked about the last week. Sorry. I have verified before to put my answer as the good one. @api.depends('date_invoice') def _findweek(self): self.invoice_week = datetime.now().strftime('%U')

Pascal Tremblay
Autor

My goal on this forum is not to bypass everybody and do bad things...

Axel Mendoza

Happy to see that you solve your problem. The domain I posted using context_today to get the actual week number was just the way to fix your original domain
[['invoice_week','=',time.strftime('%U')]]
that was supposed to return the actual week number, nothing more

Avatar
Axel Mendoza
Best Answer

Hi @Pascal, very interesting thing/bug happened to you. You could report it to Odoo on Github.

Note: I'm still waiting for your feedback of one or two of my answers to your question.

The error that you are seen is from pyeval.js implementation of time.strftime that rely on the partially implemented datetime.datetime.strftime, all of this in javascript. Here is the formats that is supported by the function and the error you are seen:

strftime: function () {
var self = this;
var args = py.PY_parseArgs(arguments, 'format');
return py.str.fromJSON(args.format.toJSON()
.replace(/%([A-Za-z])/g, function (m, c) {
switch (c) {
case 'Y': return _.str.sprintf('%04d', self.year);
case 'm': return _.str.sprintf('%02d', self.month);
case 'd': return _.str.sprintf('%02d', self.day);
case 'H': return _.str.sprintf('%02d', self.hour);
case 'M': return _.str.sprintf('%02d', self.minute);
case 'S': return _.str.sprintf('%02d', self.second);
}
throw new Error('ValueError: No known conversion for ' + m);
}));
},

Your problem can be solved by change this record domain:

<record id="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','=',context_today().weekday()]]</field>
<field name="context">{}</field>
</record>

Cheers

1
Avatar
Descartar
Pascal Tremblay
Autor

Thanks for this answer. Will try it tomorrow. I will check old posts to find where I owe you some answers (sorry for this, I will correct it).

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
cbbbbggf
filter
Avatar
0
de nov. 25
2
Factura en estado "EN PROCESO DE PAGO"
filter
Avatar
0
de nov. 25
2
Simultaneous search criteria across companies and persons Solved
filter
Avatar
Avatar
1
d’oct. 25
769
Extended "shop" controller executes (confirmed by log), but the view ignores the modified "qcontext" (even with request.render)
filter
Avatar
Avatar
Avatar
3
d’oct. 25
917
Differentiating subscription invoices from one-shot services Solved
filter
Avatar
Avatar
Avatar
3
de set. 25
1070
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now