summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-03 15:20:06 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-03 15:20:06 +0700
commit8edde46e16d4d977e84a3681c03d1bfab8591a71 (patch)
treee320dac54a3d4fc9bead223045948ab011c66a0b
parent9ee856d603530e8cc3494a2bccb8fdfaa328da6a (diff)
cr unreserved
-rwxr-xr-xindoteknik_custom/models/sale_order.py3
-rw-r--r--indoteknik_custom/models/stock_picking.py2
-rwxr-xr-xindoteknik_custom/views/sale_order.xml1
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 @@
<button name="do_unreserve"
string="Unreserve Picking"
type="object"
+ attrs="{'invisible': [('state', 'not in', ['draft', 'cancel', 'done'])]}"
/>
<button name="sale_order_approve"
string="Ask Approval"