diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-06 11:17:53 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-06 11:17:53 +0700 |
| commit | 2fa15330d221cb68e5b9acdb4379aa82764f46f0 (patch) | |
| tree | 0139db5bc9605080a38e23ed8733cf423b4b9657 /indoteknik_api/controllers/api_v1 | |
| parent | 12b015dc599f3a3876b10171bcec95e8aba7683c (diff) | |
Update flashsale calculation price for web and odoo
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/sale_order.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index b17c2231..8209c751 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -302,18 +302,19 @@ class SaleOrder(controller.Controller): source = params['value']['source'] carts = user_cart.get_product_by_user(user_id=user_id, selected=True, source=source) - order_lines = [] promotions = [] for cart in carts: if cart['cart_type'] == 'product': - order_lines.append({ + order_line = request.env['sale.order.line'].create({ 'company_id': 1, 'order_id': sale_order.id, - 'price_unit': cart['price']['price'], - 'discount': cart['price']['discount_percentage'], 'product_id': cart['id'], 'product_uom_qty': cart['quantity'] }) + order_line.product_id_change() + order_line.onchange_vendor_id() + order_line.price_unit = cart['price']['price'] + order_line.discount = cart['price']['discount_percentage'] elif cart['cart_type'] == 'promotion': promotions.append({ 'order_id': sale_order.id, @@ -321,9 +322,6 @@ class SaleOrder(controller.Controller): 'quantity': cart['quantity'] }) - lines = request.env['sale.order.line'].create(order_lines) - for line in lines: - line.product_id_change() request.env['sale.order.promotion'].create(promotions) if len(promotions) > 0: |
