Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to use relativedelta in Odoo Studio for the following computed fields?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
#fields#studio#dateutil#datetime
2 Antwoorden
3417 Weergaven
Avatar
Bhoj Rani Soopal

This is my error: 


RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/home/odoo/src/odoo/saas-16.4/odoo/tools/safe_eval.py", line 365, in safe_eval

    return unsafe_eval(c, globals_dict, locals_dict)

  File "", line 6, in

TypeError: 'wrap_module' object is not callable


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1715, in _serve_db

    return service_model.retrying(self._serve_ir_http, self.env)

  File "/home/odoo/src/odoo/saas-16.4/odoo/service/model.py", line 133, in retrying

    result = func()

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1742, in _serve_ir_http

    response = self.dispatcher.dispatch(rule.endpoint, args)

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1943, in dispatch

    result = self.request.registry['ir.http']._dispatch(endpoint)

  File "/home/odoo/src/odoo/saas-16.4/odoo/addons/base/models/ir_http.py", line 191, in _dispatch

    result = endpoint(**request.params)

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 717, in route_wrapper

    result = endpoint(self, *args, **params_ok)

  File "/home/odoo/src/odoo/saas-16.4/addons/web/controllers/dataset.py", line 30, in call_kw

    return self._call_kw(model, method, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/addons/web/controllers/dataset.py", line 26, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/api.py", line 466, in call_kw

    result = _call_kw_multi(method, model, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/api.py", line 453, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6781, in onchange

    todo = [

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6784, in

    if name not in done and snapshot0.has_changed(name)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6584, in has_changed

    return self[name] != record[name]

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6211, in __getitem__

    return self._fields[key].__get__(self, type(self))

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1157, in __get__

    self.recompute(record)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1367, in recompute

    apply_except_missing(self.compute_value, recs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1340, in apply_except_missing

    func(records)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1389, in compute_value

    records._compute_field_value(self)

  File "/home/odoo/src/odoo/saas-16.4/addons/base_automation/models/base_automation.py", line 434, in _compute_field_value

    _compute_field_value.origin(self, field)

  File "/home/odoo/src/odoo/saas-16.4/addons/mail/models/mail_thread.py", line 395, in _compute_field_value

    return super()._compute_field_value(field)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 4553, in _compute_field_value

    fields.determine(field.compute, self)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 104, in determine

    return needle(records, *args)

  File "/home/odoo/src/odoo/saas-16.4/odoo/addons/base/models/ir_model.py", line 38, in

    func = lambda self: safe_eval(text, SAFE_EVAL_BASE, {'self': self}, mode="exec")

  File "/home/odoo/src/odoo/saas-16.4/odoo/tools/safe_eval.py", line 379, in safe_eval

    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))

ValueError: : "'wrap_module' object is not callable" while evaluating

'for record in self:\n    if record.x_studio_contract_duration_months ==0:\n       record["x_studio_contract_target_end_date"] = record.x_studio_contract_target_start_date \n       \n    if (record.x_studio_contract_target_start_date and record.x_studio_contract_duration_months):\n        future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta(months=+record.x_studio_contract_duration_months)\n        print(future_date)\n        record["x_studio_contract_target_end_date"] = future_date - datetime.timedelta(days=1)\n'


The above server error caused the following client error:

null


And this is the code I am using for: 
for record in self:

    if record.x_studio_contract_duration_months ==0:

       record["x_studio_contract_target_end_date"] = record.x_studio_contract_target_start_date 

       

    if (record.x_studio_contract_target_start_date and record.x_studio_contract_duration_months):

        future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta(months=+record.x_studio_contract_duration_months)

        print(future_date)

        record["x_studio_contract_target_end_date"] = future_date - datetime.timedelta(days=1)


Thanks in advance! 

0
Avatar
Annuleer
Avatar
Francesco Pranzo
Beste antwoord

try to update the code with this:

future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta.relativedelta(months=+record.x_studio_contract_duration_months)



0
Avatar
Annuleer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

Hi,In the given question, an attempt is made to add months which could potentially lead to an error. This is due to the usage of 'dateutil.relativedelta' with an argument of months equals to plus record.x_studio_contract_duration_months. The corrected solution uses 'dateutil.relativedelta.relativedelta' with an argument of months equals to record.x_studio_contract_duration_months to accurately apply the relative difference for adding months in date calculations. The key difference is in the correct usage of the relativedelta method for proper date manipulation. This change ensures that the months are added correctly.

By following these steps, you should be able to diagnose and potentially resolve the issue with the missing Studio tabs in your Odoo database.


Hope it helps

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Studio vs Code (V16)
#studio
Avatar
Avatar
1
aug. 23
1971
Filters / Custom Filters (V16) Opgelost
#studio
Avatar
Avatar
1
aug. 23
2128
"Time data does not match format" error with custom code Opgelost
v17 #datetime
Avatar
Avatar
1
mrt. 24
3191
How to delete studio approval rules? Opgelost
#studio v17
Avatar
Avatar
Avatar
2
feb. 24
1886
How to make read-only fields false in 17? Opgelost
#fields v17
Avatar
Avatar
Avatar
3
feb. 24
5084
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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