1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
26
from osv import osv, fields
28
class stock_picking(osv.osv):
29
_inherit = 'stock.picking'
31
def button_draft(self, cr, uid, ids, context=None):
32
print 'holaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
35
cr.execute('select id from sale_order_line where order_id IN %s and state=%s', (tuple(ids), 'cancel'))
36
line_ids = map(lambda x: x[0], cr.fetchall())
37
self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0})
38
self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]})
39
wf_service = netsvc.LocalService("workflow")
41
# Deleting the existing instance of workflow for SO
42
wf_service.trg_delete(uid, 'sale.order', inv_id, cr)
43
wf_service.trg_create(uid, 'sale.order', inv_id, cr)
44
for (id,name) in self.name_get(cr, uid, ids):
45
message = _("The sales order '%s' has been set in draft state.") %(name,)
46
self.log(cr, uid, id, message)