From 9b86d64f64e149d26b5e33254fefd5dfc15ce1c4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Oct 2024 09:03:21 +0700 Subject: approval retur picking --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/approval_retur_picking.py | 38 ++++++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 16 ++++++++- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/approval_retur_picking.xml | 27 +++++++++++++++ 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/approval_retur_picking.py create mode 100644 indoteknik_custom/views/approval_retur_picking.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c8a658b5..da44ebf3 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -145,6 +145,7 @@ 'views/approval_unreserve.xml', 'views/vendor_approval.xml', 'views/find_page.xml', + 'views/approval_retur_picking.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index e62fbb4a..4983cc17 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -131,3 +131,4 @@ from . import approval_unreserve from . import vendor_approval from . import partner from . import find_page +from . import approval_retur_picking diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py new file mode 100644 index 00000000..63639782 --- /dev/null +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -0,0 +1,38 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class ApprovalReturPicking(models.TransientModel): + _name = 'approval.retur.picking' + _description = 'Wizard to add Note Return' + + note_return = fields.Text(string="Note Return", required=True) + + def action_confirm_note_return(self): + picking_ids = self._context.get('picking_ids') + picking = self.env['stock.picking'].browse(picking_ids) + + # Update the note_return field + picking.update({ + 'note_return': self.note_return + }) + + # Post a highlighted message to lognote + picking.message_post( + body=f"
" + f"Note Return (Pinned):
{self.note_return}
", + subtype_id=self.env.ref("mail.mt_note").id + ) + + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Note berhasil ditambah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } + diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4c9d7658..107a6e72 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -104,6 +104,7 @@ class StockPicking(models.Model): ('to invoice', 'To Invoice'), ('no', 'Nothing to Invoice') ], string='Invoice Status', related="sale_id.invoice_status") + note_return = fields.Text(string="Note Return", help="Catatan untuk kirim barang kembali") state_reserve = fields.Selection([ ('waiting', 'Waiting For Fullfilment'), @@ -445,6 +446,11 @@ class StockPicking(models.Model): pick.approval_return_status = 'approved' else: pick.approval_return_status = 'pengajuan1' + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action def calculate_line_no(self): for picking in self: @@ -503,6 +509,9 @@ class StockPicking(models.Model): def button_validate(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + if self._name != 'stock.picking': return super(StockPicking, self).button_validate() @@ -553,6 +562,11 @@ class StockPicking(models.Model): self.date_done = datetime.datetime.utcnow() self.state_reserve = 'done' return res + def action_cancel(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + res = super(StockPicking, self).action_cancel() + return res @api.model def create(self, vals): @@ -688,4 +702,4 @@ class StockPicking(models.Model): formatted_fastest_eta = fastest_eta.strftime(format_time_fastest) formatted_longest_eta = longest_eta.strftime(format_time) - return f'{formatted_fastest_eta} - {formatted_longest_eta}' + return f'{formatted_fastest_eta} - {formatted_longest_eta}' \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 553047e6..06848ad7 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -143,3 +143,4 @@ access_vendor_approval_line,access.vendor.approval.line,model_vendor_approval_li access_vit_kota,access.vit.kota,model_vit_kota,,1,1,1,1 access_v_brand_product_category,access.v.brand.product.category,model_v_brand_product_category,,1,1,1,1 access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 +access_approval_retur_picking,access.approval.retur.picking,model_approval_retur_picking,,1,1,1,1 diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml new file mode 100644 index 00000000..ebe038d1 --- /dev/null +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -0,0 +1,27 @@ + + + + approval.retur.picking.form + approval.retur.picking + +
+ + + +
+
+
+
+
+ + + + Add Return Note + approval.retur.picking + form + + new + +
-- cgit v1.2.3 From 1bb2d9edb764ee3de50b0a005ff40aeef60bf5d6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 13:38:49 +0700 Subject: add approval sales manager and marketing manager on rpo --- indoteknik_custom/models/requisition.py | 16 ++++++++++++++++ indoteknik_custom/views/requisition.xml | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c4104ec5..a90a5718 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -22,15 +22,31 @@ class Requisition(models.Model): requisition_match = fields.One2many('requisition.purchase.match', 'requisition_id', string='Matches', auto_join=True) sale_order_id = fields.Many2one('sale.order', string='SO', help='harus diisi nomor SO yang ingin digenerate', domain="[('state', '=', 'sale')]") + sales_approve = fields.Boolean(string='Sales Approve', tracking=3, copy=False) + merchandise_approve = fields.Boolean(string='Merchandise Approve', tracking=3, copy=False) @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('requisition') or '0' result = super(Requisition, self).create(vals) return result + + def button_approve(self): + if self.env.user.id not in [377, 19]: + raise UserError('Hanya Vita dan Darren Yang Bisa Approve') + if self.env.user.id == 377: + self.sales_approve = True + elif self.env.user.id == 19: + if not self.sales_approve: + raise UserError('Vita Belum Approve') + self.merchandise_approve = True def create_po_from_requisition(self): + if not self.sales_approve: + raise UserError('Harus Di Approve oleh Vita') + if not self.merchandise_approve: + raise UserError('Harus Di Approve oleh Darren') if not self.requisition_lines: raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index b704baaf..cc537eda 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -50,6 +50,13 @@ requisition
+
+
-- cgit v1.2.3 From 4be403f544f63a5161275f0d600c6f6950f3a30c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 16:13:27 +0700 Subject: push --- indoteknik_custom/models/approval_retur_picking.py | 16 ++++++------- indoteknik_custom/models/requisition.py | 2 +- indoteknik_custom/models/stock_picking.py | 26 +++++++++++++++++----- indoteknik_custom/views/approval_retur_picking.xml | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py index 63639782..34c449a8 100644 --- a/indoteknik_custom/models/approval_retur_picking.py +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -8,7 +8,7 @@ class ApprovalReturPicking(models.TransientModel): _name = 'approval.retur.picking' _description = 'Wizard to add Note Return' - note_return = fields.Text(string="Note Return", required=True) + note_return = fields.Text(string="Note Return") def action_confirm_note_return(self): picking_ids = self._context.get('picking_ids') @@ -16,22 +16,22 @@ class ApprovalReturPicking(models.TransientModel): # Update the note_return field picking.update({ - 'note_return': self.note_return + 'approval_return_status': 'pengajuan1' }) # Post a highlighted message to lognote - picking.message_post( - body=f"
" - f"Note Return (Pinned):
{self.note_return}
", - subtype_id=self.env.ref("mail.mt_note").id - ) + # picking.message_post( + # body=f"
" + # f"Note Return (Pinned):
{self.note_return}
", + # subtype_id=self.env.ref("mail.mt_note").id + # ) return { 'type': 'ir.actions.client', 'tag': 'display_notification', 'params': { 'title': 'Notification', - 'message': 'Note berhasil ditambah', + 'message': 'Status pengajuan telah berubah', 'next': {'type': 'ir.actions.act_window_close'}, } } diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index a90a5718..89ed4a27 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -117,7 +117,7 @@ class Requisition(models.Model): 'product_id': product.id, 'product_qty': line.qty_purchase, 'product_uom_qty': line.qty_purchase, - 'name': product.name, + 'name': product.display_name, 'price_unit': line.price_unit, 'taxes_id': tax, } diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 107a6e72..ad31a2ba 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -445,14 +445,28 @@ class StockPicking(models.Model): if self.env.user.is_accounting: pick.approval_return_status = 'approved' else: - pick.approval_return_status = 'pengajuan1' - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') - action['context'] = { - 'picking_ids': [x.id for x in self] - } - return action + if self.picking_type_code == 'outgoing': + if self.env.user.id in [3988, 3401, 20]: + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Sales Admin yang Ask Return') + elif self.picking_type_code == 'incoming': + if self.env.user.has_group('indoteknik_custom.group_role_purchasing'): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Purchasing yang Ask Return') + def calculate_line_no(self): + for picking in self: name = picking.group_id.name for move in picking.move_ids_without_package: diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml index ebe038d1..5ce28e20 100644 --- a/indoteknik_custom/views/approval_retur_picking.xml +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -6,7 +6,7 @@ - + Ask Approval Retur?