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

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

Iscriviti

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

La domanda è stata contrassegnata
#fields#studio#dateutil#datetime
2 Risposte
3398 Visualizzazioni
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
Abbandona
Avatar
Francesco Pranzo
Risposta migliore

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
Abbandona
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Risposta migliore

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
Abbandona
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à
Studio vs Code (V16)
#studio
Avatar
Avatar
1
ago 23
1970
Filters / Custom Filters (V16) Risolto
#studio
Avatar
Avatar
1
ago 23
2124
"Time data does not match format" error with custom code Risolto
v17 #datetime
Avatar
Avatar
1
mar 24
3187
How to delete studio approval rules? Risolto
#studio v17
Avatar
Avatar
Avatar
2
feb 24
1884
How to make read-only fields false in 17? Risolto
#fields v17
Avatar
Avatar
Avatar
3
feb 24
5077
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