diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-19 16:54:00 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-19 16:54:00 +0700 |
| commit | 5006bd2c6cbf09d9f46624b6087cb72702f1ac52 (patch) | |
| tree | b7b0ed41e3c8f97e24724bb649de8ccd10094124 | |
| parent | 63bc8cf104e4c8b0908df8f573d137fcf38c1b5c (diff) | |
Bug fix synchronize order line on purchase
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index df1ecf14..13ff2931 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -151,23 +151,20 @@ 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: - for order_line in self.sale_order_id.order_line: - if not order_line.product_id: - continue - 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.env['purchase.order.line'].create(values) + 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: |
