diff --git a/apply_inventory_prompt_for_reason/__init__.py b/apply_inventory_prompt_for_reason/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/apply_inventory_prompt_for_reason/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/apply_inventory_prompt_for_reason/__manifest__.py b/apply_inventory_prompt_for_reason/__manifest__.py new file mode 100644 index 0000000..099d01f --- /dev/null +++ b/apply_inventory_prompt_for_reason/__manifest__.py @@ -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, +} diff --git a/apply_inventory_prompt_for_reason/models/__init__.py b/apply_inventory_prompt_for_reason/models/__init__.py new file mode 100644 index 0000000..70f8e6c --- /dev/null +++ b/apply_inventory_prompt_for_reason/models/__init__.py @@ -0,0 +1 @@ +from . import stock_quant diff --git a/apply_inventory_prompt_for_reason/models/stock_quant.py b/apply_inventory_prompt_for_reason/models/stock_quant.py new file mode 100644 index 0000000..2175f90 --- /dev/null +++ b/apply_inventory_prompt_for_reason/models/stock_quant.py @@ -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, + } diff --git a/apply_inventory_prompt_for_reason/views/stock_quant_views.xml b/apply_inventory_prompt_for_reason/views/stock_quant_views.xml new file mode 100644 index 0000000..ed13e79 --- /dev/null +++ b/apply_inventory_prompt_for_reason/views/stock_quant_views.xml @@ -0,0 +1,13 @@ + + + + stock.quant.tree.inventory.editable.inherit + stock.quant + + + + + +