diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-05-31 15:29:08 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-05-31 15:29:08 +0700 |
| commit | 1df0e8445f89f2be188a6a2dae54d044288a756c (patch) | |
| tree | 66a533ae37b35e57b1409840124782a683b03dd3 /fixco_api | |
| parent | a91a0009ffd03e99b91c4cb441a867552b042d14 (diff) | |
refactor some information after success
Diffstat (limited to 'fixco_api')
| -rw-r--r-- | fixco_api/controllers/api_v1/sale.py | 19 | ||||
| -rw-r--r-- | fixco_api/models/sale.py | 5 |
2 files changed, 18 insertions, 6 deletions
diff --git a/fixco_api/controllers/api_v1/sale.py b/fixco_api/controllers/api_v1/sale.py index 2741897..2f38350 100644 --- a/fixco_api/controllers/api_v1/sale.py +++ b/fixco_api/controllers/api_v1/sale.py @@ -147,7 +147,11 @@ class Sales(controller.Controller): request.env['sale.order.line'].create(param_line) sale_order.action_confirm() return { - 'status': 'success', 'message': sale_order.name + 'status': 'success', + 'id': sale_order.id, + 'name': sale_order.name, + 'ref': sale_order.client_order_ref, + 'state': sale_order.state } @http.route(prefix + 'do/confirm', auth='public', methods=['POST', 'OPTIONS'], csrf=False) @@ -164,21 +168,28 @@ class Sales(controller.Controller): sales = request.env['sale.order'].search(query) data = [] + data_picking = [] for sale in sales: picking_ids = sale.picking_ids - reserved = validated = False + # 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_picking.append({ + 'id': picking.id, + 'name': picking.name, + 'state': picking.state, + 'reserved': reserved, + 'validated': str(validated) + }) data.append({ 'id': sale.id, 'name': sale.name, 'ref': sale.client_order_ref, - 'reserved': reserved, - 'validated': str(validated) + 'pickings': data_picking }) return self.response(data) diff --git a/fixco_api/models/sale.py b/fixco_api/models/sale.py index b7f404c..198689a 100644 --- a/fixco_api/models/sale.py +++ b/fixco_api/models/sale.py @@ -37,8 +37,9 @@ class SaleOrder(models.Model): for invoice in invoices: invoice.action_post() data.append({ - 'invoice_id': invoice.id, - 'invoice': invoice.name, + 'id': invoice.id, + 'name': invoice.name, + 'ref': invoice.ref, 'state': invoice.state }) return data |
