summaryrefslogtreecommitdiff
path: root/indoteknik_api/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/models')
-rw-r--r--indoteknik_api/models/sale_order.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py
index 45461974..5427ed07 100644
--- a/indoteknik_api/models/sale_order.py
+++ b/indoteknik_api/models/sale_order.py
@@ -20,12 +20,14 @@ class SaleOrder(models.Model):
'amount_untaxed': sale_order.amount_untaxed,
'amount_tax': sale_order.amount_tax,
'amount_total': sale_order.grand_total,
+ 'amount_discount': sale_order.amount_voucher_shipping_disc,
'purchase_order_name': sale_order.partner_purchase_order_name or sale_order.client_order_ref,
'purchase_order_file': True if sale_order.partner_purchase_order_file else False,
'invoice_count': sale_order.invoice_count,
'status': 'draft',
'approval_step': APPROVAL_STEP[sale_order.web_approval] if sale_order.web_approval else 0,
'date_order': self.env['rest.api'].datetime_to_str(sale_order.date_order, '%d/%m/%Y %H:%M:%S'),
+ 'payment_type': sale_order.payment_type,
'pickings': []
}
for picking in sale_order.picking_ids:
@@ -116,11 +118,28 @@ class SaleOrder(models.Model):
data.update(data_with_detail)
else:
data_with_detail = {
+ 'products': [],
'address': {
'customer': res_users.api_address_response(sale_order.partner_id),
}
}
data.update(data_with_detail)
+ for line in sale_order.order_line:
+ product = self.env['product.product'].api_single_response(line.product_id)
+ product['price'] = {
+ 'price': line.price_unit,
+ 'discount_percentage': line.discount,
+ 'price_discount': line.price_reduce_taxexcl,
+ 'subtotal': line.price_subtotal
+ }
+ product['quantity'] = line.product_uom_qty
+ product['available_quantity'] = line.product_available_quantity
+ for data_v2 in sale_order.fulfillment_line_v2:
+ product_v2 = self.env['product.product'].api_single_response(data_v2.product_id)
+ if product['id'] == product_v2['id']:
+ product['so_qty'] = data_v2.so_qty
+ product['reserved_stock_qty'] = data_v2.reserved_stock_qty
+ data_with_detail['products'].append(product)
return data