コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

How to Set 48-Hour Order Restriction on Specific Food Items in Shop Page? Version: Odoo saas~17.4+e Enterprise Edition

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
salesecommercewebsitescheduledactionodooV17
3 返信
2457 ビュー
アバター
Zuhair

Hello everyone,

I'm working on a website where users can order specific food items from a shop page, with each item being available on certain days of the week. I want to add a condition on the shop page that allows users to place an order only if it's at least 48 hours or more in advance. If there are less than 48 hours left for a specific food item, it should not be possible to add it to the cart.

Could anyone advise how to implement this? Would a scheduled action be the right approach? 

Any suggestions?

Thanks in advance for your help!

0
アバター
破棄
Zuhair
著作者

Every Oder will be place via the Website app in the shop page:

Sandwich: Available to order: ( Tuesday, Wednesday, Thursday, Friday and Saturday) not Available to order: (Sunday and Monday)

Pasta Salad: Available to order: ( Wednesday, Thursday, Friday Saturday and Sunday) not Available to order: (Monday and Tuesday)

Mini Pizza: Available to order: (Thursday, Friday, Saturday, Sunday and Monday) not Available to order: ( Tuesday and Wednesday)

Chicken Nuggets: Available to order: (Friday, Saturday, Sunday, Monday and Tuesday) Not Available to Order ( Wednesday and Thursday)

