diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e104038 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class + +# Odoo +*.hot-update.js +*.hot-update.json +.odoo/ + +# VS Code +.vscode/ + +# System +.DS_Store +Thumbs.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..96e9f41 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Approval Create WH to Prep Move + +This module creates an Inventory Transfer from an Approval Request. + +## Features + +- **Create Inventory Transfer**: adds a button "Create WH to Prep Move" to the Approval Request form (visible when approved). +- **Automatic Transfer Creation**: Creates a delivery order with operation type "Brigjend Katamso: WH to Prep (Send)" and destination "Physical Locations/Inter-warehouse transit". +- **Status Tracking**: + - Adds a new status "WH Sent" to the Approval Request. + - Automatically updates the status to "WH Sent" when the inventory transfer is created. + - Displays "WH Sent" status in the statusbar and with a distinct color in the list view. +- **Link to Transfer**: Adds a smart button to view the created transfer(s). + +## Configuration + +Ensure the following are configured in your database: +- Operation Type: "Brigjend Katamso: WH to Prep (Send)" +- Destination Location: "Physical Locations/Inter-warehouse transit" + +## Usage + +1. Create a new Approval Request with the appropriate category. +2. Submit and get it approved. +3. One approved, click the "Create WH to Prep Move" button. +4. The system will create the inventory transfer and change the approval status to "WH Sent". diff --git a/models/__pycache__/approval_request.cpython-312.pyc b/models/__pycache__/approval_request.cpython-312.pyc index 0273667..b5994ee 100644 Binary files a/models/__pycache__/approval_request.cpython-312.pyc and b/models/__pycache__/approval_request.cpython-312.pyc differ diff --git a/models/approval_request.py b/models/approval_request.py index 7384ae2..d0603bc 100644 --- a/models/approval_request.py +++ b/models/approval_request.py @@ -8,6 +8,8 @@ class ApprovalRequest(models.Model): picking_ids = fields.Many2many('stock.picking',compute='_compute_picking_ids', string='Transfers') picking_count = fields.Integer(compute='_compute_picking_count') + wh_move_created = fields.Boolean("WH Move Created", copy=False) + request_status = fields.Selection(selection_add=[('wh_sent', 'WH Sent')]) def _compute_picking_ids(self): for request in self: @@ -18,6 +20,12 @@ class ApprovalRequest(models.Model): for request in self: request.picking_count = len(request.picking_ids) + def _compute_request_status(self): + super()._compute_request_status() + for request in self: + if request.request_status == 'approved' and request.wh_move_created: + request.request_status = 'wh_sent' + def action_create_wh_prep_move(self): self.ensure_one() if self.picking_count > 0: @@ -70,6 +78,8 @@ class ApprovalRequest(models.Model): picking = self.env['stock.picking'].create(picking_vals) picking.action_confirm() # Confirm the picking to reserve stock if possible + self.wh_move_created = True + msg = Markup(_("Created Inventory Transfer: %s")) % (picking.id, picking.name) self.message_post(body=msg) @@ -84,3 +94,4 @@ class ApprovalRequest(models.Model): 'context': clean_context(self.env.context), } return action + diff --git a/views/approval_request_views.xml b/views/approval_request_views.xml index ca76e3c..c8ad7b5 100644 --- a/views/approval_request_views.xml +++ b/views/approval_request_views.xml @@ -23,4 +23,29 @@ + + + approval.wh.prep.move.request.view.tree.inherit + approval.request + + + + request_status == 'new' or request_status == 'wh_sent' + request_status == 'pending' + request_status == 'approved' + request_status == 'refused' + + + + + + approval.wh.prep.move.request.view.form.inherit.statusbar + approval.request + + + + new,pending,approved,wh_sent,refused + + +