Hi, I have created an action and generated a website URL. How can I pass parameters?
such as 127.0.0.1:61001/website/action/add_new_order_cron?order=xxxxxx
to execute python code:
model.add_new_order_cron(xxxxxx)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi, I have created an action and generated a website URL. How can I pass parameters?
such as 127.0.0.1:61001/website/action/add_new_order_cron?order=xxxxxx
to execute python code:
model.add_new_order_cron(xxxxxx)
Hello! It seems like you want to pass parameters to a Python function via a URL. This is typically done in web development using web frameworks like Flask or Django. Here’s a basic example using Flask:
from flask import Flask, request
app = Flask(__name__)
@app.route('/website/action/add_new_order_cron', methods=['GET'])
def add_new_order_cron():
order = request.args.get('order', default = None, type = str)
if order is not None:
# Assuming model is a global object and add_new_order_cron is a method in its class
model.add_new_order_cron(order)
return 'Order added successfully', 200
else:
return 'No order parameter provided', 400
if __name__ == '__main__':
app.run(host='127.0.0.1', port=61001)
In this code, request.args.get('order') gets the ‘order’ parameter from the URL. If the ‘order’ parameter is not provided in the URL, it returns None. You can replace None with any default value you want to use when the ‘order’ parameter is not provided.
Please note that you’ll need to have Flask installed in your Python environment. You can install it using pip:
pip install flask
Remember to replace model.add_new_order_cron(order) with your actual function call. Also, ensure that your server is properly secured and sanitized to prevent SQL injection or other forms of attacks.
Hi
Hope you are doing well
you can try model.add_new_order_cron(**xxxxxx) and now you can receive argument in xxxxxx . Only need to put ** before argument name
Hope this will help you
thanks
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Apr 24
|
1347 | ||
|
2
Oct 23
|
1961 | ||
|
1
Sep 23
|
1336 | ||
|
1
Sep 23
|
961 | ||
|
5
Jul 20
|
5273 |