52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
from trytond.wsgi import app
|
|
from trytond.protocols.wrappers import (
|
|
with_pool,
|
|
with_transaction,
|
|
user_application,
|
|
allow_null_origin)
|
|
import json
|
|
|
|
don_confiao_application = user_application(
|
|
'sale_don_confiao')
|
|
|
|
|
|
@app.route('/<database_name>/sale_don_confiao/parties', methods=[
|
|
'GET'])
|
|
@app.route('/<database_name>/sale_don_confiao/parties', methods=[
|
|
'POST'])
|
|
@allow_null_origin
|
|
@with_pool
|
|
@with_transaction()
|
|
@don_confiao_application
|
|
def parties(request, pool):
|
|
Party = pool.get('party.party')
|
|
if request.method == 'GET':
|
|
parties = Party.search_read(
|
|
[],
|
|
order=[('id', 'ASC')],
|
|
fields_names=['id', 'name'])
|
|
return parties
|
|
|
|
if request.method == 'POST':
|
|
data = json.loads(
|
|
request.get_data().decode()
|
|
)
|
|
|
|
party = Party()
|
|
party.name = data['name']
|
|
party.save()
|
|
|
|
|
|
@app.route('/<database_name>/sale_don_confiao/products', methods=['GET'])
|
|
@allow_null_origin
|
|
@with_pool
|
|
@with_transaction()
|
|
@don_confiao_application
|
|
def get_products(request, pool):
|
|
Product = pool.get('product.product')
|
|
products = Product.search_read(
|
|
[],
|
|
order=[('id', 'ASC')],
|
|
fields_names=['id', 'name'])
|
|
return products
|