From 610b0dde2b83d539b153db5f71b68da441217eed Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 13 Apr 2024 09:26:37 +0700 Subject: feedback sj --- indoteknik_custom/models/automatic_purchase.py | 28 ++++++++++++++++++++++++-- indoteknik_custom/models/purchasing_job.py | 2 +- indoteknik_custom/models/report_logbook_sj.py | 13 +++++++----- indoteknik_custom/views/report_logbook_sj.xml | 19 +++++------------ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 3eba0d62..a8a67569 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -68,7 +68,6 @@ class AutomaticPurchase(models.Model): if count > 0: raise UserError('Ada sekitar %s SO Yang sudah create PO, berikut SO nya: %s' % (count, ', '.join(names))) - def create_po_from_automatic_purchase(self): if not self.purchase_lines: raise UserError('Tidak ada Lines, belum bisa create PO') @@ -151,10 +150,35 @@ class AutomaticPurchase(models.Model): self.notification = 'PO Created successfully' 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') + def create_po_by_vendor(self, vendor_id): current_time = datetime.now() + self.check_qty_po() + PRODUCT_PER_PO = 20 auto_purchase_line = self.env['automatic.purchase.line'] diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index d3d95a09..5fba0a95 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -146,7 +146,7 @@ class PurchasingJob(models.Model): 'product_id': job.product_id.id, 'qty_purchase': qty_purchase, 'qty_available': qty_available, - 'partner_id': vendor_id.id, + 'partner_id': job.vendor_id.id, 'last_price': price, 'taxes_id': taxes, 'subtotal': qty_purchase * price, diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index 33a7ccb1..f34835ae 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -5,13 +5,16 @@ from datetime import datetime class ReportLogbookSJ(models.Model): _name = 'report.logbook.sj' + _description = "Logbook SJ" + _inherit = ['mail.thread'] + _rec_name = 'name' name = fields.Char(string='Name', default='Logbook SJ') date = fields.Datetime(string='Date Created') - date_approve = fields.Datetime(string='Date Approve') - approve_by_finance = fields.Boolean(string='Approve By Finance') - approve_by = fields.Many2one(comodel_name='res.users', string='Approve By') - created_by = fields.Many2one(comodel_name='res.users', string='Created By') + date_approve = fields.Datetime(string='Date Approve', tracking=3) + approve_by_finance = fields.Boolean(string='Approve By Finance', tracking=3) + approve_by = fields.Many2one(comodel_name='res.users', string='Approve By', tracking=3) + created_by = fields.Many2one(comodel_name='res.users', string='Created By', tracking=3) report_logbook_sj_line = fields.One2many( comodel_name='report.logbook.sj.line', inverse_name='report_logbook_sj_id', @@ -24,7 +27,7 @@ class ReportLogbookSJ(models.Model): ], default='terima_semua', string='Status', - tracking=True + tracking=True, ) @api.model diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 8fd2c861..8221b419 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -4,7 +4,7 @@ report.logbook.sj.tree report.logbook.sj - + @@ -67,22 +67,13 @@ +
+ + +
- Report Logbook SJ -- cgit v1.2.3