summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-04-13 11:39:33 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-04-13 11:39:33 +0700
commitbb00e1a54298bab88856e291ca8190f1823b1fcc (patch)
treed53337b0cc722c8f7f9c12a0ef9a751509ec3ccd
parent610b0dde2b83d539b153db5f71b68da441217eed (diff)
trying to fix bug
-rw-r--r--indoteknik_custom/models/automatic_purchase.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index a8a67569..8a44b747 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -152,27 +152,28 @@ class AutomaticPurchase(models.Model):
self.is_po = True
def check_qty_po(self):
- for lines in self.purchase_lines:
- purchasing_job = self.env['v.purchasing.job'].search([
- ('product_id', '=', lines.product_id.id)
- ], limit=1)
-
- po = self.env['purchase.order'].search([
- ('product_id', '=', lines.product_id.id),
- ('order_sales_match_line.sale_id', '=', lines.automatic_purchase_id.sales_match.sale_id),
- ('state', 'not in', ['cancel']),
- ('from_apo', '=', True)
- ], limit=1)
-
- if not purchasing_job:
- raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm')
-
- for line in po.order_line:
- qty_pj = po.product_qty + lines.qty_purchase
- qty_outgoing_pj = po.qty_outgoing
-
- if qty_pj > qty_outgoing_pj:
- raise UserError('Qty yang anda beli lebih dari qty outgoing')
+ if self.apo_type == 'regular':
+ for lines in self.purchase_lines:
+ purchasing_job = self.env['v.purchasing.job'].search([
+ ('product_id', '=', lines.product_id.id)
+ ], limit=1)
+
+ po = self.env['purchase.order'].search([
+ ('product_id', '=', lines.product_id.id),
+ ('order_sales_match_line.sale_id', '=', lines.automatic_purchase_id.sales_match.sale_id),
+ ('state', 'not in', ['cancel']),
+ ('from_apo', '=', True)
+ ], limit=1)
+
+ if not purchasing_job:
+ raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm')
+
+ for line in po.order_line:
+ qty_pj = po.product_qty + lines.qty_purchase
+ qty_outgoing_pj = po.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()