~vauxoo/addons-vauxoo/7.0-addons-vauxoo-send_email_add_follower-dev-julio

« back to all changes in this revision

Viewing changes to purchase_test_data_imp/wizard/test_yaml.py

  • Committer: Jorge Naranjo
  • Date: 2013-09-27 01:04:40 UTC
  • mto: This revision was merged to the branch mainline in revision 848.
  • Revision ID: tsu.jorgenaranjo@gmail.com-20130927010440-00kmtmazoauy8xk2
[IMP][sale_test_data_imp] Changed objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
#
 
20
##############################################################################
 
21
 
 
22
""" Modules (also called addons) management.
 
23
 
 
24
"""
 
25
import openerp.tools as tools
 
26
import os
 
27
from openerp.tools import assertion_report
 
28
import sys
 
29
import base64
 
30
from openerp.osv import osv, fields
 
31
 
 
32
class test_yaml_data(osv.osv_memory):
 
33
    
 
34
    _name = 'test.yaml.data'
 
35
    
 
36
    _columns = {
 
37
        'yaml_file': fields.binary('File sale order worng'),
 
38
        'yaml_file_log': fields.binary('File Log'),
 
39
        'filename': fields.char('File name', size=128, readonly=True, help='This is File name'),
 
40
        'filename_log': fields.char('File name log', size=128, readonly=True),
 
41
    }
 
42
    
 
43
    def test_sale (self, cr, uid, ids, context=None):
 
44
 
 
45
        assertion_obj = assertion_report.assertion_report()
 
46
        this = self.browse(cr, uid, ids)[0]
 
47
        fp_data = tools.file_open(os.path.join('sale_test_data', 'test/sale_order_test_data.xml'))
 
48
        fp_test = tools.file_open(os.path.join('sale_test_data', 'test/sale_order_product_can_be_sold.yml'))
 
49
        try:
 
50
            cr.execute("SAVEPOINT test_yaml_sale_savepoint")
 
51
            tools.convert_xml_import(cr, 'sale_test_data', fp_data , {}, 'init', False, assertion_obj)
 
52
            tools.convert_yaml_import(cr, 'sale_test_data', fp_test ,'test', {}, 'init', False, assertion_obj)
 
53
        finally:
 
54
            if commit:
 
55
                cr.execute("RELEASE SAVEPOINT test_yaml_sale_savepoint")
 
56
            else:
 
57
                cr.execute("ROLLBACK TO test_yaml_sale_savepoint")
 
58
            fp_data.close()
 
59
            fp_test.close()
 
60
            if tools.config['test_report_directory']:
 
61
                file_sale_order_wrong = base64.encodestring(open(os.path.join(tools.config['test_report_directory'], 'product_sale_order_wrong.csv'), 'rb+').read())
 
62
                file_sale_order_log = base64.encodestring(open(os.path.join(tools.config['test_report_directory'], 'product_sale_order_LOG.csv'), 'rb+').read())
 
63
                
 
64
                self.write(cr, uid, ids, {
 
65
                                'yaml_file': file_sale_order_wrong,
 
66
                                'yaml_file_log' : file_sale_order_log,
 
67
                                'filename': 'product_sale_order_wrong.csv',
 
68
                                'filename_log' : 'product_sale_order_LOG.csv',
 
69
                                }, context=context)
 
70
                                
 
71
        __, xml_id = self.pool.get('ir.model.data').get_object_reference(
 
72
                cr, uid, 'sale_test_data', 'view_wizard_sale_test_data_result')
 
73
                
 
74
        return {
 
75
                'res_model': 'test.yaml.data',
 
76
                'view_type': 'form',
 
77
                'view_mode': 'form',
 
78
                'view_id': xml_id,
 
79
                'res_id': this.id,
 
80
                'context': context,
 
81
                'type': 'ir.actions.act_window',
 
82
                'target': 'new',
 
83
            }