Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Patch Spreadsheet Date Ranges in 17

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptspreadsheets17.0
3 Réponses
3001 Vues
Avatar
Matt Spinder

I am trying to add more date ranges to the spreadsheet/dashboard filters. This worked in 16, but it does not work in 17.


import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";

patch(require('@spreadsheet/helpers/constants'), {
    RELATIVE_DATE_RANGE_TYPES: [
        { type: "year_to_date", description: _t("Year to Date") },
        { type: "last_week", description: _t("Last 7 Days") },
        { type: "last_month", description: _t("Last 30 Days") },
        { type: "last_three_months", description: _t("Last 90 Days") },
        { type: "last_six_months", description: _t("Last 180 Days") },
        { type: "last_year", description: _t("Last 365 Days") },
        { type: "last_three_years", description: _t("Last 3 Years") },
        { type: "o_last_business_day", description: _t("Last Business Day") },
        { type: "o_last_week", description: _t("Last Week") },
        { type: "o_last_month", description: _t("Last Month") },
    ]
});

And I insert in the __manifest__.py after the original:

'assets': {
    'spreadsheet.o_spreadsheet': [
        ('after', 'spreadsheet/static/src/helpers/constants.js', 'spreadsheet_dates/static/src/helpers_constants.js'),
        ('after', 'spreadsheet/static/src/global_filters/helpers.js', 'spreadsheet_dates/static/src/global_filters_helpers.js'),
    ],
}

I see the patch code in the final javascript looking at the browsers code, but it does not seem to apply. (I also patched getRelativeDateDomain to support the new filters, but that does not seem to apply either. I am testing that with just a conole.log)


What am I doing wrong, any help is appreciated.

Thanks,

-Matt

0
Avatar
Ignorer
Avatar
Matt Spinder
Auteur Meilleure réponse

I found the issue. I need to prepend the patch files. I believe (and someone can correct me if I wrong for the next person), that odoo.define dependencies parameter will cause the module to queue until after the dependent modules are loaded. So in my case, a module that depends on '@spreadsheet/helpers/constants' was defined before the module '@spreadsheet/helpers/constants' was defined, and then loaded before my patch is loaded.

odoo.define('@spreadsheet/global_filters/components/filter_value/filter_value', ['@spreadsheet/helpers/constants' ], function() {})
odoo.define('@spreadsheet/helpers/constants', function() { RELATIVE_DATE_RANGE_TYPES  = ...)
// @spreadsheet/global_filters/components/filter_value/filter_value is now loaded with the original RELATIVE_DATE_RANGE_TYPES 
odoo.define('@spreadsheet_dates/constants', ['@spreadsheet/helpers/constants' ], function() { RELATIVE_DATE_RANGE_TYPES  = ...)
// Now my patch applies

With my module prepended:

odoo.define('@spreadsheet_dates/constants', ['@spreadsheet/helpers/constants' ], function() { RELATIVE_DATE_RANGE_TYPES  = ...)
odoo.define('@spreadsheet/global_filters/components/filter_value/filter_value', ['@spreadsheet/helpers/constants' ], function() {})
odoo.define('@spreadsheet/helpers/constants', function() { RELATIVE_DATE_RANGE_TYPES  = ...)
// Now my patch applies
// @spreadsheet/global_filters/components/filter_value/filter_value is now loaded with the patched RELATIVE_DATE_RANGE_TYPES 

 

0
Avatar
Ignorer
Avatar
SterlingKensington
Meilleure réponse

It helped me also, Thank you.

0
Avatar
Ignorer
Avatar
Jeff King
Meilleure réponse

Is it possible to give more details on your solution? I am trying to do the exact same thing as you and cannot get it to work. Are you still using patch in your final solution with your added files loaded after the source files in the manifest?

0
Avatar
Ignorer
Matt Spinder
Auteur

The files are prepended in the __manifest__.py file:
```
'assets': {
'spreadsheet.o_spreadsheet': [
('prepend', 'spreadsheet_dates/static/src/helpers_constants.js'),
('prepend', 'spreadsheet_dates/static/src/global_filters_helpers.js'),
],
}
```

Then in helpers_contants.js:
```
import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";

patch(require('@spreadsheet/helpers/constants'), {
RELATIVE_DATE_RANGE_TYPES: [
{ type: "year_to_date", description: _t("Year to Date") },
{ type: "last_week", description: _t("Last 7 Days") },
{ type: "last_month", description: _t("Last 30 Days") },
{ type: "last_three_months", description: _t("Last 90 Days") },
{ type: "last_six_months", description: _t("Last 180 Days") },
{ type: "last_year", description: _t("Last 365 Days") },
{ type: "last_three_years", description: _t("Last 3 Years") },
{ type: "o_last_business_day", description: _t("Last Business Day") },
{ type: "o_last_week", description: _t("Last Week") },
{ type: "o_last_month", description: _t("Last Month") },
]
});
```

And global_filters_helpers.js
```
import { patch } from "@web/core/utils/patch";
import { serializeDate, serializeDateTime } from "@web/core/l10n/dates";
import { Domain } from "@web/core/domain";

var helpers = require('@spreadsheet/global_filters/helpers');
var _super = helpers.getRelativeDateDomain;
patch(helpers, {
getRelativeDateDomain(now, offset, rangeType, fieldName, fieldType) {
var s = _super(...arguments)
// Do stuff if _super returns none
}
});
```

Jeff King

I got it to work, thank you so much!

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How to create two models in a function similar to fields ?
javascript spreadsheets
Avatar
Avatar
2
mars 15
8721
Is it possible to merge 2 spreadsheets and/or 2 dashboards
spreadsheets dashbord 17.0
Avatar
0
juin 25
1068
Custom translations do not work for own Owl components and snippets
javascript development 17.0
Avatar
Avatar
2
déc. 24
2278
Reload certain fields on the form view without refreshing the page
javascript fields frontend 17.0
Avatar
0
déc. 24
2245
o_spreadsheet.js has many untranslated entries Résolu
javascript translations spreadsheets .po
Avatar
Avatar
2
févr. 23
3059
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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