summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-06-19 04:24:17 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-06-19 04:24:17 +0000
commitb7c98087933cde132a741d5676e1309a0d5ab445 (patch)
tree86218296b1936bf70336c7bb1360e6bca9a9ef7f /indoteknik_custom/models/purchase_order.py
parentaab8e1f3e1c6b05e7dc57060efd1f9fe586d092d (diff)
parent7ad6f514da84253dfed42efc18c3c9343d7cc052 (diff)
Merged in nathan-dev (pull request #31)
Nathan dev
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 7e18bd8f..5aedb07b 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -137,7 +137,7 @@ class PurchaseOrder(models.Model):
else:
status = 'Menunggu Diproses'
purchase_order.procurement_status = status
-
+
def sale_order_sync(self):
if not self.sale_order_id:
return
@@ -151,23 +151,22 @@ 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 = order_line.product_id.virtual_available
- suggest = 'harus beli'
- if order_line.product_id.virtual_available > order_line.product_qty:
- suggest = 'masih cukup'
- values = {
- 'order_id': self.id,
- '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,
- 'suggest': suggest,
- }
- self.env['purchase.order.line'].sudo().create(values)
+ for order_line in self.sale_order_id.order_line:
+
+ qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty
+
+ suggest = 'harus beli'
+ if qty_available > order_line.product_qty:
+ suggest = 'masih cukup'
+ values = {
+ 'order_id': self.id,
+ '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,
+ 'suggest': suggest,
+ }
+ self.order_line.create(values)
def compute_count_line_product(self):
for order in self: