1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import fields, osv
24
class mrp_reversed_bom(osv.osv_memory):
25
_name = "mrp.reversed.bom"
26
_description = "Reversed Bom"
31
def do_reverse(self, cr, uid, ids, context={}):
32
""" To check the product type
33
@param self: The object pointer.
34
@param cr: A database cursor
35
@param uid: ID of the user currently logged in
36
@param ids: the ID or list of IDs if we want more than one
37
@param context: A standard dictionary
40
bom_obj = self.pool.get('mrp.bom')
41
bom_ids = context['active_ids']
42
bom_ids = bom_obj.browse(cr, uid, context['active_ids'])
43
for bom_id in bom_ids:
44
new_bom_id = bom_obj.copy(cr, uid, bom_id.id, {'name': 'Reversed ' + bom_id.name,
45
'product_qty':(-1)*bom_id.product_qty,
47
'product_uos_qty':(-1)*bom_id.product_uos_qty
49
for b in bom_id.bom_lines:
51
bom_obj.copy(cr, uid, b.id, {'name': 'reversed' + b.name,
53
'product_qty':(-1)*b.product_qty,
54
'product_uos_qty':(-1)*b.product_uos_qty