Fish and Chips: Available to order: (Saturday, Sunday, Monday, Tuesday and Wednesday Not Available to Order: ( Thursday and Friday)

( >>> Making the menu unavailable doesn't seem quite right. Today is Monday, user can't order for tomorrow (Tuesday), can the user not order for a week Monday or Tuesday? If Monday & Tuesday's menu isn't published they wouldn't be able to place that order.<<<)

What approach do you propose?

I tried this approach because of preparations. so that I have the number of a specific new that need to be prepared for a specific day 48 hours in advance.

If you have a better solution let me know please.

( >>> Not sure how you plan to capture the date of delivery. I would have used the extra step at checkout option. Settings > Website > Shop checkout section

Configure the form to include delivery date and probably have some automation here to not accept order less than 48 hrs.<<<)

or this part is it possible in Odoo V17.4 online? Can you give more details please.

Thanks

Jaideep

Yes, it is possible to have a form input at checkout.
1 Navigate to Website > Configuration > Settings and enable extra step at checkout
2 You would then have the option to configure the form Or navigate to a cart and click 'checkout'. While on the form, click edit top right of the page.
3. Click a field and change type or add a new field and set type to 'Delivery date'.
Once this field is set, it updated the delivery date on the order (other info tab) as well as updates the delivery order's 'Scheduled date'.

If your business model is to only accept orders between 48hr and 7 days (effective 5 days), then you should follow your method since it does not require any input from customer as to when they wish the delivery as it is possible only on a certain day of the week within 7 days

アバター
Jaideep
最善の回答

1 Making the menu unavailable doesn't seem quite right. Today is Monday, user can't order for tomorrow (Tuesday), can the user not order for a week Monday or Tuesday? If Monday & Tuesday's menu isn't published they wouldn't be able to place that order.

Unless I have misunderstood your ordering timelines. ( >>> 1. Ordering Restriction and Availability: The goal is for customers to place orders at least 48 hours in advance. For instance, if a user wants to order a sandwich for Monday, they should not be able to do so on the same Monday. However, the same sandwich should still be available for ordering on any day from Tuesday to Saturday for the next Monday<<<)

From what you describe it seems you want the orders deliveries to be limited between 48 hrs to 5 days

2 Not sure how you plan to capture the date of delivery. I would have used the extra step at checkout option. Settings > Website > Shop checkout section

Configure the form to include delivery date and probably have some automation here to not accept order less than 48 hrs.


3. You might be able to organize your menu with ecommerce categories and even banners to highlight which day the product is available.

0
アバター
破棄
Zuhair
著作者

Okay I will try it. thank you

アバター
Zuhair
著作者 最善の回答

Hello,

But I want to make it available for each week. For example i want Noodle to be available on each Monday. With the scheduled active date I can only insert one date at a time. Unless I am not doing it the right way.

Thanks

0
アバター
破棄
Nazzun Hanif Ahsani

I see,
Maybe you can replace it with column `Scheduled Active Day` with the column type is `Selection`. You can put selection for days name of `Sunday until Monday`. But this approach will only work if only one product active in one certain day only (not multiple days). If you want to do multiple days, you will need a table to store the days name and use a column type `many2many`.

Zuhair
著作者

Can you help me how to set up the table to store the data?

Zuhair
著作者

I tried the selection then i created an scheduled action but it is not working. i am getting this error:

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/home/odoo/src/odoo/17.0/odoo/tools/safe_eval.py", line 391, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
File "ir.actions.server(822,)", line 2, in <module>
AttributeError: 'product.template' object has no attribute 'fields'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/odoo/src/odoo/17.0/odoo/http.py", line 1783, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/home/odoo/src/odoo/17.0/odoo/service/model.py", line 133, in retrying
result = func()
File "/home/odoo/src/odoo/17.0/odoo/http.py", line 1810, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/home/odoo/src/odoo/17.0/odoo/http.py", line 2014, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/home/odoo/src/odoo/17.0/addons/website/models/ir_http.py", line 235, in _dispatch
response = super()._dispatch(endpoint)
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_http.py", line 222, in _dispatch
result = endpoint(**request.params)
File "/home/odoo/src/odoo/17.0/odoo/http.py", line 759, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/home/odoo/src/odoo/17.0/addons/web/controllers/dataset.py", line 28, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/17.0/addons/web/controllers/dataset.py", line 20, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/17.0/odoo/api.py", line 468, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/odoo/src/odoo/17.0/odoo/api.py", line 453, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_cron.py", line 107, in method_direct_trigger
cron.with_user(cron.user_id).with_context({'lastcall': cron.lastcall}).ir_actions_server_id.run()
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_actions.py", line 939, in run
res = runner(run_self, eval_context=eval_context)
File "/home/odoo/src/odoo/17.0/addons/website/models/ir_actions_server.py", line 61, in _run_action_code_multi
res = super(ServerAction, self)._run_action_code_multi(eval_context)
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_actions.py", line 771, in _run_action_code_multi
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self)) # nocopy allows to return 'action'
File "/home/odoo/src/odoo/17.0/odoo/tools/safe_eval.py", line 405, in safe_eval
raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
ValueError: <class 'AttributeError'>: "'product.template' object has no attribute 'fields'" while evaluating
"# Get the current date using Odoo's fields safely\ncurrent_date = env['product.template'].fields.Date.today()\ncurrent_day = current_date.weekday() # Get the current day of the week (Monday = 0, ..., Sunday = 6)\n\n# Search for all products that have a preparation day set\nproducts = env['product.template'].search([\n ('x_studio_preparation_day', '!=', False) # Replace with your field's actual technical name\n])\n\nfor product in products:\n # Get the preparation day from the product's field\n preparation_day = int(product.x_studio_preparation_day)\n \n # Calculate the difference in days between the current day and the preparation day\n day_difference = (preparation_day - current_day + 7) % 7\n \n # Publish the product on its preparation day each week\n if day_difference == 0:\n product.write({'website_published': True})\n \n # Unpublish the product if it's within 48 hours of the preparation day\n elif day_difference < 2:\n product.write({'website_published': False})"

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPCError@https://test-food-service.odoo.com/web/assets/0d9bfb7/web.assets_web.min.js:2885:319
makeErrorFromResponse@https://test-food-service.odoo.com/web/assets/0d9bfb7/web.assets_web.min.js:2888:163
jsonrpc/promise</<@https://test-food-service.odoo.com/web/assets/0d9bfb7/web.assets_web.min.js:2892:34

