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/account_move.py | 1 + indoteknik_custom/models/automatic_purchase.py | 13 +++++++------ indoteknik_custom/views/account_move.xml | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index f80cc109..94a1ab19 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -55,6 +55,7 @@ class AccountMove(models.Model): bills_invoice_document = fields.Binary(string="Invoice", required=False) is_invoice_uploaded = fields.Boolean(string="Is Invoice Uploaded", default=False) is_efaktur_uploaded = fields.Boolean(string="Is eFaktur Uploaded", default=False) + already_paid = fields.Boolean(string="Sudah Dibayar?", default=False) delivery_amt_text = fields.Char(string="Delivery Amt Terbilang", compute='compute_delivery_amt_text') def compute_delivery_amt_text(self): 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 diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 3ad51b70..f505ef9d 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -51,6 +51,9 @@ + + + -- cgit v1.2.3