diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-11-11 16:16:45 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-11-11 16:16:45 +0700 |
| commit | d8dd0813ff6760e4a06968967594d27c6fd3b9d5 (patch) | |
| tree | 264a18adb5e15c3ecd80b4790451698bbc6947d0 | |
| parent | 17d46cf9f4eede8177b2373c03d5b36123f712c1 (diff) | |
| parent | 4be403f544f63a5161275f0d600c6f6950f3a30c (diff) | |
Merge branch 'approval_retur_picking' into production
# Conflicts:
# indoteknik_custom/models/requisition.py
# indoteknik_custom/views/requisition.xml
| -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/requisition.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 32 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/approval_retur_picking.xml | 27 | ||||
| -rw-r--r-- | indoteknik_custom/views/requisition.xml | 8 |
8 files changed, 105 insertions, 9 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..34c449a8 --- /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") + + 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({ + 'approval_return_status': 'pengajuan1' + }) + + # 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': '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 3d9ca876..8ebdd31b 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -70,9 +70,9 @@ class Requisition(models.Model): def create_po_from_requisition(self): if not self.sales_approve: - raise UserError('Harus di Approve Vita') + raise UserError('Harus Di Approve oleh Vita') if not self.merchandise_approve: - raise UserError('Harus di Approve Darren') + 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: @@ -145,7 +145,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 1906dae0..ef26e002 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'), @@ -441,9 +442,28 @@ class StockPicking(models.Model): if self.env.user.is_accounting: pick.approval_return_status = 'approved' else: - pick.approval_return_status = 'pengajuan1' + 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: @@ -500,6 +520,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() @@ -550,6 +573,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): @@ -685,4 +713,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..5ce28e20 --- /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> + <span>Ask Approval Retur?</span> + </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> diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index a866690d..7b066bca 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -52,10 +52,10 @@ <form> <header> <button name="button_approve" - string="Approve" - type="object" - class="mr-2 oe_highlight" - /> + string="Approve" + type="object" + class="mr-2 oe_highlight" + /> </header> <sheet string="Requisition"> <div class="oe_button_box" name="button_box"/> |
