[9.0][IMP] stock_cycle_count: The configuration of an inventory adjustment related to a cycle count cannot be modified.

This commit is contained in:
lreficent
2017-05-11 19:00:25 +02:00
committed by Lois Rilo
parent 61407007af
commit f958b14a1f

View File

@@ -3,7 +3,8 @@
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from openerp import api, fields, models, _
from openerp.exceptions import UserError
PERCENT = 100.0
@@ -22,9 +23,9 @@ class StockInventory(models.Model):
if not self.line_ids and self.state == 'done':
self.inventory_accuracy = 100.0
cycle_count_id = fields.Many2one(comodel_name='stock.cycle.count',
string='Stock Cycle Count',
ondelete='cascade')
cycle_count_id = fields.Many2one(
comodel_name='stock.cycle.count', string='Stock Cycle Count',
ondelete='cascade', readonly=True)
inventory_accuracy = fields.Float(string='Accuracy',
compute=_compute_inventory_accuracy,
digits=(3, 2))
@@ -34,3 +35,13 @@ class StockInventory(models.Model):
if self.cycle_count_id:
self.cycle_count_id.state = 'done'
return super(StockInventory, self).action_done()
@api.multi
def write(self, vals):
for inventory in self:
if (inventory.cycle_count_id and 'state' not in vals.keys() and
inventory.state == 'draft'):
raise UserError(
_('You cannot modify the configuration of an Inventory '
'Adjustment related to a Cycle Count.'))
return super(StockInventory, self).write(vals)