Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

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

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
salesecommercewebsitescheduledactionodooV17
3 Replies
2473 Rodiniai
Portretas
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
Portretas
Atmesti
Zuhair
Autorius

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

Portretas
Jaideep
Best Answer

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
Portretas
Atmesti
Zuhair
Autorius

Okay I will try it. thank you

Portretas
Zuhair
Autorius Best Answer

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
Portretas
Atmesti
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
Autorius

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

Zuhair
Autorius

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
Autorius

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
Autorius

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
Autorius

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.

Portretas
Nazzun Hanif Ahsani
Best Answer

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Ecommerce sales with regular grouped payment by bank transfer on invoices only
sales ecommerce website
Portretas
0
vas. 25
1435
Use eCommerce for selling licences Solved
sales customizing ecommerce website
Portretas
Portretas
Portretas
3
gruod. 20
4970
Tax is Not Being Applied on Website Sales in Odoo 18 Solved
sales ecommerce taxes receivables website
Portretas
1
rugs. 25
2725
How to Set Up Manufacturing for Products Without Stock After Website Orders Odoo v17 enterprise Solved
sales manufacturing ecommerce website maketoorder
Portretas
Portretas
1
gruod. 24
1963
Product bundle - create 'product' with individual products to create a hamper / bundle
sales ecommerce products website bundleproduct
Portretas
Portretas
1
birž. 25
2314
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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