Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
filterweek_numberaccount.invoice
4 Risposte
6341 Visualizzazioni
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
Abbandona
Pascal Tremblay
Autore

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

Avatar
Pascal Tremblay
Autore Risposta migliore

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
Abbandona
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
Autore

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
Autore

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
Risposta migliore

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
Abbandona
Pascal Tremblay
Autore

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).

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
cbbbbggf
filter
Avatar
0
nov 25
2
Factura en estado "EN PROCESO DE PAGO"
filter
Avatar
0
nov 25
2
Simultaneous search criteria across companies and persons Risolto
filter
Avatar
Avatar
1
ott 25
767
Extended "shop" controller executes (confirmed by log), but the view ignores the modified "qcontext" (even with request.render)
filter
Avatar
Avatar
Avatar
3
ott 25
905
Differentiating subscription invoices from one-shot services Risolto
filter
Avatar
Avatar
Avatar
3
set 25
1066
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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