Feat: Add enpoints SaleOrder
This commit is contained in:
@@ -16,8 +16,19 @@ post_sale_order = requests.post(
|
||||
'Authorization': f'bearer {key}',
|
||||
}, data=json.dumps({
|
||||
"party": 2573,
|
||||
"pickup_location": 'on_site'
|
||||
"pickup_location": 'on_site',
|
||||
"lines": [[
|
||||
"create", [{
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}]]]
|
||||
})
|
||||
)
|
||||
|
||||
get_sale_order = requests.get(
|
||||
base_url + '/order/1',
|
||||
headers={
|
||||
'Authorization': f'bearer {key}',
|
||||
})
|
||||
|
||||
pudb.set_trace()
|
||||
|
||||
@@ -30,15 +30,18 @@ class SaleOrderApiRouteTestCase(RouteTestCase):
|
||||
Product = pool.get('product.product')
|
||||
Uom = pool.get('product.uom')
|
||||
Application = pool.get('res.user.application')
|
||||
|
||||
Application(
|
||||
key=self.key,
|
||||
user=1,
|
||||
application='sale_order',
|
||||
state='validated').save()
|
||||
state='validated'
|
||||
).save()
|
||||
|
||||
self.unit = Uom.search([('name', '=', 'Unit')])[0].id
|
||||
self.productTemplate, = ProductTemplate.create([{
|
||||
'name': 'Product',
|
||||
'default_uom': Uom.search([('name', '=', 'Unit')])[0].id,
|
||||
'default_uom': self.unit,
|
||||
}])
|
||||
self.product, = Product.create([
|
||||
{'template': self.productTemplate.id}
|
||||
@@ -56,7 +59,47 @@ class SaleOrderApiRouteTestCase(RouteTestCase):
|
||||
'Authorization': f'bearer {self.key}',
|
||||
}, data=json.dumps({
|
||||
"party": self.party.id,
|
||||
"pickup_location": 'on_site'
|
||||
"pickup_location": 'on_site',
|
||||
"lines": [[
|
||||
"create", [{
|
||||
"product": self.product.id,
|
||||
"unit": self.unit,
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}]
|
||||
]]
|
||||
}))
|
||||
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
def test_get_sale_orders(self):
|
||||
client = self.client()
|
||||
|
||||
order = client.post(
|
||||
f'/{self.db_name}/sale_order/order',
|
||||
headers={
|
||||
'Authorization': f'bearer {self.key}',
|
||||
}, data=json.dumps({
|
||||
"party": self.party.id,
|
||||
"pickup_location": 'on_site',
|
||||
"lines": [[
|
||||
"create", [{
|
||||
"product": self.product.id,
|
||||
"unit": self.unit,
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}]
|
||||
]]
|
||||
}))
|
||||
|
||||
response = client.get(
|
||||
f'/{self.db_name}/sale_order/order/{order.text}',
|
||||
headers={
|
||||
'Authorization': f'bearer {self.key}',
|
||||
})
|
||||
|
||||
orders = json.loads(
|
||||
response.get_data().decode())
|
||||
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
self.assertEqual(len(orders), 1)
|
||||
|
||||
Reference in New Issue
Block a user