Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | b896b44023 | 
| @@ -1,13 +1,11 @@ | |||||||
| from trytond.pool import Pool | from trytond.pool import Pool | ||||||
| from . import sale_order, user, routes | from . import sale_order | ||||||
|  |  | ||||||
| __all__ = [ | __all__ = ['register'] | ||||||
|     'register', 'routes'] |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def register(): | def register(): | ||||||
|     Pool.register( |     Pool.register( | ||||||
|         user.UserApplication, |  | ||||||
|         sale_order.SaleOrder, |         sale_order.SaleOrder, | ||||||
|         sale_order.OrderLine, |         sale_order.OrderLine, | ||||||
|         module='sale_order', type_='model') |         module='sale_order', type_='model') | ||||||
|   | |||||||
							
								
								
									
										165
									
								
								routes.py
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								routes.py
									
									
									
									
									
								
							| @@ -1,165 +0,0 @@ | |||||||
| from trytond.wsgi import app |  | ||||||
| from trytond.transaction import Transaction |  | ||||||
| from trytond.protocols.wrappers import ( |  | ||||||
|     with_pool, |  | ||||||
|     with_transaction, |  | ||||||
|     user_application, |  | ||||||
|     allow_null_origin, |  | ||||||
| ) |  | ||||||
| import json |  | ||||||
|  |  | ||||||
| sale_order_application = user_application("sale_order") |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route( |  | ||||||
|     "/<database_name>/sale_order/associate_party/<contact_method>", methods=[ |  | ||||||
|         "GET"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def get_associate_party(request, pool, contact_method: str): |  | ||||||
|     ContactMechanism = pool.get("party.contact_mechanism") |  | ||||||
|     associate_contact_method = ContactMechanism.search( |  | ||||||
|         [("value", "ilike", contact_method)] |  | ||||||
|     ) |  | ||||||
|     if associate_contact_method: |  | ||||||
|         response_data = { |  | ||||||
|             "id": associate_contact_method[0].id, |  | ||||||
|             "associate_party": associate_contact_method[0].party.id, |  | ||||||
|             "status": "success", |  | ||||||
|             "type": associate_contact_method[0].type, |  | ||||||
|             "message": "Associate Party found", |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return json.dumps(response_data), 200 |  | ||||||
|     response_data = { |  | ||||||
|         "id": None, |  | ||||||
|         "associate_party": None, |  | ||||||
|         "status": "success", |  | ||||||
|         "type": None, |  | ||||||
|         "message": "Associate Party not found", |  | ||||||
|     } |  | ||||||
|     return json.dumps(response_data), 404 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route("/<database_name>/sale_order/order/<order>", methods=["GET"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def get_order(request, pool, order: int): |  | ||||||
|     Order = pool.get("sale.order") |  | ||||||
|     with Transaction().set_context({"company": 1, "locations": [3]}): |  | ||||||
|         if request.method == "GET": |  | ||||||
|             orders = Order.search_read( |  | ||||||
|                 [("id", "=", order)], |  | ||||||
|                 order=[("id", "ASC")], |  | ||||||
|                 fields_names=["id", "party", "lines"], |  | ||||||
|             ) |  | ||||||
|  |  | ||||||
|             return orders |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route("/<database_name>/sale_order/order", methods=["POST"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def post_order(request, pool): |  | ||||||
|     Order = pool.get("sale.order") |  | ||||||
|     with Transaction().set_context({"company": 1, "locations": [3]}): |  | ||||||
|         if request.method == "POST": |  | ||||||
|             data = json.loads(request.get_data().decode()) |  | ||||||
|             (order,) = Order.create([dict(data)]) |  | ||||||
|  |  | ||||||
|             response_data = { |  | ||||||
|                 "id": order.id, |  | ||||||
|                 "status": "success", |  | ||||||
|                 "message": "Order created successfully", |  | ||||||
|             } |  | ||||||
|             return json.dumps(response_data), 201 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route("/<database_name>/sale_order/<order>/order_line", methods=["POST"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def order_line(request, pool, order: int): |  | ||||||
|     OrderLine = pool.get("order.line") |  | ||||||
|     with Transaction().set_context({"company": 1, "locations": [3]}): |  | ||||||
|         if request.method == "POST": |  | ||||||
|             data = json.loads(request.get_data().decode()) |  | ||||||
|  |  | ||||||
|             order_lines = OrderLine.create([dict(data)]) |  | ||||||
|  |  | ||||||
|             response_data = { |  | ||||||
|                 "order_lines": [line.id for line in order_lines], |  | ||||||
|                 "status": "success", |  | ||||||
|                 "message": "Order lines created successfully", |  | ||||||
|             } |  | ||||||
|             return json.dumps(response_data), 201 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route("/<database_name>/sale_order/confirm_order/<order>", methods=[ |  | ||||||
|     "POST"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def confirm_order(request, pool, order: int): |  | ||||||
|     Order = pool.get("sale.order") |  | ||||||
|     if request.method == "POST": |  | ||||||
|         (order,) = Order.search([("id", "=", order)]) |  | ||||||
|  |  | ||||||
|         Order.confirm([order]) |  | ||||||
|  |  | ||||||
|         response_data = { |  | ||||||
|             "id": order.id, |  | ||||||
|             "status": "success", |  | ||||||
|             "state": order.state, |  | ||||||
|             "message": "Order confirm successfully", |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return json.dumps(response_data), 201 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route("/<database_name>/sale_order/<order>", methods=["DELETE"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def delete_order(request, pool, order: int): |  | ||||||
|     Order = pool.get("sale.order") |  | ||||||
|     if request.method == "DELETE": |  | ||||||
|         (order,) = Order.search([("id", "=", order)]) |  | ||||||
|         order.delete([order]) |  | ||||||
|  |  | ||||||
|         response_data = { |  | ||||||
|             "id": order.id, |  | ||||||
|             "status": "success", |  | ||||||
|             "message": "Order deleted successfully", |  | ||||||
|         } |  | ||||||
|         return json.dumps(response_data), 200 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @app.route( |  | ||||||
|     "/<database_name>/sale_order/<order>/order_line/<order_line>", methods=[ |  | ||||||
|         "DELETE"]) |  | ||||||
| @allow_null_origin |  | ||||||
| @with_pool |  | ||||||
| @with_transaction() |  | ||||||
| @sale_order_application |  | ||||||
| def delete_order_line(request, pool, order: int, order_line: int): |  | ||||||
|     OrderLine = pool.get("order.line") |  | ||||||
|     if request.method == "DELETE": |  | ||||||
|         (order_line,) = OrderLine.search([("id", "=", order_line)]) |  | ||||||
|         order_line.delete([order_line]) |  | ||||||
|  |  | ||||||
|         response_data = { |  | ||||||
|             "id": order_line.id, |  | ||||||
|             "status": "success", |  | ||||||
|             "message": "Order line deleted successfully", |  | ||||||
|         } |  | ||||||
|         return json.dumps(response_data), 200 |  | ||||||
| @@ -33,15 +33,12 @@ class SaleOrder (Workflow, ModelView, ModelSQL): | |||||||
|     party = fields.Many2One( |     party = fields.Many2One( | ||||||
|         'party.party', "Party", required=True, states=_states) |         'party.party', "Party", required=True, states=_states) | ||||||
|     order_address = fields.Many2One( |     order_address = fields.Many2One( | ||||||
|         'party.address', 'Address', states=_states) |         'party.address', 'Address', required=True, states=_states) | ||||||
|     pickup_location = fields.Selection([ |     pickup_location = fields.Selection([ | ||||||
|         ("on_site", "On Site"), |         ("on_site", "On Site"), | ||||||
|         ("at_home", "At Home")], 'Pickup Location', states=_states) |         ("at_home", "At Home")], 'Pickup Location', states=_states) | ||||||
|     order_mobile = fields.Char('Mobile', states=_states) |     order_mobile = fields.Char('Mobile', states=_states) | ||||||
|     date = fields.Date("Date", required=True, states={ |     date = fields.Date("Date", required=True, states=_states) | ||||||
|         'readonly': Eval('state').in_(['confirmed', 'done']), |  | ||||||
|         'required': Eval('pickup_location') == 'at_home' |  | ||||||
|     }) |  | ||||||
|     lines = fields.One2Many( |     lines = fields.One2Many( | ||||||
|         'order.line', 'order', 'Lines', states=_states) |         'order.line', 'order', 'Lines', states=_states) | ||||||
|     total_order = fields.Function( |     total_order = fields.Function( | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							| @@ -107,7 +107,7 @@ setup(name=name, | |||||||
|         ], |         ], | ||||||
|     license='GPL-3', |     license='GPL-3', | ||||||
|     python_requires='>=3.8', |     python_requires='>=3.8', | ||||||
|     # install_requires=requires, |     install_requires=requires, | ||||||
|     extras_require={ |     extras_require={ | ||||||
|         'test': tests_require, |         'test': tests_require, | ||||||
|         }, |         }, | ||||||
|   | |||||||
| @@ -1,75 +0,0 @@ | |||||||
| import pudb |  | ||||||
| import requests |  | ||||||
| import json |  | ||||||
|  |  | ||||||
|  |  | ||||||
| url = "http://localhost:8000" |  | ||||||
| key = ( |  | ||||||
|     "f46f14d77db646b0ac0802e7bdab9cbb" |  | ||||||
|     + ("1d53ad96387242e1918c45854dce5238707fed31daa64cab88569d119512153") |  | ||||||
|     + ("64db6ced393b44f198ab9a3967b6f4ddf") |  | ||||||
| ) |  | ||||||
| db = "tryton" |  | ||||||
| application_name = "sale_order" |  | ||||||
| base_url = "{}/{}/{}".format(url, db, application_name) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| get_associate_party = requests.get( |  | ||||||
|     base_url + "/associate_party/alejandro.ayala@gmail.com", |  | ||||||
|     headers={ |  | ||||||
|         "Authorization": f"bearer {key}", |  | ||||||
|     }, |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| post_sale_order = requests.post( |  | ||||||
|     base_url + "/order", |  | ||||||
|     headers={ |  | ||||||
|         "Authorization": f"bearer {key}", |  | ||||||
|     }, |  | ||||||
|     data=json.dumps( |  | ||||||
|         { |  | ||||||
|             "party": 2573, |  | ||||||
|             "pickup_location": "on_site", |  | ||||||
|             "lines": [ |  | ||||||
|                 [ |  | ||||||
|                     "create", |  | ||||||
|                     [ |  | ||||||
|                         { |  | ||||||
|                             "product": "1", |  | ||||||
|                             "unit": "1", |  | ||||||
|                             "quantity": "5", |  | ||||||
|                             "unitprice": "10" |  | ||||||
|                         }], |  | ||||||
|                 ] |  | ||||||
|             ], |  | ||||||
|         } |  | ||||||
|     ), |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| order = json.loads(json.loads(post_sale_order.text)[0]).get("id") |  | ||||||
|  |  | ||||||
| get_sale_order = requests.get( |  | ||||||
|     base_url + "/order/1", |  | ||||||
|     headers={ |  | ||||||
|         "Authorization": f"bearer {key}", |  | ||||||
|     }, |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| post_line_order = requests.post( |  | ||||||
|     base_url.replace( |  | ||||||
|         "sale_don_confiao", "sale_order") + f"/{order}/order_line", |  | ||||||
|     headers={ |  | ||||||
|         "Authorization": f"bearer {key}", |  | ||||||
|     }, |  | ||||||
|     data=json.dumps( |  | ||||||
|         { |  | ||||||
|             "order": order, |  | ||||||
|             "product": "1", |  | ||||||
|             "unit": "1", |  | ||||||
|             "quantity": "5", |  | ||||||
|             "unitprice": "10", |  | ||||||
|         } |  | ||||||
|     ), |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| pudb.set_trace() |  | ||||||
| @@ -1,291 +0,0 @@ | |||||||
| from trytond.tests.test_tryton import RouteTestCase |  | ||||||
| from trytond.pool import Pool |  | ||||||
| from http import HTTPStatus |  | ||||||
| import uuid |  | ||||||
| import json |  | ||||||
| from trytond.tests.test_tryton import DB_NAME |  | ||||||
| from trytond.transaction import Transaction |  | ||||||
| from trytond.modules.company.tests.tools import create_company |  | ||||||
| from trytond.tests.tools import activate_modules |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class SaleOrderApiRouteTestCase(RouteTestCase): |  | ||||||
|     """Sale Order API Routes""" |  | ||||||
|  |  | ||||||
|     module = "sale_order" |  | ||||||
|  |  | ||||||
|     key = uuid.uuid4().hex |  | ||||||
|  |  | ||||||
|     @classmethod |  | ||||||
|     def setUpClass(cls): |  | ||||||
|         activate_modules("sale_order", create_company) |  | ||||||
|  |  | ||||||
|     def setUp(self): |  | ||||||
|         pool = Pool(DB_NAME) |  | ||||||
|         transaction = Transaction().start( |  | ||||||
|             DB_NAME, 0, _lock_tables=["product_product"]) |  | ||||||
|         with transaction: |  | ||||||
|             Party = pool.get("party.party") |  | ||||||
|             ProductTemplate = pool.get("product.template") |  | ||||||
|             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() |  | ||||||
|  |  | ||||||
|             self.unit = Uom.search([("name", "=", "Unit")])[0].id |  | ||||||
|             (self.productTemplate,) = ProductTemplate.create( |  | ||||||
|                 [ |  | ||||||
|                     { |  | ||||||
|                         "name": "Product", |  | ||||||
|                         "default_uom": self.unit, |  | ||||||
|                     } |  | ||||||
|                 ] |  | ||||||
|             ) |  | ||||||
|             (self.product,) = Product.create([ |  | ||||||
|                 {"template": self.productTemplate.id} |  | ||||||
|             ]) |  | ||||||
|  |  | ||||||
|             (self.party,) = Party.create( |  | ||||||
|                 [ |  | ||||||
|                     { |  | ||||||
|                         "name": "Dunkan", |  | ||||||
|                         "contact_mechanisms": [[ |  | ||||||
|                             "create", [{ |  | ||||||
|                                 "type": "mobile", |  | ||||||
|                                 "value": "3102223334"}]] |  | ||||||
|                         ], |  | ||||||
|                     } |  | ||||||
|                 ] |  | ||||||
|             ) |  | ||||||
|  |  | ||||||
|     def test_post_sale_order(self): |  | ||||||
|         client = self.client() |  | ||||||
|         response = 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", |  | ||||||
|                                 } |  | ||||||
|                             ], |  | ||||||
|                         ] |  | ||||||
|                     ], |  | ||||||
|                 } |  | ||||||
|             ), |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         self.assertEqual(response.status_code, HTTPStatus.OK) |  | ||||||
|  |  | ||||||
|     def test_get_sale_orders(self): |  | ||||||
|         client = self.client() |  | ||||||
|  |  | ||||||
|         order = json.loads( |  | ||||||
|             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", |  | ||||||
|                                     } |  | ||||||
|                                 ], |  | ||||||
|                             ] |  | ||||||
|                         ], |  | ||||||
|                     } |  | ||||||
|                 ), |  | ||||||
|             ) |  | ||||||
|             .get_data() |  | ||||||
|             .decode() |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         response = client.get( |  | ||||||
|             f"/{self.db_name}/sale_order/order/{json.loads(order[0])['id']}", |  | ||||||
|             headers={ |  | ||||||
|                 "Authorization": f"bearer {self.key}", |  | ||||||
|             }, |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         self.assertEqual(response.status_code, HTTPStatus.OK) |  | ||||||
|         self.assertEqual(len(json.loads(response.text)), 1) |  | ||||||
|  |  | ||||||
|     def test_confirm_sale_order(self): |  | ||||||
|         client = self.client() |  | ||||||
|  |  | ||||||
|         order = json.loads( |  | ||||||
|             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", |  | ||||||
|                                     } |  | ||||||
|                                 ], |  | ||||||
|                             ] |  | ||||||
|                         ], |  | ||||||
|                     } |  | ||||||
|                 ), |  | ||||||
|             ) |  | ||||||
|             .get_data() |  | ||||||
|             .decode() |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         confirm_url = f"/{self.db_name}/sale_order/confirm_order/" |  | ||||||
|         order_id = json.loads(order[0])["id"] |  | ||||||
|         response = client.post( |  | ||||||
|             f"{confirm_url}{order_id}", |  | ||||||
|             headers={ |  | ||||||
|                 "Authorization": f"bearer {self.key}", |  | ||||||
|             }, |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         response_data = json.loads(json.loads(response.text)[0]) |  | ||||||
|  |  | ||||||
|         self.assertEqual(response.status_code, HTTPStatus.OK) |  | ||||||
|         self.assertEqual(response_data["state"], "confirmed") |  | ||||||
|  |  | ||||||
|     def test_post_line_order(self): |  | ||||||
|         client = self.client() |  | ||||||
|  |  | ||||||
|         response = 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"}), |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         order = json.loads(json.loads(response.text)[0]).get("id") |  | ||||||
|  |  | ||||||
|         response = client.post( |  | ||||||
|             f"/{self.db_name}/sale_order/{order}/order_line", |  | ||||||
|             headers={ |  | ||||||
|                 "Authorization": f"bearer {self.key}", |  | ||||||
|             }, |  | ||||||
|             data=json.dumps( |  | ||||||
|                 { |  | ||||||
|                     "order": order, |  | ||||||
|                     "product": self.product.id, |  | ||||||
|                     "unit": self.unit, |  | ||||||
|                     "quantity": "5", |  | ||||||
|                     "unitprice": "10", |  | ||||||
|                 } |  | ||||||
|             ), |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         self.assertEqual(response.status_code, HTTPStatus.OK) |  | ||||||
|  |  | ||||||
|     def test_get_party_asociate_contact_method(self): |  | ||||||
|         """ |  | ||||||
|         Recibe un numbero de telofono y retorna el tercero asociado |  | ||||||
|         a este numero de telofono. |  | ||||||
|         Args: |  | ||||||
|             phone: string |  | ||||||
|         Return: |  | ||||||
|             party: int |  | ||||||
|         """ |  | ||||||
|         client = self.client() |  | ||||||
|         response = client.get( |  | ||||||
|             f"/{self.db_name}/sale_order/associate_party/3102223334", |  | ||||||
|             headers={ |  | ||||||
|                 "Authorization": f"bearer {self.key}", |  | ||||||
|             }, |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         self.assertEqual(response.status_code, HTTPStatus.OK) |  | ||||||
|         self.assertEqual(json.loads(response.text)[1], 200) |  | ||||||
|         self.assertEqual(json.loads( |  | ||||||
|             json.loads( |  | ||||||
|                 response.text |  | ||||||
|             )[0])["associate_party"], 2) |  | ||||||
|  |  | ||||||
|     def test_create_contact_method(self): |  | ||||||
|         """ |  | ||||||
|         Crea un tercero asociandolo a un metodo de contacto |  | ||||||
|  |  | ||||||
|         Args: |  | ||||||
|             email, phone : string |  | ||||||
|         Return: |  | ||||||
|             party: int |  | ||||||
|         """ |  | ||||||
|  |  | ||||||
|     def test_delete_sale(self): |  | ||||||
|         client = self.client() |  | ||||||
|         order = json.loads( |  | ||||||
|             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", |  | ||||||
|                                     } |  | ||||||
|                                 ], |  | ||||||
|                             ] |  | ||||||
|                         ], |  | ||||||
|                     } |  | ||||||
|                 ), |  | ||||||
|             ) |  | ||||||
|             .get_data() |  | ||||||
|             .decode() |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         order_id = json.loads(order[0])["id"]  # Get the id of the order |  | ||||||
|         delete_order = client.delete( |  | ||||||
|             f"/{self.db_name}/sale_order/{order_id}", |  | ||||||
|             headers={"Authorization": f"bearer {self.key}"}, |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         self.assertEqual(delete_order.status_code, HTTPStatus.OK) |  | ||||||
|         self.assertEqual(json.loads(delete_order.text)[1], 200) |  | ||||||
							
								
								
									
										14
									
								
								user.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								user.py
									
									
									
									
									
								
							| @@ -1,14 +0,0 @@ | |||||||
| # This file is part of Tryton.  The COPYRIGHT file at the top level of |  | ||||||
| # this repository contains the full copyright notices and license terms. |  | ||||||
| from trytond.pool import PoolMeta |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class UserApplication(metaclass=PoolMeta): |  | ||||||
|     __name__ = 'res.user.application' |  | ||||||
|  |  | ||||||
|     @classmethod |  | ||||||
|     def __setup__(cls): |  | ||||||
|         super(UserApplication, cls).__setup__() |  | ||||||
|         cls.application.selection.append( |  | ||||||
|             ('sale_order', 'SaleOrder') |  | ||||||
|         ) |  | ||||||
		Reference in New Issue
	
	Block a user