From baafe0710c1fda73df482c513c36bc876e5e57d7 Mon Sep 17 00:00:00 2001 From: Ruchir Shukla Date: Wed, 16 Sep 2020 11:35:39 +0530 Subject: [PATCH] [FIX]make reason fields readonly if in done state --- stock_change_qty_reason/models/stock_inventory.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stock_change_qty_reason/models/stock_inventory.py b/stock_change_qty_reason/models/stock_inventory.py index 6c75d06a8..f755e28ab 100644 --- a/stock_change_qty_reason/models/stock_inventory.py +++ b/stock_change_qty_reason/models/stock_inventory.py @@ -6,8 +6,13 @@ from odoo import api, fields, models class StockInventory(models.Model): _inherit = "stock.inventory" - reason = fields.Char(help="Type in a reason for the " "product quantity change") - preset_reason_id = fields.Many2one("stock.inventory.line.reason") + reason = fields.Char( + help="Type in a reason for the " "product quantity change", + states={"done": [("readonly", True)]}, + ) + preset_reason_id = fields.Many2one( + "stock.inventory.line.reason", states={"done": [("readonly", True)]} + ) def _get_inventory_lines_values(self): vals = super(StockInventory, self)._get_inventory_lines_values()