diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-19 17:08:47 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-19 17:08:47 +0700 |
| commit | e595c9ce8de2eb8c778b998cef58b2d85c29a6a7 (patch) | |
| tree | 799c57e3e759ad4fe28b188bfbe58870f5159b64 /indoteknik_custom/models/purchase_order.py | |
| parent | e59d33ea416afbe5d2e531f524be37c1eeef6015 (diff) | |
| parent | 7ad6f514da84253dfed42efc18c3c9343d7cc052 (diff) | |
Merge branch 'nathan-dev' of bitbucket.org:altafixco/indoteknik-addons into nathan-dev
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 3b94e816..5aedb07b 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -151,38 +151,19 @@ 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: - - qty_onhand = self.env['stock.quant'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_id', '=', 57) - ]) + for order_line in self.sale_order_id.order_line: - qty_incoming = self.env['stock.move'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_dest_id', '=', 57), - ('state', 'not in', ['done', 'cancel']) - ]) - - qty_outgoing = self.env['stock.move'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_id', '=', 57), - ('state', 'not in', ['done', 'cancel']) - ]) - - qty_total = sum(qty_onhand.mapped('quantity')) + sum(qty_incoming.mapped('product_uom_qty')) - - qty = qty_total - sum(qty_outgoing.mapped('product_uom_qty')) + 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 order_line.product_id.virtual_available > order_line.product_qty: + 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, + 'qty_available_store': qty_available, 'suggest': suggest, } self.order_line.create(values) |
