summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-02-10 09:50:21 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-02-10 09:50:21 +0700
commitb4c46fd025ce765acdf9efd3e44f475b6e83d747 (patch)
treeaad9f3e29cfc787dca6a2d6a5d181e48930ea894
parent8799539f33a225fd5b6ddcd1e5ae1bac52fb6b2c (diff)
<Miqdad> rev
-rw-r--r--indoteknik_custom/models/gudang_service.py48
-rw-r--r--indoteknik_custom/models/tukar_guling.py116
-rw-r--r--indoteknik_custom/views/gudang_service.xml2
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"📦 <b>{new_pick.name}</b> created by <b>{self.env.user.name}</b> (state: <b>{new_pick.state}</b>)")
- 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 @@
<field name="gudang_service_lines">
<tree string="Product Lines" editable="top" create="0" delete="1">
<field name="product_id"/>
- <!-- <field name="quantity"/> -->
+ <field name="quantity"/>
</tree>
</field>
</page>