Fix: Routes

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

View File

@ -45,9 +45,10 @@ def parties(request, pool):
@don_confiao_application
def party(request, pool, party: int):
Party = pool.get('party.party')
with Transaction().set_context({'company': 1}):
if request.method == 'GET':
parties = Party.search_read(
[('id', '=', party)],
parties = Party.search_read([
('id', '=', int(party))],
order=[('id', 'ASC')],
fields_names=['id', 'name'])
return parties
@ -74,14 +75,15 @@ def products(request, pool):
@with_pool
@with_transaction()
@don_confiao_application
def search_products(request, pool, product_name):
def search_products(request, pool, product_name: str):
with Transaction().set_context({'company': 1}):
Product = pool.get('product.product')
products = Product.search_read(
[('name', 'like', product_name)],
[('name', 'ilike', f'%{product_name}%')],
order=[('id', 'ASC')],
fields_names=[
'id', 'name', 'list_price',
'description', 'template.forecast_quantity'
'description'
])
return products
@ -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'])