diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-06-15 11:54:20 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-06-15 11:54:20 +0700 |
| commit | 64507a0c199721fee5e3fc8c808adec5a3ee6a5d (patch) | |
| tree | 4c9973ff4ee51c5adb88be97e890682c7cb77c03 | |
| parent | 1edd55b85c24b8f9a36349fa34793cb65a554851 (diff) | |
revert code nathan
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index ea75539a..7e18bd8f 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -151,10 +151,11 @@ class PurchaseOrder(models.Model): self.order_line.unlink() for order_line in self.sale_order_id.order_line: if order_line.product_id.id and order_line.product_id.id not in products_exception: - qty_available = self.env['stock.quant'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_id', '=', "BU/Stock") - ], limit=1) + # qty_available = self.env['stock.quant'].search([ + # ('product_id', '=', order_line.product_id.id), + # ('location_id', '=', "BU/Stock") + # ], limit=1) + qty_available = order_line.product_id.virtual_available suggest = 'harus beli' if order_line.product_id.virtual_available > order_line.product_qty: suggest = 'masih cukup' @@ -163,10 +164,10 @@ class PurchaseOrder(models.Model): 'product_id': order_line.product_id.id, 'name': order_line.product_id.display_name, 'product_qty': order_line.product_qty, - 'qty_available_store': qty_available.available_quantity, + 'qty_available_store': qty_available, 'suggest': suggest, } - self.order_line.create(values) + self.env['purchase.order.line'].sudo().create(values) def compute_count_line_product(self): for order in self: |
