summaryrefslogtreecommitdiff
path: root/indoteknik_custom
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-03 14:14:09 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-03 14:14:09 +0700
commit9ee856d603530e8cc3494a2bccb8fdfaa328da6a (patch)
tree45060ea34a072579defd77dee32687f260dce60e /indoteknik_custom
parenta50b6fd128b643e542ca023aa40f3803260bcf66 (diff)
push
Diffstat (limited to 'indoteknik_custom')
-rwxr-xr-xindoteknik_custom/models/sale_order.py9
-rw-r--r--indoteknik_custom/models/stock_picking.py19
-rwxr-xr-xindoteknik_custom/views/sale_order.xml5
3 files changed, 31 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 710e99de..2769d408 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -109,6 +109,15 @@ class SaleOrder(models.Model):
date_driver_departure = fields.Datetime(string='Departure Date', compute='_compute_date_kirim', copy=False)
note_website = fields.Char(string="Note Website")
use_button = fields.Boolean(string='Using Calculate Selling Price', copy=False)
+ unreserve_id = fields.Many2one('stock.picking', 'Unreserve Picking')
+
+ def do_unreserve(self):
+ user_id = self.env.user.id
+ if user_id != self.user_id.id:
+ raise UserError(_("Only the user who created the picking can unreserve it."))
+
+ self.unreserve_id.do_unreserve()
+
def _compute_date_kirim(self):
for rec in self:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index d16d508e..474c7526 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -125,12 +125,27 @@ 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:
+ self.sale_id.unreserve_id = self.id
+ return self._create_approval_notification('Logistic')
+
res = super(StockPicking, self).do_unreserve()
- if not self.env.user.is_purchasing_manager:
- raise UserError('Hanya Purchasing Manager yang bisa Unreserve')
current_time = datetime.datetime.utcnow()
self.date_unreserve = current_time
+
return res
+
+ def _create_approval_notification(self, approval_role):
+ title = 'Warning'
+ message = f'Butuh approval sales untuk unreserved'
+ return self._create_notification_action(title, message)
+
+ def _create_notification_action(self, title, message):
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': { 'title': title, 'message': message, 'next': {'type': 'ir.actions.act_window_close'} },
+ }
def _compute_shipping_status(self):
for rec in self:
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 1257ff85..569c59f3 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -11,6 +11,10 @@
string="Create No"
type="object"
/>
+ <button name="do_unreserve"
+ string="Unreserve Picking"
+ type="object"
+ />
<button name="sale_order_approve"
string="Ask Approval"
type="object"
@@ -64,6 +68,7 @@
<field name="npwp" placeholder='99.999.999.9-999.999' required="1"/>
<field name="sppkp" attrs="{'required': [('customer_type', '=', 'pkp')]}"/>
<field name="email" required="1"/>
+ <field name="unreserve_id"/>
<field name="due_id" readonly="1"/>
<field name="source_id" domain="[('id', 'in', [32, 59, 60, 61])]" required="1"/>
<button name="override_allow_create_invoice"