From 1c5eaef25d30a2f760afaad4f5329a87cc4da3c1 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 26 Feb 2025 16:30:42 +0700 Subject: CR repeat order --- indoteknik_api/models/sale_order.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indoteknik_api/models') diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 727379c5..0b9881ec 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -104,11 +104,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 -- cgit v1.2.3