2
#-*- encoding:utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2011 TeMPO Consulting, MSF. All Rights Reserved
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
25
from osv import fields
27
class real_average_consumption(osv.osv):
28
_name = 'real.average.consumption'
29
_inherit = 'real.average.consumption'
32
def action_cancel(self, cr, uid, ids, context=None):
33
""" Cancels stock move related to the lines of the Real Average Consumption (rac)
36
rac = self.browse(cr, uid, ids, context=context)[0]
37
move_obj = self.pool.get('stock.move')
40
for line in rac.line_ids:
41
move_ids.append(line.move_id.id)
42
move_obj.action_cancel(cr, uid, move_ids, context=context)
43
self.write(cr, uid, ids, {'created_ok': False}, context=context)
47
real_average_consumption()
50
class real_average_consumption_line(osv.osv):
51
_inherit = 'real.average.consumption.line'
53
# Need to redefine the asset_id field from char to m2o because the
54
# product_asset module is not loaded before consumption_calculation
57
'asset_id': fields.many2one('product.asset', string='Asset'),
60
real_average_consumption_line()