summaryrefslogtreecommitdiff
path: root/fixco_api
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_api')
-rw-r--r--fixco_api/controllers/api_v1/sale.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/fixco_api/controllers/api_v1/sale.py b/fixco_api/controllers/api_v1/sale.py
index e2e9bdc..7096ccb 100644
--- a/fixco_api/controllers/api_v1/sale.py
+++ b/fixco_api/controllers/api_v1/sale.py
@@ -60,7 +60,7 @@ class Sales(controller.Controller):
@http.route(prefix + 'sale/update_shipper', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
- def cancel_sale_order(self, **kw):
+ def update_shipper_sale_order(self, **kw):
sale_id = int(kw.get('id', '0'))
ref = str(kw.get('ref', '0'))
shipper = str(kw.get('shipper', '0'))
@@ -148,3 +148,39 @@ class Sales(controller.Controller):
return {
'status': 'success', 'message': sale_order.name
}
+
+ @http.route(prefix + 'do/confirm', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
+ @controller.Controller.must_authorized()
+ def complete_delivery_order(self, **kw):
+ # stock_picking.action_assign
+ sale_id = int(kw.get('id', '0'))
+ ref = str(kw.get('ref', '0'))
+ if sale_id == 0 and ref == '0':
+ return self.response(code=500, description='Internal Server Error')
+ if sale_id > 0:
+ query = [('id', '=', sale_id)]
+ else:
+ query = [('client_order_ref', '=', ref)]
+
+ sales = request.env['sale.order'].search(query)
+ data = []
+ for sale in sales:
+ picking_ids = sale.picking_ids
+ reserved = validated = False
+ for picking in picking_ids:
+ reserved = picking.action_assign()
+ if reserved == True:
+ for line in picking.move_line_ids_without_package:
+ line.qty_done = line.product_uom_qty
+ validated = picking.button_validate()
+ data.append({
+ 'id': sale.id,
+ 'name': sale.name,
+ 'ref': sale.client_order_ref,
+ 'reserved': reserved,
+ 'validated': str(validated)
+ })
+ test = data
+ print(test)
+ return self.response(data)
+