summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-05 17:02:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-05 17:02:16 +0700
commit5b78ec72f001ad0d5ccde1269d1ec86418fb7339 (patch)
treee57ab8ffb8d05cad2bf346dbe1765fe6b84799d4
parentfcc0596b649ef53a6280530b60c89a2a0dc0ebec (diff)
push
-rwxr-xr-xindoteknik_custom/models/sale_order.py47
-rw-r--r--indoteknik_custom/models/stock_move.py1
-rwxr-xr-xindoteknik_custom/views/sale_order.xml11
3 files changed, 59 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index b0e17a3a..8af34c75 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -247,6 +247,51 @@ class SaleOrder(models.Model):
)
nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3)
shipping_option_id = fields.Many2one("shipping.option", string="Selected Shipping Option", domain="['|', ('sale_order_id', '=', False), ('sale_order_id', '=', id)]")
+ hold_outgoing = fields.Boolean('Hold Outgoing SO')
+ state_ask_cancel = fields.Selection([
+ ('hold', 'Hold'),
+ ('approve', 'Approve')
+ ], tracking=True, string='State Cancel', copy=False)
+
+ def ask_retur_cancel_purchasing(self):
+ for rec in self:
+ if self.env.user.has_group('indoteknik_custom.group_role_purchasing'):
+ rec.state_ask_cancel = 'approve'
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': 'Persetujuan Diberikan',
+ 'message': 'Proses cancel sudah disetujui',
+ 'type': 'success',
+ 'sticky': True
+ }
+ }
+ else:
+ rec.state_ask_cancel = 'hold'
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': 'Menunggu Persetujuan',
+ 'message': 'Tim Purchasing akan memproses permintaan Anda',
+ 'type': 'warning',
+ 'sticky': False
+ }
+ }
+
+ def hold_unhold_qty_outgoing_so(self):
+ pickings = self.env['stock.picking'].search([('sale_id', '=', self.id), ('state', 'not in', ['cancel','done']), ('name', 'ilike', 'BU/PICK/%')])
+ products = self.order_line.mapped('product_id')
+ for picking in pickings:
+ for line in picking.move_ids_without_package:
+ if line.product_id in products:
+ if line.hold_outgoingg == True:
+ line.hold_outgoingg = False
+ self.hold_outgoing = False
+ else:
+ line.hold_outgoingg = True
+ self.hold_outgoing = True
def _validate_uniform_taxes(self):
for order in self:
@@ -1392,6 +1437,8 @@ class SaleOrder(models.Model):
def action_cancel(self):
# TODO stephan prevent cancel if have invoice, do, and po
+ if self.state_ask_cancel != 'approve':
+ raise UserError("Anda harus approval purchasing terlebih dahulu")
main_parent = self.partner_id.get_main_parent()
if self._name != 'sale.order':
return super(SaleOrder, self).action_cancel()
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index 3c765244..90ab30a4 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -14,6 +14,7 @@ class StockMove(models.Model):
qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant')
barcode = fields.Char(string='Barcode', related='product_id.barcode')
vendor_id = fields.Many2one('res.partner' ,string='Vendor')
+ hold_outgoingg = fields.Boolean('Hold Outgoing', default=False)
# @api.model_create_multi
# def create(self, vals_list):
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 79a095fb..40a57203 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -16,6 +16,16 @@
type="object"
attrs="{'invisible': [('approval_status', '=', ['approved'])]}"
/>
+ <button name="hold_unhold_qty_outgoing_so"
+ string="Hold/Unhold Outgoing"
+ type="object"
+ attrs="{'invisible': [('state', 'not in', ['sale','done'])]}"
+ />
+ <button name="ask_retur_cancel_purchasing"
+ string="Ask Retur Purchasing"
+ type="object"
+ attrs="{'invisible': [('state', 'in', ['cancel'])]}"
+ />
<button name="action_web_approve"
string="Web Approve"
type="object"
@@ -83,6 +93,7 @@
<attribute name="invisible">1</attribute>
</field>
<field name="user_id" position="after">
+ <field name="hold_outgoing" readonly="1" />
<field name="helper_by_id" readonly="1" />
<field name="compute_fullfillment" invisible="1" />
</field>