[IMP][account_asset_management] Define a list of move's fields that can't be modified if a move is linked with a depriciation line

This commit is contained in:
Adrien Peiffer (ACSONE)
2015-05-29 08:02:10 +02:00
parent d22c13e786
commit 07ece3d6f7

View File

@@ -26,6 +26,10 @@ from openerp.tools.translate import _
import logging
_logger = logging.getLogger(__name__)
# List of move's fields that can't be modified if move is linked
# with a depreciation line
FIELDS_AFFETCS_ASSET_MOVE = ['period_id', 'journal_id', 'date']
class account_move(orm.Model):
_inherit = 'account.move'
@@ -51,7 +55,7 @@ class account_move(orm.Model):
cr, uid, ids, context=context, check=check)
def write(self, cr, uid, ids, vals, context=None):
if vals:
if set(vals).intersection(set(FIELDS_AFFETCS_ASSET_MOVE)):
if isinstance(ids, (int, long)):
ids = [ids]
depr_obj = self.pool.get('account.asset.depreciation.line')