From 7c56f5cbd4a19532f88eea36204bb4dc671f9017 Mon Sep 17 00:00:00 2001 From: lreficent Date: Wed, 10 May 2017 18:35:09 +0200 Subject: [PATCH] [9.0][FIX] stock_cycle_count: fields only editable in draft and add tracking to some of them. --- stock_cycle_count/models/stock_cycle_count.py | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/stock_cycle_count/models/stock_cycle_count.py b/stock_cycle_count/models/stock_cycle_count.py index da65d8115..533a93d73 100644 --- a/stock_cycle_count/models/stock_cycle_count.py +++ b/stock_cycle_count/models/stock_cycle_count.py @@ -27,30 +27,33 @@ class StockCycleCount(models.Model): return company_id name = fields.Char(string='Name', readonly=True) - location_id = fields.Many2one(comodel_name='stock.location', - string='Location', - required=True) - responsible_id = fields.Many2one(comodel_name='res.users', - string='Assigned to') - date_deadline = fields.Date(string='Required Date') + location_id = fields.Many2one( + comodel_name='stock.location', string='Location', required=True, + readonly=True, states={'draft': [('readonly', False)]}) + responsible_id = fields.Many2one( + comodel_name='res.users', string='Assigned to', + readonly=True, states={'draft': [('readonly', False)]}, + track_visibility='onchange') + date_deadline = fields.Date( + string='Required Date', readonly=True, + states={'draft': [('readonly', False)]}) cycle_count_rule_id = fields.Many2one( - comodel_name='stock.cycle.count.rule', - string='Cycle count rule', - required=True) + comodel_name='stock.cycle.count.rule', string='Cycle count rule', + required=True, readonly=True, states={'draft': [('readonly', False)]}) state = fields.Selection(selection=[ ('draft', 'Planned'), ('open', 'Execution'), ('cancelled', 'Cancelled'), ('done', 'Done') - ], string='State', default='draft') + ], string='State', default='draft', track_visibility='onchange') stock_adjustment_ids = fields.One2many(comodel_name='stock.inventory', inverse_name='cycle_count_id', - string='Inventory Adjustment') + string='Inventory Adjustment', + track_visibility='onchange') inventory_adj_count = fields.Integer(compute=_count_inventory_adj) - company_id = fields.Many2one(comodel_name='res.company', - string='Company', - required=True, - default=_company_get) + company_id = fields.Many2one( + comodel_name='res.company', string='Company', required=True, + default=_company_get, readonly=True) @api.one def do_cancel(self):