Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

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

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
defaultdatequotationexpiration
5 Trả lời
18548 Lượt xem
Ảnh đại diện
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
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Daniel
Câu trả lời hay nhất

@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
Ảnh đại diện
Huỷ bỏ
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)".

Ảnh đại diện
Josep Anton Belchi Riera
Câu trả lời hay nhất

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


1
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Ray Carnes (ray)
Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
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)'

Ảnh đại diện
Christian Meyer
Câu trả lời hay nhất

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

0
Ảnh đại diện
Huỷ bỏ
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!

Ảnh đại diện
Dávid Kecskés
Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
How to set the default invoice date to today's date in V9? Đã xử lý
default date
Ảnh đại diện
Ảnh đại diện
1
thg 1 16
4833
How can I set today as the default date in a date field in Odoo Studio? Đã xử lý
default date Studio
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 7 25
13540
Set Delivery Date for an Sales Order
date delivery quotation
Ảnh đại diện
Ảnh đại diện
2
thg 3 15
10139
How can I make a quotation expire after 60 days?
v7 quotation expiration
Ảnh đại diện
Ảnh đại diện
1
thg 3 15
7950
v16 - Sended mail for quotation with due date ! How to remove it?
mail date quotation template Due
Ảnh đại diện
Ảnh đại diện
1
thg 6 23
2860
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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