trytondo-sale_order/routes.py
2025-02-11 18:13:51 -05:00

28 lines
721 B
Python

from trytond.wsgi import app
from trytond.transaction import Transaction
from trytond.protocols.wrappers import (
with_pool,
with_transaction,
user_application,
allow_null_origin)
import json
sale_order_application = user_application('sale_order')
@app.route(
'/<database_name>/sale_order/order', methods=['POST'])
@allow_null_origin
@with_pool
@with_transaction()
@sale_order_application
def order(request, pool):
Order = pool.get('sale.order')
with Transaction().set_context(
{'company': 1, 'locations': [3]}):
if request.method == 'POST':
data = json.loads(
request.get_data().decode()
)
Order.create([dict(data)])