summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-06 13:56:14 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-06 13:56:14 +0700
commitc1d93cfcef61276db77b9943c38e242141dc41f3 (patch)
tree398162200bd884b0c4f327fb832e7118e992f695
parente16c4fd64143db43eff45d39789a1e59d64f1d34 (diff)
parent08fb1ce211c3bc11e6ff0ea6ff37e0be8b7c2b31 (diff)
Merge branch 'feature/hold-qty-outgoing-mom' into odoo-backup
-rwxr-xr-xindoteknik_custom/models/sale_order.py40
-rw-r--r--indoteknik_custom/models/stock_move.py1
-rwxr-xr-xindoteknik_custom/views/sale_order.xml12
3 files changed, 53 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 0711e33a..1e744f18 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -296,6 +296,44 @@ 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):
+ if self.hold_outgoing == True:
+ self.hold_outgoing = False
+ else:
+ self.hold_outgoing = True
def _validate_uniform_taxes(self):
for order in self:
@@ -1448,6 +1486,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 633ac6d1..c446a8ba 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', 'in', ['cancel'])]}"
+ />
+ <button name="ask_retur_cancel_purchasing"
+ string="Ask Cancel 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>
@@ -383,6 +394,7 @@
<field name="payment_status" optional="hide" />
<field name="pareto_status" optional="hide" />
<field name="shipping_method_picking" optional="hide" />
+ <field name="hold_outgoing" optional="hide" />
</field>
</field>
</record>