diff options
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 14 | ||||
| -rw-r--r-- | indoteknik_custom/models/users.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/views/users.xml | 17 |
5 files changed, 38 insertions, 7 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 937fb0c9..0d6da7f1 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -38,10 +38,11 @@ 'views/stock_location.xml', 'views/stock_picking.xml', 'views/stock_picking_type.xml', + 'views/users.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', - 'report/purchase_order.xml' + 'report/purchase_order.xml', ], 'demo': [], 'css': [], 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') diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml new file mode 100644 index 00000000..d75b35fc --- /dev/null +++ b/indoteknik_custom/views/users.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="users_form_view_inherit" model="ir.ui.view"> + <field name="name">User</field> + <field name="model">res.users</field> + <field name="inherit_id" ref="base.view_users_form"/> + <field name="arch" type="xml"> + <field name="tz_offset" position="after"> + <field name="is_purchasing_manager"/> + <field name="is_sales_manager"/> + <field name="is_leader"/> + </field> + </field> + </record> + </data> +</odoo>
\ No newline at end of file |
