Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    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
    Producție
    • 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
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How can I default the Expiration Date of a Quotation to 30 days, 60 days, etc?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
defaultdatequotationexpiration
5 Răspunsuri
18435 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Daniel
Cel mai bun răspuns

@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
Imagine profil
Abandonează
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)".

Imagine profil
Josep Anton Belchi Riera
Cel mai bun răspuns

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


1
Imagine profil
Abandonează
Imagine profil
Ray Carnes (ray)
Cel mai bun răspuns

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
Imagine profil
Abandonează
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)'

Imagine profil
Christian Meyer
Cel mai bun răspuns

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

0
Imagine profil
Abandonează
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!

Imagine profil
Dávid Kecskés
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to set the default invoice date to today's date in V9? Rezolvat
default date
Imagine profil
Imagine profil
1
ian. 16
4763
How can I set today as the default date in a date field in Odoo Studio? Rezolvat
default date Studio
Imagine profil
Imagine profil
Imagine profil
2
iul. 25
13406
Set Delivery Date for an Sales Order
date delivery quotation
Imagine profil
Imagine profil
2
mar. 15
10075
How can I make a quotation expire after 60 days?
v7 quotation expiration
Imagine profil
Imagine profil
1
mar. 15
7866
v16 - Sended mail for quotation with due date ! How to remove it?
mail date quotation template Due
Imagine profil
Imagine profil
1
iun. 23
2788
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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