2
# -*- encoding: utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2011 TeMPO Consulting, MSF
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
25
from osv import fields
27
from tools.translate import _
30
class stock_adjustment_type(osv.osv):
31
_name = 'stock.adjustment.type'
32
_description = 'Inventory/Move Adjustment Types'
35
'name': fields.char(size=64, string='Name', required=True),
38
stock_adjustment_type()
41
class stock_inventory_line(osv.osv):
42
_name = 'stock.inventory.line'
43
_inherit = 'stock.inventory.line'
46
'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type'),
47
'comment': fields.char(size=128, string='Comment'),
50
stock_inventory_line()
53
class stock_move(osv.osv):
55
_inherit = 'stock.move'
58
'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type', readonly=True),
59
'comment': fields.char(size=128, string='Comment'),
65
class stock_inventory(osv.osv):
66
_name = 'stock.inventory'
67
_inherit = 'stock.inventory'
69
# @@@override@ stock.stock_inventory._inventory_line_hook()
70
def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
71
""" Creates a stock move from an inventory line
72
@param inventory_line:
76
location_obj = self.pool.get('stock.location')
78
type_id = inventory_line.type_id and inventory_line.type_id.id or False
82
'comment': inventory_line.comment,
85
location = location_obj.browse(cr, uid, move_vals['location_dest_id'])
92
if location.usage == 'inventory':
93
reason_type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_loss')[1]
95
'reason_type_id': reason_type_id,
98
if location.scrap_location:
99
reason_type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_scrap')[1]
101
'reason_type_id': reason_type_id,
104
if inventory_line.type_id and type_id == self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock_inventory_type', 'adjustment_type_expired')[1]:
105
reason_type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_expiry')[1]
107
'reason_type_id': reason_type_id,
110
if inventory_line.location_id.id == move_vals.get('location_dest_id'):
111
reason_type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_discrepancy')[1]
113
'reason_type_id': reason_type_id,
116
return super(stock_inventory, self)._inventory_line_hook(cr, uid, inventory_line, move_vals)
121
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: