~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to sale_line_import/wizard/sale_line_import.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-02 16:24:49 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120102162449-lhxnrtif2ud36du2

[ADD] Added new module invoice_so.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
###########################################################################
3
 
#    Module Writen to OpenERP, Open Source Management Solution
4
 
#
5
 
#    Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6
 
#    All Rights Reserved.
7
 
#    info@vauxoo.com
8
 
############################################################################
9
 
#    Coded by: julio (julio@vauxoo.com)
10
 
############################################################################
11
 
#
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.
16
 
#
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.
21
 
#
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/>.
24
 
#
25
 
##############################################################################
26
 
 
27
 
import pooler
28
 
import base64
29
 
import cStringIO
30
 
import openerp.netsvc as netsvc
31
 
from openerp.tools.translate import _
32
 
 
33
 
import openerp.tools as tools
34
 
import os
35
 
from openerp.osv import osv, fields
36
 
 
37
 
 
38
 
class wizard_import(osv.TransientModel):
39
 
    _name = 'wizard.import'
40
 
    _columns = {
41
 
        'name': fields.binary('File'),
42
 
        'msg': fields.text('Messages', readonly=True),
43
 
        'validate': fields.boolean('Validate?')
44
 
    }
45
 
 
46
 
    def send_lines(self, cr, uid, ids, context=None):
47
 
        if context is None:
48
 
            context = {}
49
 
        form = self.read(cr, uid, ids, [])
50
 
        order_id = context.get('active_id', False)
51
 
        fdata = form and base64.decodestring(form[0]['name']) or False
52
 
        fvalidate = form and form[0]['validate'] or False
53
 
        msg = self.pool.get('sale.order').import_data_line(
54
 
            cr, uid, order_id, fdata, fvalidate, context=context)
55
 
        if msg:
56
 
            self.write(cr, uid, ids, {'msg': msg})
57
 
            return True
58
 
        return {}