diff options
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/approval_retur_picking.py | 38 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 16 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/approval_retur_picking.xml | 27 |
6 files changed, 83 insertions, 1 deletions
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"<div style='background-color: #fdf2e9; border: 1px solid #f5c6cb; padding: 10px;'>" + f"<b>Note Return (Pinned):</b><br>{self.note_return}</div>", + 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 @@ +<odoo> + <!-- Form View for Stock Return Note Wizard --> + <record id="view_stock_return_note_form" model="ir.ui.view"> + <field name="name">approval.retur.picking.form</field> + <field name="model">approval.retur.picking</field> + <field name="arch" type="xml"> + <form string="Add Return Note"> + <group> + <field name="note_return" placeholder="Enter return note here..." /> + </group> + <footer> + <button name="action_confirm_note_return" string="Confirm" type="object" class="btn-primary"/> + <button string="Cancel" class="btn-secondary" special="cancel"/> + </footer> + </form> + </field> + </record> + + <!-- Action to Open the Wizard --> + <record id="action_stock_return_note_wizard" model="ir.actions.act_window"> + <field name="name">Add Return Note</field> + <field name="res_model">approval.retur.picking</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_stock_return_note_form"/> + <field name="target">new</field> + </record> +</odoo> |