Nazzun Hanif Ahsani

replace this line
`current_date = env['product.template'].fields.Date.today()`

with this
`current_date = datetime.datetime.today()`

Zuhair
著作者

Thank You.

I have been able to do it but when I run the scheduled action manually. all the dishes remain on the screen as published.

Python code:

# Map days of the week to their numeric values
day_map = {
'Monday': 0,
'Tuesday': 1,
'Wednesday': 2,
'Thursday': 3,
'Friday': 4,
'Saturday': 5,
'Sunday': 6
}

# Get the current date from the Odoo environment using today() safely
current_date = env['res.partner']._fields['create_date'].today()
current_day = current_date.weekday() # Get the current day of the week (Monday = 0, ..., Sunday = 6)

# Search for all products that have a preparation day set
products = env['product.template'].search([
('x_studio_preparation_day', '!=', False) # Replace with your field's actual technical name
])

for product in products:
# Get the preparation day from the product's field and map it to a numeric value
preparation_day_name = product.x_studio_preparation_day # Assuming this is the day name as a string
preparation_day = day_map.get(preparation_day_name)

# If preparation day is None (not in the map), skip this product
if preparation_day is None:
continue

# Calculate the difference in days between the current day and the preparation day
day_difference = (preparation_day - current_day + 7) % 7

# Debugging output
print(f"Product: {product.name}, Preparation Day: {preparation_day_name}, Day Difference: {day_difference}, Website Published: {product.website_published}")

# Publish the product on its preparation day each week
if day_difference == 0:
product.write({'website_published': True})

# Unpublish the product if it's within 48 hours of the preparation day
elif day_difference < 2:
product.write({'website_published': False})

Nazzun Hanif Ahsani

change the column to be activated or deactivated:

from `website_published`

to `is_published`

Jaideep

Would you not want all the dishes to be published?

There is a 48hrs + order leadtime, so some might want to order 5-7 days in advance.

Or is your order limited to ONLY 48hrs?

Zuhair
著作者

Hello,

I'm currently trying on setting up a food ordering system in Odoo. The menu is the same every week, with different items available each day. The weekly menu looks like this:

Monday: Sandwich
Tuesday: Pasta Salad
Wednesday: Mini Pizza
Thursday: Chicken Nuggets
Friday: Fish and Chips

To place an order, users must do so at least 48 hours in advance. For example, they should not be able to order the Monday menu on Monday itself. If they try, the system should prevent them from making that order.

What I've tried so far:

I've added a custom field on the product form that specifies the "available day" for each food item.
I attempted to use a Scheduled Action to automatically "unpublish" any menu items that do not meet the 48-hour rule, while keeping those that do meet the rule published.

Unfortunately, my approach hasn't worked as expected as all menu are still published.

Do you know a better way to implement this 48-hour rule within Odoo? I'd like v17 enterprise saas any suggestions this effectively.

This is the code i have used in the scheduled action:

# Map days of the week to their numeric values
day_map = {
'Monday': 0,
'Tuesday': 1,
'Wednesday': 2,
'Thursday': 3,
'Friday': 4,
'Saturday': 5,
'Sunday': 6
}

# Safely get the current datetime using Odoo's environment
current_datetime = env['ir.cron']._fields['nextcall'].now()
current_day = current_datetime.weekday() # Get the current day of the week (Monday = 0, ..., Sunday = 6)

# Search for all products that have a preparation day set
products = env['product.template'].search([
('x_studio_preparation_day', '!=', False) # Replace with your actual field name
])

for product in products:
# Get the preparation day from the product's field and map it to a numeric value
preparation_day_name = product.x_studio_preparation_day # Assuming this is the day name as a string
preparation_day = day_map.get(preparation_day_name)

