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 can I default the Expiration Date of a Quotation to 30 days, 60 days, etc?

Iscriviti

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

La domanda è stata contrassegnata
defaultdatequotationexpiration
5 Risposte
18534 Visualizzazioni
Avatar
Community Question

This field is left blank unless the user fills it in - I'd like to fill it in automatically.

How can this be achieved?


0
Avatar
Abbandona
Avatar
Daniel
Risposta migliore

@David i managed it using ur method

Action To  Do:  Update the record

Trigger Condition: On Creation

Date to write:

Field: Expiration (Sales Order)

Evaluation Type: Python expression

Value:  record.date_order + datetime.timedelta(days=30)


1
Avatar
Abbandona
Jason Dueck

Thank you, I was able to get this implemented after years of not having it. I would like to add that in Odoo v16 the model "Quotation" doesn't seem to exist. The model instead is "Sales Order" as suggested by the field value you listed, "Expiration (Sales Order)".

Avatar
Josep Anton Belchi Riera
Risposta migliore

No need to use automated actions. There is a parameter in settings / sales. 
(Screenshot from V16)


1
Avatar
Abbandona
Avatar
Ray Carnes (ray)
Risposta migliore

You can set the value of a field using an Automated Action, configured with a Trigger Condition of On Creation.

1. Activate Developer Mode, then nagivate to Settings --> Technical --> Automation --> Automated Actions.

2. Create an Automated Action like this:


The Python script portion:

DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"

if not record.validity_date:
record['validity_date'] = datetime.datetime.strptime(record.date_order, DATETIME_FORMAT)
+ datetime.timedelta(days=30)

This example checks if the user has defined an Expiry Date, and if they have not, calculates a default 30 days from now.

By changing 30 to 60 you can extend the default number of days used to calculate the Expiry Date of the Quotation.

1
Avatar
Abbandona
Bassem Riachi

dear Ray

Im using Saas v13 enterprise and tried the same steps and code you mentioned however its giving below error

Error:

Odoo Server Error

Traceback (most recent call last):

File "/home/odoo/src/odoo/13.0/odoo/tools/safe_eval.py", line 349, in safe_eval

return unsafe_eval(c, globals_dict, locals_dict)

File "", line 13, in <module>

TypeError: strptime() argument 1 must be str, not datetime.datetime

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 619, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 309, in _handle_exception

raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

File "/home/odoo/src/odoo/13.0/odoo/tools/pycompat.py", line 14, in reraise

raise value

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 664, in dispatch

result = self._call_function(**self.params)

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 345, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/home/odoo/src/odoo/13.0/odoo/service/model.py", line 93, in wrapper

return f(dbname, *args, **kwargs)

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 338, in checked_call

result = self.endpoint(*a, **kw)

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 910, in __call__

return self.method(*args, **kw)

File "/home/odoo/src/odoo/13.0/odoo/http.py", line 510, in response_wrap

response = f(*args, **kw)

File "/home/odoo/src/odoo/13.0/addons/web/controllers/main.py", line 1320, in call_kw

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

File "/home/odoo/src/odoo/13.0/addons/web/controllers/main.py", line 1312, in _call_kw

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

File "/home/odoo/src/odoo/13.0/odoo/api.py", line 387, in call_kw

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

File "/home/odoo/src/odoo/13.0/odoo/api.py", line 374, in _call_kw_multi

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

File "/home/odoo/src/odoo/13.0/addons/base_automation/models/base_automation.py", line 291, in write

action._process(records, domain_post=domain_post)

File "/home/odoo/src/odoo/13.0/addons/base_automation/models/base_automation.py", line 221, in _process

raise e

File "/home/odoo/src/odoo/13.0/addons/base_automation/models/base_automation.py", line 218, in _process

self.action_server_id.with_context(**ctx).run()

File "/home/odoo/src/odoo/13.0/odoo/addons/base/models/ir_actions.py", line 545, in run

res = func(action, eval_context=eval_context)

File "/home/odoo/src/odoo/13.0/odoo/addons/base/models/ir_actions.py", line 430, in run_action_code_multi

safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True) # nocopy allows to return 'action'

File "/home/odoo/src/odoo/13.0/odoo/tools/safe_eval.py", line 372, in safe_eval

pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2])

File "/home/odoo/src/odoo/13.0/odoo/tools/pycompat.py", line 13, in reraise

raise value.with_traceback(tb)

File "/home/odoo/src/odoo/13.0/odoo/tools/safe_eval.py", line 349, in safe_eval

return unsafe_eval(c, globals_dict, locals_dict)

File "", line 13, in <module>

ValueError: <class 'TypeError'>: "strptime() argument 1 must be str, not datetime.datetime" while evaluating

'# Available variables:\n# - env: Odoo Environment on which the action is triggered\n# - model: Odoo Model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - log: log(message, level=\'info\'): logging function to record debug information in ir.logging table\n# - Warning: Warning Exception to use with raise\n# To return an action, assign: action = {...}\n\nDATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"\n\nrecord[\'validity_date\'] = datetime.datetime.strptime(record.date_order, DATETIME_FORMAT) + datetime.timedelta(days=30)'

Avatar
Christian Meyer
Risposta migliore

I only see "Scheduled Actions" and no "Automated Actions" in my odoo instance (v11, community). Is this an enterprise feature ?

0
Avatar
Abbandona
Ray Carnes (ray)

Check if you have the module "Automated Action Rules" (aka base_automation) installed.

Christian Meyer

Ah, that was not installed ! Thanks again, Ray!

Avatar
Dávid Kecskés
Risposta migliore

Hello there!

I solve this problem in this way:


I made  an  automated action...

Action To  Do:  U pdate the record

Trigger Condition: On Creation

Date to write:

Field: Expiration (Sales Order)

Evaluation Type: Python expression

Value:  record.date_order + datetime.timedelta(days=30)


Hope this help for somebody. :)

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à
How to set the default invoice date to today's date in V9? Risolto
default date
Avatar
Avatar
1
gen 16
4822
How can I set today as the default date in a date field in Odoo Studio? Risolto
default date Studio
Avatar
Avatar
Avatar
2
lug 25
13524
Set Delivery Date for an Sales Order
date delivery quotation
Avatar
Avatar
2
mar 15
10131
How can I make a quotation expire after 60 days?
v7 quotation expiration
Avatar
Avatar
1
mar 15
7940
v16 - Sended mail for quotation with due date ! How to remove it?
mail date quotation template Due
Avatar
Avatar
1
giu 23
2846
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