summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/vendor_approval.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-03 11:55:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-03 11:55:16 +0700
commit7059f095dd09649f7c12f74ff29200f644bbc854 (patch)
tree9e7dc3c1e0ca800a1b589cb3c65dddf5ad798894 /indoteknik_custom/models/vendor_approval.py
parent4a69c71eab2d4ea3504a0cf6e3a9ca241be48594 (diff)
push
Diffstat (limited to 'indoteknik_custom/models/vendor_approval.py')
-rw-r--r--indoteknik_custom/models/vendor_approval.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/vendor_approval.py b/indoteknik_custom/models/vendor_approval.py
index 4369a193..442aec7a 100644
--- a/indoteknik_custom/models/vendor_approval.py
+++ b/indoteknik_custom/models/vendor_approval.py
@@ -15,7 +15,21 @@ class VendorApproval(models.Model):
partner_id = fields.Many2one('res.partner', string="Customer", readonly=True)
order_id = fields.Many2one('sale.order', string="SO", readonly=True)
vendor_approval_line = fields.One2many('vendor.approval.line', 'vendor_approval_id', string='Vendor Approval Lines', auto_join=True)
+ state = fields.Selection([('draft', 'Draft'), ('done', 'Done'), ('cancel', 'Cancel')], string='State', tracking=True)
+
+ def action_approve(self):
+ if not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
+ raise UserError('Hanya Merchandiser yang bisa approve')
+ self.state = 'done'
+ self.order_id.update({'vendor_approval': True})
+ self.order_id.action_confirm()
+
+ def action_reject(self):
+ if not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
+ raise UserError('Hanya Merchandiser yang bisa cancel')
+ self.state = 'cancel'
+
def unlink(self):
res = super(VendorApproval, self).unlink()
if not self._name == 'vendor.approval':