From e016af1d1ab8df064cbb852965173ab2d53093dd Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 15 Apr 2024 15:14:59 +0700 Subject: fix bug automatic purchase and add already_paid on account move --- indoteknik_custom/models/automatic_purchase.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indoteknik_custom/models/automatic_purchase.py') diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 911e35a8..c27950fd 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -154,15 +154,15 @@ class AutomaticPurchase(models.Model): 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) + ('product_id', 'in', [lines.product_id.id]) + ]) 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.id), + ('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) - ], limit=1) + ]) if not purchasing_job: raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm') @@ -179,7 +179,8 @@ class AutomaticPurchase(models.Model): def create_po_by_vendor(self, vendor_id): current_time = datetime.now() - self.check_qty_po() + if not self.apo_type =='reordering': + self.check_qty_po() PRODUCT_PER_PO = 20 -- cgit v1.2.3