From 12c5971f46f3527ed9a8e1d865430d2b9fa25b38 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Mon, 2 Feb 2026 11:13:40 +0700 Subject: Initial Commit --- indoteknik_custom/models/gudang_service.py | 23 +---------------------- indoteknik_custom/views/gudang_service.xml | 9 --------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py index ce3b2919..55e27b65 100644 --- a/indoteknik_custom/models/gudang_service.py +++ b/indoteknik_custom/models/gudang_service.py @@ -35,7 +35,7 @@ class GudangService(models.Model): # ) remaining_date = fields.Char( compute='_compute_remaining_date', - string='Remaining Date' + string='Date Status' ) state = fields.Selection([('draft', 'Backlog'), ('onprogress', 'On Progress'),('done', 'Done'), ('cancel', 'Cancel')], default='draft', tracking=True) cancel_reason = fields.Text('Cancel Reason', tracking=True) @@ -88,27 +88,6 @@ class GudangService(models.Model): if records: records._send_logistic_notification() - # @api.depends('schedule_date', 'start_date', 'state') - # def _compute_unprocessed_date(self): - # today = fields.Date.today() - - # for rec in self: - # if not rec.schedule_date or rec.state == 'cancel': - # rec.unprocessed_date = "-" - # continue - - # schedule = rec.schedule_date - - # # BELUM DIPROSES - # if not rec.start_date: - # days = (today - schedule).days - - # # SUDAH DIPROSES - # else: - # days = (rec.start_date.date() - schedule).days - - # rec.unprocessed_date = _("Unprocessed %s days") % max(days, 0) - @api.depends('schedule_date', 'create_date') def _compute_remaining_date(self): today = fields.Date.today() diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index e06e9e7e..8bc787cf 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -6,11 +6,6 @@ gudang.serivice.tree gudang.service - - - @@ -63,7 +56,6 @@ - @@ -77,7 +69,6 @@ - -- cgit v1.2.3 From b4c46fd025ce765acdf9efd3e44f475b6e83d747 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 09:50:21 +0700 Subject: rev --- indoteknik_custom/models/gudang_service.py | 48 +++--------- indoteknik_custom/models/tukar_guling.py | 116 ++++++++++++++--------------- indoteknik_custom/views/gudang_service.xml | 2 +- 3 files changed, 68 insertions(+), 98 deletions(-) diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py index 70ff27c0..3f483a56 100644 --- a/indoteknik_custom/models/gudang_service.py +++ b/indoteknik_custom/models/gudang_service.py @@ -13,8 +13,8 @@ class GudangService(models.Model): name = fields.Char('Name', readonly=True) partner_id = fields.Many2one('res.partner', string='Customer', readonly=True) - vendor_id = fields.Many2one('res.partner', string='Vendor', readonly=True, required=True) - origin = fields.Many2one('sale.order', string='Origin SO', required=True) + vendor_id = fields.Many2one('res.partner', string='Vendor Service', required=True) + origin = fields.Many2one('sale.order', string='Origin SO', required=True, domain=[('state', 'in', ['done', 'sale'])]) schedule_date = fields.Date( string="Schedule Date", required=True, @@ -36,7 +36,13 @@ class GudangService(models.Model): compute='_compute_remaining_date', string='Date Status' ) - state = fields.Selection([('draft', 'Backlog'), ('onprogress', 'On Progress'),('done', 'Done'), ('cancel', 'Cancel')], default='draft', tracking=True) + state = fields.Selection([ + ('draft', 'Backlog'), + ('received_from_cust', 'Received From Customer'), + ('sent_to_vendor', 'Sent to Service Vendor'), + ('received_from_vendor', 'Received From Service Vendor'), + ('delived_to_cust', 'Delivered to Customer'), + ('cancel', 'Cancel')], default='draft', tracking=True) cancel_reason = fields.Text('Cancel Reason', tracking=True) def _send_logistic_notification(self): @@ -162,42 +168,6 @@ class GudangService(models.Model): so = self.env['sale.order'].browse(vals['origin']) vals['partner_id'] = so.partner_id.id - # 1️⃣ Cari BU/OUT dari SO - picking = self.env['stock.picking'].search([ - ('origin', '=', so.name), - ('picking_type_id', '=', 29), # BU/OUT - ('state', '=', 'done'), - ], limit=1) - - if not picking: - raise UserError("BU/OUT (done) tidak ditemukan untuk SO ini.") - - # 2️⃣ Validasi product service ada di picking - picking_products = picking.move_lines.mapped('product_id') - service_lines = vals.get('gudang_service_lines', []) - - tg_lines = [] - for line in service_lines: - product = self.env['product.product'].browse(line[2]['product_id']) - if product not in picking_products: - raise UserError( - f"Produk {product.display_name} tidak ada di BU/OUT {picking.name}" - ) - - tg_lines.append((0, 0, { - 'product_id': product.id, - 'quantity': line[2]['quantity'], - })) - - # 3️⃣ Create Tukar Guling - self.env['tukar.guling'].create({ - 'origin_so': so.id, - 'operation_type': 'service', - 'partner_id': so.partner_id.id, - 'operations': picking.id, - 'line_ids': tg_lines, - }) - res = super(GudangService, self).create(vals) res._send_logistic_notification() diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index 03af984f..619e7c99 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -62,7 +62,7 @@ class TukarGuling(models.Model): notes = fields.Text('Notes') return_type = fields.Selection(String='Return Type', selection=[ ('tukar_guling', 'Tukar Guling'), # -> barang yang sama - ('service', 'Service'), # -> barang yang sama + # ('service', 'Service'), # -> barang yang sama ('retur_so', 'Retur SO')], required=True, tracking=3, help='Retur SO (ORT-SRT),\n Tukar Guling (ORT-SRT-PICK-OUT)') state = fields.Selection(string='Status', selection=[ ('draft', 'Draft'), @@ -933,64 +933,64 @@ class TukarGuling(models.Model): record.message_post( body=f"📦 {new_pick.name} created by {self.env.user.name} (state: {new_pick.state})") - if record.return_type == 'service': - GUDANG_SERVICE_LOCATION_ID = 98 - # From STOCK to OUTPUT - done_service = self.env['stock.picking'].create({ - 'group_id': bu_out.group_id.id, - 'tukar_guling_id': record.id, - 'sale_order': record.origin, - 'note': record.notes, - 'picking_type_id': 32, - 'location_id': GUDANG_SERVICE_LOCATION_ID, - 'location_dest_id': BU_STOCK_LOCATION_ID, - 'partner_id': bu_out.partner_id.id, - 'move_ids_without_package': [(0, 0, { - 'product_id': line.product_id.id, - 'product_uom_qty': line.product_uom_qty, - 'product_uom': line.product_uom.id, - 'name': line.product_id.display_name, - 'location_id': GUDANG_SERVICE_LOCATION_ID, - 'location_dest_id': BU_STOCK_LOCATION_ID, - }) for line in record.line_ids], - }) - if done_service: - done_service.action_confirm() - done_service.action_assign() - else: - raise UserError("Gagal membuat picking service") + # if record.return_type == 'service': + # GUDANG_SERVICE_LOCATION_ID = 98 + # # From STOCK to OUTPUT + # done_service = self.env['stock.picking'].create({ + # 'group_id': bu_out.group_id.id, + # 'tukar_guling_id': record.id, + # 'sale_order': record.origin, + # 'note': record.notes, + # 'picking_type_id': 32, + # 'location_id': GUDANG_SERVICE_LOCATION_ID, + # 'location_dest_id': BU_STOCK_LOCATION_ID, + # 'partner_id': bu_out.partner_id.id, + # 'move_ids_without_package': [(0, 0, { + # 'product_id': line.product_id.id, + # 'product_uom_qty': line.product_uom_qty, + # 'product_uom': line.product_uom.id, + # 'name': line.product_id.display_name, + # 'location_id': GUDANG_SERVICE_LOCATION_ID, + # 'location_dest_id': BU_STOCK_LOCATION_ID, + # }) for line in record.line_ids], + # }) + # if done_service: + # done_service.action_confirm() + # done_service.action_assign() + # else: + # raise UserError("Gagal membuat picking service") - service_to_output = self.env['stock.picking'].create({ - 'group_id': bu_out.group_id.id, - 'tukar_guling_id': record.id, - 'sale_order': record.origin, - 'note': record.notes, - 'picking_type_id': 32, - 'location_id': BU_STOCK_LOCATION_ID, - 'location_dest_id': BU_OUTPUT_LOCATION_ID, - 'partner_id': bu_out.partner_id.id, - 'move_lines': [(0, 0, { - 'product_id': line.product_id.id, - 'product_uom_qty': line.product_uom_qty, - 'product_uom': line.product_uom.id, - 'name': line.product_id.display_name, - 'location_id':BU_STOCK_LOCATION_ID, - 'location_dest_id': BU_STOCK_LOCATION_ID, - }) for line in record.line_ids], - 'move_ids_without_package': [(0, 0, { - 'product_id': line.product_id.id, - 'product_uom_qty': line.product_uom_qty, - 'product_uom': line.product_uom.id, - 'name': line.product_id.display_name, - 'location_id': BU_STOCK_LOCATION_ID, - 'location_dest_id': BU_OUTPUT_LOCATION_ID, - }) for line in record.line_ids], - }) - if service_to_output: - service_to_output.action_confirm() - service_to_output.action_assign() - else: - raise UserError("Gagal membuat picking service") + # service_to_output = self.env['stock.picking'].create({ + # 'group_id': bu_out.group_id.id, + # 'tukar_guling_id': record.id, + # 'sale_order': record.origin, + # 'note': record.notes, + # 'picking_type_id': 32, + # 'location_id': BU_STOCK_LOCATION_ID, + # 'location_dest_id': BU_OUTPUT_LOCATION_ID, + # 'partner_id': bu_out.partner_id.id, + # 'move_lines': [(0, 0, { + # 'product_id': line.product_id.id, + # 'product_uom_qty': line.product_uom_qty, + # 'product_uom': line.product_uom.id, + # 'name': line.product_id.display_name, + # 'location_id':BU_STOCK_LOCATION_ID, + # 'location_dest_id': BU_STOCK_LOCATION_ID, + # }) for line in record.line_ids], + # 'move_ids_without_package': [(0, 0, { + # 'product_id': line.product_id.id, + # 'product_uom_qty': line.product_uom_qty, + # 'product_uom': line.product_uom.id, + # 'name': line.product_id.display_name, + # 'location_id': BU_STOCK_LOCATION_ID, + # 'location_dest_id': BU_OUTPUT_LOCATION_ID, + # }) for line in record.line_ids], + # }) + # if service_to_output: + # service_to_output.action_confirm() + # service_to_output.action_assign() + # else: + # raise UserError("Gagal membuat picking service") # BU/OUT Baru dari SRT diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index 8bc787cf..d68b0f08 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -68,7 +68,7 @@ - + -- cgit v1.2.3 From b6d2feb969d38e1991e5afa129813da89e8a51fb Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 09:55:53 +0700 Subject: fix colors --- indoteknik_custom/views/gudang_service.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index d68b0f08..68e2428c 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -6,10 +6,8 @@ gudang.serivice.tree gudang.service - + @@ -17,8 +15,8 @@ - + -- cgit v1.2.3 From 7aadac577c7bdacf1fab54c23fe50b04fba08393 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 15:06:17 +0700 Subject: fix state --- indoteknik_custom/models/gudang_service.py | 37 ++++++++++++++++++------------ indoteknik_custom/views/gudang_service.xml | 8 +++---- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py index 3f483a56..4e3b2c34 100644 --- a/indoteknik_custom/models/gudang_service.py +++ b/indoteknik_custom/models/gudang_service.py @@ -41,7 +41,7 @@ class GudangService(models.Model): ('received_from_cust', 'Received From Customer'), ('sent_to_vendor', 'Sent to Service Vendor'), ('received_from_vendor', 'Received From Service Vendor'), - ('delived_to_cust', 'Delivered to Customer'), + ('delivered_to_cust', 'Delivered to Customer'), ('cancel', 'Cancel')], default='draft', tracking=True) cancel_reason = fields.Text('Cancel Reason', tracking=True) @@ -88,7 +88,7 @@ class GudangService(models.Model): @api.model def cron_notify_onprogress_gudang_service(self): records = self.search([ - ('state', '=', 'draft') + ('state', 'in', ['draft', 'received_from_customer']), ]) if records: @@ -118,21 +118,28 @@ class GudangService(models.Model): def action_submit(self): for rec in self: - rec.state = 'onprogress' - rec.start_date = fields.Datetime.now() - # rec.date = fields.Datetime.now() + if rec.state == 'draft': + rec.state = 'received_from_cust' + elif rec.state == 'received_from_cust': + rec.state = 'sent_to_vendor' + rec.start_date = fields.Datetime.now() + elif rec.state == 'sent_to_vendor': + rec.state = 'received_from_vendor' def action_done(self): - for rec in self: - activities = self.env['mail.activity'].search([ - ('res_id', '=', rec.id), - ('res_model', '=', 'gudang.service'), - ('state', '=', 'done') - ]) - activities.unlink() - rec.state = 'done' - if not rec.done_date: - rec.done_date = fields.Datetime.now() + if self.state != 'received_from_vendor': + raise UserError("Only 'Received From Vendor' state can be set to Done") + else: + for rec in self: + activities = self.env['mail.activity'].search([ + ('res_id', '=', rec.id), + ('res_model', '=', 'gudang.service'), + ('state', '=', 'delivered_to_cust'), + ]) + activities.unlink() + rec.state = 'delivered_to_cust' + if not rec.done_date: + rec.done_date = fields.Datetime.now() def action_draft(self): """Reset to draft state""" diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index 68e2428c..6abdcc8b 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -31,16 +31,16 @@
-- cgit v1.2.3 From dc2baa117413f3140adf99c8a398da3d7637c3d3 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 18:26:52 +0700 Subject: push --- indoteknik_custom/models/gudang_service.py | 2 +- indoteknik_custom/views/gudang_service.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py index 4e3b2c34..4900113f 100644 --- a/indoteknik_custom/models/gudang_service.py +++ b/indoteknik_custom/models/gudang_service.py @@ -157,7 +157,7 @@ class GudangService(models.Model): ('res_model', '=', 'gudang.service'), ]) activities.unlink() - if rec.state == 'done': + if rec.state == 'delivered_to_cust': raise UserError("You cannot cancel a done record") if not rec.cancel_reason: raise UserError("Cancel Reason must be filled") diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index 6abdcc8b..e5cc94c4 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -56,10 +56,10 @@ - + + attrs="{'invisible': [('state', 'in', ['delivered_to_cust', 'draft'])]}"/> -- cgit v1.2.3 From 55a8c1e5b204bd19733f3197b253293bc00fdf32 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Fri, 13 Feb 2026 09:42:10 +0700 Subject: fix conflict --- indoteknik_custom/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index b2e94858..6287aace 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -194,7 +194,7 @@ 'views/domain_apo.xml', 'views/uom_uom.xml', 'views/commission_internal.xml', - 'views/gudang_service.xml' + 'views/gudang_service.xml', 'views/update_depreciation_move_wizard_view.xml' ], 'demo': [], -- cgit v1.2.3