summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-29 08:54:16 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-29 08:54:16 +0700
commit43a8e9a7f2d6ba127de9bcd40925b838b1f5eaeb (patch)
treea6531f8e798663efd442f42093d4549a52391d04 /indoteknik_custom/models
parentac37a854362dbaaf8a88431ea5ab077a37f3c5f9 (diff)
Update __manifest__.py, __init__.py, and 3 more files...
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order.py14
-rw-r--r--indoteknik_custom/models/users.py10
3 files changed, 19 insertions, 6 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index e4913205..19916fd4 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -24,3 +24,4 @@ from . import stock_move
from . import stock_picking
from . import stock_picking_type
from . import delivery_order
+from . import users
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 2966eeed..a3226083 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -85,12 +85,12 @@ class PurchaseOrder(models.Model):
def button_confirm(self):
res = super(PurchaseOrder, self).button_confirm()
- test = self.env.user.id
- if self.total_percent_margin < self.total_so_percent_margin and self.env.user.id != 6:
+ test = self.env.user.is_leader
+ test2 = self.env.user.is_purchasing_manager
+ if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
raise UserError("Beda Margin dengan Sales, harus approval Manager")
- if not self.sale_order_id:
- if self.env.user.id != 6 and self.env.user.id != 7:
- raise UserError("Tidak ada link dengan SO, harus approval Manager")
+ if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
+ raise UserError("Tidak ada link dengan SO, harus approval Manager")
self.approval_status = 'approved'
# for line in self.order_line:
@@ -120,7 +120,9 @@ class PurchaseOrder(models.Model):
return res
def po_approve(self):
- if (self.total_percent_margin == self.total_so_percent_margin) and (self.env.user.id == 6 or self.env.user.id == 7):
+ if self.env.user.is_leader or self.env.user.is_purchasing_manager:
+ raise UserError("Bisa langsung Confirm")
+ elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id:
raise UserError("Bisa langsung Confirm")
else:
self.approval_status = 'pengajuan1'
diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py
new file mode 100644
index 00000000..bc56fe54
--- /dev/null
+++ b/indoteknik_custom/models/users.py
@@ -0,0 +1,10 @@
+from odoo import fields, models, api, _
+from odoo.exceptions import AccessError, UserError, ValidationError
+
+
+class Users(models.Model):
+ _inherit = 'res.users'
+
+ is_purchasing_manager = fields.Boolean(String='Purchasing Manager', help='Berhak melakukan Approval PO')
+ is_sales_manager = fields.Boolean(String='Sales Manager', help='Berhak melakukan Approval SO dengan margin 15-25')
+ is_leader = fields.Boolean(String='Leader', help='Berhak Approval SO Margin < 15 dan Approval PO')