summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-11-14 11:45:32 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-11-14 11:45:32 +0700
commit0b85c98761260dd93b70fa429340c4edbf5154b1 (patch)
tree8ddc71d430371289834db659c3cb247a4712a10e /indoteknik_custom/models
parentd6c056a43636bd2707620649cb1917ea341f1400 (diff)
add approval if want to return
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/stock_picking.py15
-rw-r--r--indoteknik_custom/models/stock_picking_return.py19
3 files changed, 34 insertions, 1 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 94fe56fe..8645fb00 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -29,3 +29,4 @@ from . import users
from . import ir_attachment
from . import delivery_carrier
from . import dunning_run
+from . import stock_picking_return
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index d016e241..2f82c6f6 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -50,7 +50,12 @@ class StockPicking(models.Model):
approval_status = fields.Selection([
('pengajuan1', 'Approval Accounting'),
('approved', 'Approved'),
- ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3)
+ ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Internal Use")
+
+ approval_return_status = fields.Selection([
+ ('pengajuan1', 'Approval Accounting'),
+ ('approved', 'Approved'),
+ ], string='Approval Return Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Return")
def action_assign(self):
res = super(StockPicking, self).action_assign()
@@ -68,6 +73,13 @@ class StockPicking(models.Model):
raise UserError("Qty tidak boleh 0")
pick.approval_status = 'pengajuan1'
+ def ask_return_approval(self):
+ for pick in self:
+ if self.env.user.is_accounting:
+ pick.approval_return_status = 'approved'
+ else:
+ pick.approval_return_status = 'pengajuan1'
+
def calculate_line_no(self):
line_no = 0
for picking in self:
@@ -102,6 +114,7 @@ class StockPicking(models.Model):
if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False:
raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO'))
+
if self.is_internal_use and not self.env.user.is_accounting:
raise UserError("Harus di Approve oleh Accounting")
res = super(StockPicking, self).button_validate()
diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py
new file mode 100644
index 00000000..a4a3a500
--- /dev/null
+++ b/indoteknik_custom/models/stock_picking_return.py
@@ -0,0 +1,19 @@
+from odoo import _, api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_round
+
+
+class ReturnPicking(models.TransientModel):
+ _inherit = 'stock.return.picking'
+
+ @api.model
+ def default_get(self, fields):
+ res = super(ReturnPicking, self).default_get(fields)
+
+ stock_picking = self.env['stock.picking'].search([
+ ('id', '=', res['picking_id']),
+ ])
+ if not stock_picking.approval_return_status == 'approved':
+ raise UserError('Harus Approval Accounting untuk melakukan Retur')
+
+ return res \ No newline at end of file