Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
defaultdatequotationexpiration
5 Besvarelser
18581 Visninger
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
Kassér
Avatar
Daniel
Bedste svar

@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
Kassér
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
Bedste svar

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


1
Avatar
Kassér
Avatar
Ray Carnes (ray)
Bedste svar

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
Kassér
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
Bedste svar

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

0
Avatar
Kassér
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
Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How to set the default invoice date to today's date in V9? Løst
default date
Avatar
Avatar
1
jan. 16
4841
How can I set today as the default date in a date field in Odoo Studio? Løst
default date Studio
Avatar
Avatar
Avatar
2
jul. 25
13550
Set Delivery Date for an Sales Order
date delivery quotation
Avatar
Avatar
2
mar. 15
10141
How can I make a quotation expire after 60 days?
v7 quotation expiration
Avatar
Avatar
1
mar. 15
7958
v16 - Sended mail for quotation with due date ! How to remove it?
mail date quotation template Due
Avatar
Avatar
1
jun. 23
2882
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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