diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-04-16 11:51:03 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-04-16 11:51:03 +0700 |
| commit | e2a9f4f82b0c761cc4c20d501ab586239c0126a3 (patch) | |
| tree | ba20e710464b7f64a3f4ffb1bd1acc9b3ab222aa | |
| parent | 6ee875d5dad299ebcd17c16d6c3736cf881e53f4 (diff) | |
push
| -rw-r--r-- | indoteknik_api/controllers/api_v1/stock_picking.py | 9 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 31 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 10 |
3 files changed, 39 insertions, 11 deletions
diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py index a2cd0557..31706b99 100644 --- a/indoteknik_api/controllers/api_v1/stock_picking.py +++ b/indoteknik_api/controllers/api_v1/stock_picking.py @@ -116,10 +116,10 @@ class StockPicking(controller.Controller): return self.response(picking.get_tracking_detail()) - @http.route(prefix + 'stock-picking/<id>/documentation', auth='public', methods=['PUT', 'OPTIONS'], csrf=False) + @http.route(prefix + 'stock-picking/<scanid>/documentation', auth='public', methods=['PUT', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized() def write_partner_stock_picking_documentation(self, **kw): - id = int(kw.get('id', 0)) + scanid = int(kw.get('scanid', 0)) sj_document = kw.get('sj_document', False) paket_document = kw.get('paket_document', False) @@ -128,7 +128,10 @@ class StockPicking(controller.Controller): 'driver_arrival_date': datetime.utcnow(), } - picking_data = request.env['stock.picking'].search([('id', '=', id)], limit=1) + picking_data = request.env['stock.picking'].search([('id', '=', scanid)], limit=1) + + if not picking_data: + picking_data = request.env['stock.picking'].search([('picking_code', '=', scanid)], limit=1) if not picking_data: return self.response(code=404, description='picking not found') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 383c75a3..3aa3a0a4 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1542,9 +1542,22 @@ class CheckProduct(models.Model): index=True, copy=False, ) - product_id = fields.Many2one('product.product', string='Product', required=True) - quantity = fields.Float(string='Quantity', default=1.0, required=True) + product_id = fields.Many2one('product.product', string='Product') + quantity = fields.Float(string='Quantity', default=1.0) status = fields.Char(string='Status', compute='_compute_status') + code_product = fields.Char(string='Code Product') + + @api.onchange('code_product') + def _onchange_code_product(self): + if self.code_product: + product = self.env['product.product'].search([('default_code', '=', self.code_product)], limit=1) + if not product: + product = self.env['product.product'].search([('barcode', '=', self.code_product)], limit=1) + + if product: + self.product_id = product.id + else: + raise UserError("Product tidak ditemukan") @api.depends('quantity') def _compute_status(self): @@ -1654,13 +1667,13 @@ class CheckProduct(models.Model): # Calculate the total quantity after addition total_quantity = sum(existing_lines.mapped('quantity')) - record.quantity - if total_quantity > total_qty_in_moves: + if total_quantity == total_qty_in_moves: raise UserError(( "Quantity Product '%s' sudah melebihi quantity demand." ) % (record.product_id.display_name)) else: # Check if the quantity exceeds the allowed total - if record.quantity > total_qty_in_moves: + if record.quantity == total_qty_in_moves: raise UserError(( "Quantity Product '%s' sudah melebihi quantity demand." ) % (record.product_id.display_name)) @@ -1741,6 +1754,16 @@ class ScanKoli(models.Model): string="Progress Scan Koli", compute="_compute_scan_koli_progress" ) + code_koli = fields.Char(string='Code Koli') + + @api.onchange('code_koli') + def _onchange_code_koli(self): + if self.code_koli: + koli = self.env['sales.order.koli'].search([('koli_id.koli', '=', self.code_koli)], limit=1) + if koli: + self.write({'koli_id': koli.id}) + else: + raise UserError('Koli tidak ditemukan') def _compute_scan_koli_progress(self): for scan in self: diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 4832a1fc..da35d768 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -123,7 +123,7 @@ <field name="date_doc_kirim" attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/> <field name="summary_qty_operation"/> <field name="count_line_operation"/> - <field name="linked_manual_bu_out" domain="[('picking_type_code', '=', 'outgoing'), ('group_id', '=', group_id)]"/> + <field name="linked_manual_bu_out" attrs="{'invisible': [('location_id', '=', 60)]}" domain="[('picking_type_code', '=', 'outgoing'),('state', 'not in', ['done','cancel']), ('group_id', '=', group_id)]"/> <field name="account_id" attrs="{ 'readonly': [['state', 'in', ['done', 'cancel']]], @@ -244,7 +244,8 @@ <field name="model">scan.koli</field> <field name="arch" type="xml"> <tree editable="bottom"> - <field name="koli_id" options="{'no_create': True}" required="1" domain="[('state', '=', 'not_delivered')]"/> + <field name="code_koli"/> + <field name="koli_id" options="{'no_create': True}" domain="[('state', '=', 'not_delivered')]"/> <field name="scan_koli_progress"/> </tree> </field> @@ -255,7 +256,7 @@ <field name="model">konfirm.koli</field> <field name="arch" type="xml"> <tree editable="bottom"> - <field name="pick_id" options="{'no_create': True}" required="1" domain="[('picking_type_code', '=', 'internal'), ('group_id', '=', parent.group_id)]"/> + <field name="pick_id" options="{'no_create': True}" required="1" domain="[('picking_type_code', '=', 'internal'), ('group_id', '=', parent.group_id), ('linked_manual_bu_out', '=', parent.id)]"/> </tree> </field> </record> @@ -277,7 +278,8 @@ <field name="model">check.product</field> <field name="arch" type="xml"> <tree editable="bottom" decoration-warning="status == 'Pending'" decoration-success="status == 'Done'"> - <field name="product_id" required="1" options="{'no_create': True}"/> + <field name="code_product"/> + <field name="product_id"/> <field name="quantity" readonly="1"/> <field name="status" readonly="1"/> </tree> |
