Feat: GET search_products by name

This commit is contained in:
2025-01-11 15:13:31 -05:00
parent 00c7052838
commit 04d76ee7d9
2 changed files with 34 additions and 5 deletions

View File

@@ -98,11 +98,11 @@ class DonConfiaoApiRouteTestCase(
ProductTemplate = pool.get('product.template')
Product = pool.get('product.product')
Uom = pool.get('product.uom')
template, = ProductTemplate.create([
{'name': 'Product',
'default_uom': Uom.search([('name', '=', 'Unit')])[0].id
}
])
template, = ProductTemplate.create([{
'name': 'Product',
'default_uom': Uom.search([('name', '=', 'Unit')])[0].id,
'list_price': 5000
}])
Product.create([{'template': template.id}])
@@ -118,6 +118,20 @@ class DonConfiaoApiRouteTestCase(
self.assertEqual(response.status_code, HTTPStatus.OK)
self.assertEqual(len(products), 1)
def test_search_products(self):
client = self.client()
response = client.get(
f'/{self.db_name}/sale_don_confiao/search_products/product',
headers={
'Authorization': f'bearer {self.key}',
})
products = json.loads(
response.get_data().decode())
raise Exception(products)
self.assertEqual(response.status_code, HTTPStatus.OK)
def test_get_sales(self):
pool = Pool(DB_NAME)
transaction = Transaction().start(DB_NAME, user=0, _lock_tables=[