From 8edde46e16d4d977e84a3681c03d1bfab8591a71 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 3 Sep 2024 15:20:06 +0700 Subject: cr unreserved --- indoteknik_custom/models/sale_order.py | 3 +-- indoteknik_custom/models/stock_picking.py | 2 +- indoteknik_custom/views/sale_order.xml | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2769d408..d389f6ae 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -116,9 +116,8 @@ class SaleOrder(models.Model): if user_id != self.user_id.id: raise UserError(_("Only the user who created the picking can unreserve it.")) - self.unreserve_id.do_unreserve() + self.unreserve_id.with_context({'darimana': 'sale.order'}).do_unreserve() - def _compute_date_kirim(self): for rec in self: picking = self.env['stock.picking'].search([('sale_id', '=', rec.id), ('state', 'not in', ['cancel'])], order='date_doc_kirim desc', limit=1) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 474c7526..de45af2e 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -125,7 +125,7 @@ class StockPicking(models.Model): raise UserError('Hanya Logistic yang bisa mengubah shipping method') def do_unreserve(self): - if self.sale_id.unreserve_id.id != self.id: + if not self._context.get('darimana') == 'sale.order': self.sale_id.unreserve_id = self.id return self._create_approval_notification('Logistic') diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 569c59f3..54c01594 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -14,6 +14,7 @@