diff options
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 18 | ||||
| -rw-r--r-- | indoteknik_custom/models/users.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 7 | ||||
| -rw-r--r-- | indoteknik_custom/views/users.xml | 1 |
4 files changed, 27 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 221aff31..70e9b68a 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -43,6 +43,22 @@ class StockPicking(models.Model): copy=False ) + approval_status = fields.Selection([ + ('pengajuan1', 'Approval Accounting'), + ('approved', 'Approved'), + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) + + def ask_approval(self): + if self.env.user.is_accounting: + raise UserError("Bisa langsung Validate") + for pick in self: + if not pick.is_internal_use: + raise UserError("Selain Internal Use bisa langsung Validate") + for line in pick.move_line_ids_without_package: + if line.qty_done <= 0: + raise UserError("Qty tidak boleh 0") + pick.approval_status = 'pengajuan1' + def calculate_line_no(self): line_no = 0 for picking in self: @@ -74,6 +90,8 @@ class StockPicking(models.Model): def button_validate(self): 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() return res diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index bc56fe54..4904a33d 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -8,3 +8,4 @@ class Users(models.Model): 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') + is_accounting = fields.Boolean(String='Accounting', help='Berhak Approval Internal Use') diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 5f78ea57..1b648d58 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -6,6 +6,12 @@ <field name="model">stock.picking</field> <field name="inherit_id" ref="stock.view_picking_form"/> <field name="arch" type="xml"> + <button name="action_confirm" position="before"> + <button name="ask_approval" + string="Ask Approval" + type="object" + /> + </button> <div class="oe_title" position="after"> <button name="calculate_line_no" string="Line No" @@ -25,6 +31,7 @@ <field name="count_line_detail"/> </field> <field name="origin" position="after"> + <field name="approval_status"/> <field name="summary_qty_operation"/> <field name="count_line_operation"/> <field name="account_id" diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml index d75b35fc..29d455d4 100644 --- a/indoteknik_custom/views/users.xml +++ b/indoteknik_custom/views/users.xml @@ -7,6 +7,7 @@ <field name="inherit_id" ref="base.view_users_form"/> <field name="arch" type="xml"> <field name="tz_offset" position="after"> + <field name="is_accounting"/> <field name="is_purchasing_manager"/> <field name="is_sales_manager"/> <field name="is_leader"/> |
