From aa59f0f8f3edfc0aa1e257b35d5c6e83b8f6978c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 19 Jun 2023 16:48:16 +0700 Subject: receipt approval in logistic --- indoteknik_custom/models/stock_picking.py | 32 ++++++++++++++++++++----------- indoteknik_custom/models/users.py | 12 +++++++----- indoteknik_custom/views/stock_picking.xml | 2 +- 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 @@ - @@ -53,8 +52,6 @@ - - + + + + + + -- cgit v1.2.3 From c1a0d0e48ef64241c92947a8800f93af4ff109d0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 21 Jun 2023 10:25:26 +0700 Subject: fix approval receipt and hide uneccesary column --- indoteknik_custom/models/stock_picking.py | 36 ++++++++++++++++++------------ indoteknik_custom/views/purchase_order.xml | 1 + indoteknik_custom/views/sale_order.xml | 1 + indoteknik_custom/views/stock_picking.xml | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d8c24e10..a14e71a3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -284,25 +284,33 @@ class StockPicking(models.Model): if self.group_id.sale_id.payment_status != 'settlement': raise UserError('Uang belum masuk (settlement), mohon konfirmasi ke sales atau finance') - 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 distribute calendar 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 line in self.move_line_ids_without_package: - if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing': + if self.picking_type_id.code == 'outgoing': + for line in self.move_line_ids_without_package: if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty: raise UserError("Qty Delivered akan lebih dari Qty SO") + elif self.picking_type_id.code == 'incoming': + for line in self.move_ids_without_package: + if line.purchase_line_id.qty_received + line.quantity_done > line.purchase_line_id.product_qty: + raise UserError('Qty Received akan lebih dari Qty PO') - self.approval_status = 'approved' + if self.is_internal_use: + self.approval_status = 'approved' + elif self.picking_type_id.code == 'incoming': + self.approval_receipt_status = 'approved' res = super(StockPicking, self).button_validate() self.calculate_line_no() diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 7a397ff6..5b0c99ef 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -24,6 +24,7 @@