# If preparation day is not found in day_map, skip the product
if preparation_day is None:
continue

# Calculate the difference in days to the next preparation day
day_difference = (preparation_day - current_day + 7) % 7

# Calculate the next preparation date by adding `day_difference` days to the current datetime
next_preparation_date = current_datetime + timedelta(days=day_difference)

# Calculate the cutoff datetime for 48 hours before the preparation day
cutoff_datetime = next_preparation_date - timedelta(hours=48)

# Log publication status changes
if current_datetime >= cutoff_datetime:
product.write({'website_published': False})
env['ir.logging'].create({
'name': 'Product Unpublished',
'type': 'server',
'level': 'info',
'dbname': env.cr.dbname,
'message': f"Unpublished product: {product.name}",
'path': 'scheduled_action',
'func': 'action_code',
'line': '69',
})
else:
product.write({'website_published': True})
env['ir.logging'].create({
'name': 'Product Published',
'type': 'server',
'level': 'info',
'dbname': env.cr.dbname,
'message': f"Published product: {product.name}",
'path': 'scheduled_action',
'func': 'action_code',
'line': '77',
})

Note i tried to change from

`website_published`

to `is_published`

as Nazzun suggested but for some reason it is still not working.

Thank you.

Jaideep

Your comment
>>>I attempted to use a Scheduled Action to automatically "unpublish" any menu items that do not meet the 48-hour rule, while keeping those that do meet the rule published.<<<

My question was precisely this, can a customer NOT place an order on a Wednesday for the following Monday? Or for that matter a week Wednesday.

If your actions unpublish the available menu how will they be able to select? Additionally, how are you capturing the date for which the customer is placing the order?

Zuhair
著作者

My Approach:

1. Ordering Restriction and Availability: The goal is for customers to place orders at least 48 hours in advance. For instance, if a user wants to order a sandwich for Monday, they should not be able to do so on the same Monday. However, the same sandwich should still be available for ordering on any day from Tuesday to Saturday for the next Monday. This rule should apply consistently across all menu items based on their preparation day.

My approach was to unpublished the menu items from the website only 48 hours before their preparation day. Once the preparation day passes, the items should be republished and available again for the next week’s ordering.

The challenge here is to ensure that the products are only temporarily unavailable during the 48-hour cutoff period but otherwise available for pre-order for all other future dates.

2. Capturing the Order Date: For capturing the date, I plan to have the system take the actual date on which the order is placed. The customer’s choice of preparation day will determine when the item is available for fulfillment.

3. Request for Help:

Is this the right? Or is there a better way to implement this 48-hour ordering restriction while maintaining the smooth availability of menu items for future orders? I am especially concerned about ensuring that the temporary unpublishing and republishing of menu items is handled correctly without affecting the customer’s ability to place future orders.

Thank you.

アバター
Nazzun Hanif Ahsani
最善の回答

Hello,

i think you can approach it using Odoo Studio and Scheduled Action.

  1. First create a column using Odoo Studio for the scheduled active date​ for the product available in the chart
  2. Second create a Scheduled Action to run every 5 menit, to check if the product hit scheduled active date​, then change the product state from archive into active
0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Ecommerce sales with regular grouped payment by bank transfer on invoices only
sales ecommerce website
アバター
0
2月 25
1429
Use eCommerce for selling licences 解決済
sales customizing ecommerce website
アバター
アバター
アバター
3
12月 20
4966
Tax is Not Being Applied on Website Sales in Odoo 18 解決済
sales ecommerce taxes receivables website
アバター
1
9月 25
2720
How to Set Up Manufacturing for Products Without Stock After Website Orders Odoo v17 enterprise 解決済
sales manufacturing ecommerce website maketoorder
アバター
アバター
1
12月 24
1961
Product bundle - create 'product' with individual products to create a hamper / bundle
sales ecommerce products website bundleproduct
アバター
アバター
1
6月 25
2310
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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