new module to prompt for reason when applying a single inventory adjustment

This commit is contained in:
Marc Durepos 2025-09-03 11:15:33 -04:00
parent ce69990df6
commit c43a615dd4
5 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,20 @@
{
"name": "Stock Quant Apply Single Inventory with Reason",
"version": "18.0.1.0.0",
"category": "Inventory/Inventory",
"summary": "Add reason dialog when applying single inventory adjustment",
"description": """
This module modifies the behavior of the Apply button on stock quants to show
the same reason dialog as when using Apply All, ensuring consistency in
inventory adjustment tracking.
""",
"author": "Bemade",
"website": "https://bemade.org",
"depends": ["stock"],
"data": [
"views/stock_quant_views.xml",
],
"installable": True,
"auto_install": False,
"application": False,
}

View file

@ -0,0 +1 @@
from . import stock_quant

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
class StockQuant(models.Model):
_inherit = 'stock.quant'
def action_apply_single_inventory(self):
"""
New method that opens the same reason dialog as action_apply_all
for single inventory adjustments.
"""
ctx = dict(self.env.context or {}, default_quant_ids=self.ids)
view = self.env.ref('stock.stock_inventory_adjustment_name_form_view', False)
return {
'name': _('Inventory Adjustment Reference / Reason'),
'type': 'ir.actions.act_window',
'views': [(view.id, 'form')],
'res_model': 'stock.inventory.adjustment.name',
'target': 'new',
'context': ctx,
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_stock_quant_tree_inventory_editable_inherit" model="ir.ui.view">
<field name="name">stock.quant.tree.inventory.editable.inherit</field>
<field name="model">stock.quant</field>
<field name="inherit_id" ref="stock.view_stock_quant_tree_inventory_editable"/>
<field name="arch" type="xml">
<button name="action_apply_inventory" position="attributes">
<attribute name="name">action_apply_single_inventory</attribute>
</button>
</field>
</record>
</odoo>