summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-04-16 10:49:44 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-04-16 10:49:44 +0700
commit2afacd2b2cec9c9555172dcc5e0aafedcc1aefd8 (patch)
tree57d722d86cc3800e0f61d4e9fb19f3c82497f0b0
parent3c3f10d9ec7a5d1350d5627047975387193a473f (diff)
fix check qty po
-rw-r--r--indoteknik_custom/models/automatic_purchase.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index c27950fd..d3158182 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -157,25 +157,26 @@ class AutomaticPurchase(models.Model):
('product_id', 'in', [lines.product_id.id])
])
- po = self.env['purchase.order'].search([
- ('product_id', 'in', [lines.product_id.id]),
- # ('order_sales_match_line.sale_id', 'in', [lines.automatic_purchase_id.sales_match.sale_id.id]),
- ('state', 'not in', ['cancel']),
- ('from_apo', '=', True)
- ])
+ for sale_id in lines.automatic_purchase_id.sales_match.mapped('sale_id.id'):
+ po = self.env['purchase.order'].search([
+ ('product_id', 'in', [lines.product_id.id]),
+ ('order_sales_match_line.sale_id', '=', sale_id),
+ ('state', 'not in', ['cancel']),
+ ('from_apo', '=', True)
+ ])
- if not purchasing_job:
- raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm')
+ if not purchasing_job:
+ raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm')
- qty_pj = 0
- qty_outgoing_pj = 0
+ qty_pj = 0
+ qty_outgoing_pj = 0
- for line in po.order_line:
- qty_pj += line.product_qty + lines.qty_purchase
- qty_outgoing_pj += line.qty_outgoing
+ for line in po.order_line:
+ qty_pj += line.product_qty + lines.qty_purchase
+ qty_outgoing_pj += line.qty_outgoing
- if qty_pj > qty_outgoing_pj:
- raise UserError('Qty yang anda beli lebih dari qty outgoing')
+ if qty_pj > qty_outgoing_pj:
+ raise UserError('Qty yang anda beli lebih dari qty outgoing')
def create_po_by_vendor(self, vendor_id):
current_time = datetime.now()