Fix: Routes

This commit is contained in:
Rodia 2025-01-17 00:12:05 -05:00
parent 9c738a75f4
commit 4f33143a36

View File

@ -45,12 +45,13 @@ def parties(request, pool):
@don_confiao_application
def party(request, pool, party: int):
Party = pool.get('party.party')
if request.method == 'GET':
parties = Party.search_read(
[('id', '=', party)],
order=[('id', 'ASC')],
fields_names=['id', 'name'])
return parties
with Transaction().set_context({'company': 1}):
if request.method == 'GET':
parties = Party.search_read([
('id', '=', int(party))],
order=[('id', 'ASC')],
fields_names=['id', 'name'])
return parties
@app.route('/<database_name>/sale_don_confiao/products', methods=['GET'])
@ -74,17 +75,18 @@ def products(request, pool):
@with_pool
@with_transaction()
@don_confiao_application
def search_products(request, pool, product_name):
Product = pool.get('product.product')
products = Product.search_read(
[('name', 'like', product_name)],
order=[('id', 'ASC')],
fields_names=[
'id', 'name', 'list_price',
'description', 'template.forecast_quantity'
])
def search_products(request, pool, product_name: str):
with Transaction().set_context({'company': 1}):
Product = pool.get('product.product')
products = Product.search_read(
[('name', 'ilike', f'%{product_name}%')],
order=[('id', 'ASC')],
fields_names=[
'id', 'name', 'list_price',
'description'
])
return products
return products
@app.route('/<database_name>/sale_don_confiao/sales', methods=['GET'])
@ -93,15 +95,10 @@ def search_products(request, pool, product_name):
@with_transaction()
@don_confiao_application
def sales(request, pool):
data = json.loads(
request.get_data().decode()
)
with Transaction().set_context(
{'company': data['company']}):
{'company': 1}):
Sale = pool.get('sale.sale')
sales = Sale.search_read([
# ('company', '=', data['company']),
# ('state', '=', 'draft')
], order=[
('id', 'ASC')
], fields_names=['id', 'party.name'])