diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-06-19 16:48:16 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-06-19 16:48:16 +0700 |
| commit | aa59f0f8f3edfc0aa1e257b35d5c6e83b8f6978c (patch) | |
| tree | 21b7877eb043a183d1505efcf05f403a03371b47 | |
| parent | 63bc8cf104e4c8b0908df8f573d137fcf38c1b5c (diff) | |
receipt approval in logistic
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 32 | ||||
| -rw-r--r-- | indoteknik_custom/models/users.py | 12 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/users.xml | 1 |
4 files changed, 30 insertions, 17 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c8424121..74fd0356 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -54,6 +54,11 @@ class StockPicking(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Internal Use") + approval_receipt_status = fields.Selection([ + ('pengajuan1', 'Approval Logistic'), + ('approved', 'Approved'), + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Receipt") + approval_return_status = fields.Selection([ ('pengajuan1', 'Approval Finance'), ('approved', 'Approved'), @@ -184,17 +189,18 @@ class StockPicking(models.Model): if self.env.user.is_accounting: raise UserError("Bisa langsung Validate") - if self.is_internal_use: - stock_move_lines = self.env['stock.move.line'].search([ - ('picking_id', '!=', False), - ('product_id', '=', 236805), - ('picking_id.partner_id', '=', self.partner_id.id), - ('qty_done', '>', 0), - ]) - list_state = ['confirmed', 'done'] - for stock_move_line in stock_move_lines: - if stock_move_line.picking_id.state not in list_state: - continue + # for calendar distribute only + # if self.is_internal_use: + # stock_move_lines = self.env['stock.move.line'].search([ + # ('picking_id', '!=', False), + # ('product_id', '=', 236805), + # ('picking_id.partner_id', '=', self.partner_id.id), + # ('qty_done', '>', 0), + # ]) + # list_state = ['confirmed', 'done'] + # for stock_move_line in stock_move_lines: + # if stock_move_line.picking_id.state not in list_state: + # continue # raise UserError('Sudah pernah dikirim kalender') for pick in self: @@ -264,6 +270,10 @@ class StockPicking(models.Model): if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") + print(self.picking_type_id.id) + if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: + raise UserError("Harus di Approve oleh Eplin") + if self.group_id.sale_id: if self.group_id.sale_id.payment_link_midtrans: if self.group_id.sale_id.payment_status != 'settlement': diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index a2074c46..14fcae98 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -5,11 +5,13 @@ 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') - is_accounting = fields.Boolean(String='Accounting', help='Berhak Approval Internal Use') + 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') + is_logistic_approver = fields.Boolean(string='Logistic Approver', help='Berhak Approval Penerimaan Barang') def notify_internal_users(self, message, title): users = self.search([('share', '=', False)]) - users.notify_info(message=message, title=title)
\ No newline at end of file + users.notify_info(message=message, title=title) +
\ No newline at end of file diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 4bbdc7b8..02003e05 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -30,7 +30,7 @@ <button name="ask_return_approval" string="Ask Return/Acc" type="object" - attrs="{'invisible': ['|', ('state', '=', 'draft'), ('state', '=', 'cancel'), ('approval_return_status', '=', 'pengajuan1')]}" + attrs="{'invisible': ['|', ('state', 'in', ['draft', 'cancel', 'assigned']), ('approval_return_status', '=', 'pengajuan1')]}" /> <button name="action_create_invoice_from_mr" string="Create Bill" diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml index 29d455d4..25e7f90c 100644 --- a/indoteknik_custom/views/users.xml +++ b/indoteknik_custom/views/users.xml @@ -11,6 +11,7 @@ <field name="is_purchasing_manager"/> <field name="is_sales_manager"/> <field name="is_leader"/> + <field name="is_logistic_approver"/> </field> </field> </record> |
