feat: Enable creation of WH to Prep inventory transfers from approval requests and introduce 'WH Sent' status.
This commit is contained in:
parent
70ae5ea804
commit
2199fe86fc
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@ -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
|
||||
26
README.md
Normal file
26
README.md
Normal file
@ -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".
|
||||
Binary file not shown.
@ -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: <a href='#' data-oe-model='stock.picking' data-oe-id='%d'>%s</a>")) % (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
|
||||
|
||||
|
||||
@ -23,4 +23,29 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="approval_wh_prep_move_request_view_tree_inherit" model="ir.ui.view">
|
||||
<field name="name">approval.wh.prep.move.request.view.tree.inherit</field>
|
||||
<field name="model">approval.request</field>
|
||||
<field name="inherit_id" ref="approvals.approval_request_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='request_status']" position="attributes">
|
||||
<attribute name="decoration-info">request_status == 'new' or request_status == 'wh_sent'</attribute>
|
||||
<attribute name="decoration-warning">request_status == 'pending'</attribute>
|
||||
<attribute name="decoration-success">request_status == 'approved'</attribute>
|
||||
<attribute name="decoration-danger">request_status == 'refused'</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="approval_wh_prep_move_request_view_form_inherit_statusbar" model="ir.ui.view">
|
||||
<field name="name">approval.wh.prep.move.request.view.form.inherit.statusbar</field>
|
||||
<field name="model">approval.request</field>
|
||||
<field name="inherit_id" ref="approvals.approval_request_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='request_status']" position="attributes">
|
||||
<attribute name="statusbar_visible">new,pending,approved,wh_sent,refused</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user