Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Patch Spreadsheet Date Ranges in 17

Odoberať

Get notified when there's activity on this post

This question has been flagged
javascriptspreadsheets17.0
3 Replies
3002 Zobrazenia
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
Zrušiť
Avatar
Matt Spinder
Autor Best Answer

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
Zrušiť
Avatar
SterlingKensington
Best Answer

It helped me also, Thank you.

0
Avatar
Zrušiť
Avatar
Jeff King
Best Answer

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
Zrušiť
Matt Spinder
Autor

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!

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to create two models in a function similar to fields ?
javascript spreadsheets
Avatar
Avatar
2
mar 15
8721
Is it possible to merge 2 spreadsheets and/or 2 dashboards
spreadsheets dashbord 17.0
Avatar
0
jún 25
1068
Custom translations do not work for own Owl components and snippets
javascript development 17.0
Avatar
Avatar
2
dec 24
2278
Reload certain fields on the form view without refreshing the page
javascript fields frontend 17.0
Avatar
0
dec 24
2245
o_spreadsheet.js has many untranslated entries Solved
javascript translations spreadsheets .po
Avatar
Avatar
2
feb 23
3059
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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