~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to deliver_project/model/module.py

  • Committer: Sabrina Romero
  • Date: 2013-08-20 21:10:39 UTC
  • mto: (543.7.272 vaddddddd)
  • mto: This revision was merged to the branch mainline in revision 840.
  • Revision ID: sabrina@vauxoo.com-20130820211039-9jqrffvg2nz8q3vx

[ADD] Module product_do_merge added

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- encoding: utf-8 -*-
2
2
##############################################################################
3
3
#
4
 
#    OpenERP, Open Source Management Solution    
 
4
#    OpenERP, Open Source Management Solution
5
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6
6
#    d$
7
7
#
33
33
import addons
34
34
import pooler
35
35
import release
36
 
import tools
37
 
 
38
 
from tools.parse_version import parse_version
39
 
from tools.translate import _
40
 
 
41
 
from osv import fields, osv, orm
42
 
class module(osv.osv):
43
 
    _inherit='ir.module.module'
44
 
    
45
 
    
46
 
    def get_doc_inside(self,cr,uid,ids,context=None):
 
36
import openerp.tools as tools
 
37
 
 
38
from openerp.tools.parse_version import parse_version
 
39
 
 
40
from openerp.tools.translate import _
 
41
 
 
42
 
 
43
from openerp.osv import osv, fields, orm
 
44
 
 
45
 
 
46
class module(osv.Model):
 
47
    _inherit = 'ir.module.module'
 
48
 
 
49
    def get_doc_inside(self, cr, uid, ids, context=None):
47
50
        """
48
51
        Doc in classes on my module
49
52
        """
52
55
#            print A
53
56
        return "DOCUMENTACION DOCUMENTACION \n MAS DOCUMENTACION"
54
57
 
55
 
 
56
 
    def format_help(self,cr,uid,dict_txt,context={}):
 
58
    def format_help(self, cr, uid, dict_txt, context={}):
57
59
        '''
58
60
        {'MenuName':menu.name,
59
61
        'CompleteMenuName':menu.complete_name,
62
64
        'XmlId':data_id.name}
63
65
        :return docStr Variable with wiki text.
64
66
        '''
65
 
        docStr=''
66
 
        Name=dict_txt.get('MenuName')
67
 
        CompleteMenuName=dict_txt.get('CompleteMenuName')
68
 
        ActionHelp=dict_txt.get('ActionHelp')
69
 
        ModuleName=dict_txt.get('ModuleName')
70
 
        XmlId=dict_txt.get('XmlId')
 
67
        docStr = ''
 
68
        Name = dict_txt.get('MenuName')
 
69
        CompleteMenuName = dict_txt.get('CompleteMenuName')
 
70
        ActionHelp = dict_txt.get('ActionHelp')
 
71
        ModuleName = dict_txt.get('ModuleName')
 
72
        XmlId = dict_txt.get('XmlId')
71
73
        if Name:
72
 
            docStr=docStr+"===%s==="%Name
 
74
            docStr = docStr+"===%s===" % Name
73
75
        if XmlId:
74
 
            docStr=docStr+"\nimage: %s.jpeg"%XmlId
 
76
            docStr = docStr+"\nimage: %s.jpeg" % XmlId
75
77
        if CompleteMenuName:
76
 
            docStr=docStr+"\n''%s''"%CompleteMenuName
 
78
            docStr = docStr+"\n''%s''" % CompleteMenuName
77
79
        if ActionHelp:
78
 
            docStr=docStr+"\n%s"%ActionHelp
 
80
            docStr = docStr+"\n%s" % ActionHelp
79
81
        return docStr
80
82
 
81
 
 
82
 
    def title_help(self,cr,uid,mod_id,module,context={}):
 
83
    def title_help(self, cr, uid, mod_id, module, context={}):
83
84
        '''
84
85
        {'CompleteModuleName':action.__module__
85
86
        'ModuleName':action.__module__}
86
87
        :return docStr Variable with wiki text.
87
88
        '''
88
 
        docStr="==%s==\n%s"%(self.browse(cr,uid,
89
 
                                     mod_id,
90
 
                                     context=context).shortdesc,
91
 
                                     self.sub_title_help(cr,uid,module,
92
 
                                                         context=context))
 
89
        docStr = "==%s==\n%s" % (self.browse(cr, uid,
 
90
                                             mod_id,
 
91
                                             context=context).shortdesc,
 
92
                                 self.sub_title_help(cr, uid, module,
 
93
                                                     context=context))
93
94
        return docStr
94
95
 
95
 
 
96
 
    def sub_title_help(self,cr,uid,module_name,context={}):
 
96
    def sub_title_help(self, cr, uid, module_name, context={}):
97
97
        '''
98
98
        Subtitle generator
99
99
        :return docStr Variable with wiki text.
100
100
        '''
101
 
        docStr="'''Technical Name: ''' ''%s''"%module_name
 
101
        docStr = "'''Technical Name: ''' ''%s''" % module_name
102
102
        return docStr
103
103
 
104
104
    def _get_docs(self, cr, uid, ids, field_name=None, arg=None, context=None):
125
125
 
126
126
        if not mnames:
127
127
            return res
128
 
        #VIEWS AND REPORTS AND MENUS RELATED TO ONE SPECIFIC MODULE
129
 
        view_id = model_data_obj.search(cr,uid,[('module','in', mnames.keys()),
130
 
            ('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu','ir.actions.act_window'))])
 
128
        # VIEWS AND REPORTS AND MENUS RELATED TO ONE SPECIFIC MODULE
 
129
        view_id = model_data_obj.search(
 
130
            cr, uid, [('module', 'in', mnames.keys()),
 
131
                      ('model', 'in', ('ir.ui.view', 'ir.actions.report.xml',
 
132
                                    'ir.ui.menu', 'ir.actions.act_window'))])
131
133
#            ('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu','ir.actions.act_window'))])
132
 
        for data_id in model_data_obj.browse(cr,uid,view_id,context):
 
134
        for data_id in model_data_obj.browse(cr, uid, view_id, context):
133
135
            # We use try except, because views or menus may not exist
134
136
            try:
135
137
                key = data_id.model
136
138
                res_mod_dic = res[mnames[data_id.module]]
137
 
                #Just MEnu with actions:
138
 
                if data_id.model=='ir.ui.menu':
139
 
                    menu=menu_obj.browse(cr,uid,data_id.res_id,context=context)
140
 
                    if menu.action._table_name=='ir.actions.act_window':
 
139
                # Just MEnu with actions:
 
140
                if data_id.model == 'ir.ui.menu':
 
141
                    menu = menu_obj.browse(
 
142
                        cr, uid, data_id.res_id, context=context)
 
143
                    if menu.action._table_name == 'ir.actions.act_window':
141
144
                        if menu.action:
142
145
                            print "-.-.-.-.-.-.-.-.-.-.-.-.- %s" % data_id.name
143
 
                            res_mod_dic['doc_on_module'].append("%s" % self.format_help(cr,uid,
144
 
                            {'MenuName':menu.name,
145
 
                            'CompleteMenuName':menu.complete_name,
146
 
                            'ActionHelp':menu.action.help,
147
 
                            'ModuleName':data_id.module,
148
 
                            'XmlId':data_id.name},
149
 
                            context=context))
150
 
                            res_mod_dic['doc_on_module'].append(self.title_help(cr,uid,
151
 
                                                            mnames[data_id.module],data_id.module,context=context))
 
146
                            res_mod_dic[
 
147
                                'doc_on_module'].append("%s" %
 
148
                                    self.format_help(cr, uid,
 
149
                                        {'MenuName': menu.name,
 
150
                                         'CompleteMenuName': menu.complete_name,
 
151
                                         'ActionHelp': menu.action.help,
 
152
                                         'ModuleName': data_id.module,
 
153
                                         'XmlId': data_id.name},
 
154
                                        context=context))
 
155
                            res_mod_dic[
 
156
                                'doc_on_module'].append(self.title_help(cr, uid,
 
157
                                        mnames[data_id.module],
 
158
                                        data_id.module, context=context))
152
159
            except KeyError, e:
153
160
                self.__logger.warning(
154
 
                            'Data not found for reference %s[%s:%s.%s]', data_id.model,
155
 
                            data_id.res_id, data_id.model, data_id.name, exc_info=True)
 
161
                    'Data not found for reference %s[%s:%s.%s]', data_id.model,
 
162
                    data_id.res_id, data_id.model, data_id.name, exc_info=True)
156
163
                pass
157
164
            except Exception, e:
158
165
                self.__logger.warning('Unknown error while browsing %s[%s]',
159
 
                            data_id.model, data_id.res_id, exc_info=True)
 
166
                                        data_id.model, data_id.res_id,
 
167
                                        exc_info=True)
160
168
                pass
161
 
        #res_mod_dic['doc_on_module']=list(set(res_mod_dic['doc_on_module']))
 
169
        # res_mod_dic['doc_on_module']=list(set(res_mod_dic['doc_on_module']))
162
170
        for key, value in res.iteritems():
163
 
            for k, v in res[key].iteritems() :
164
 
                #TODO Make Generic or with regEx
165
 
                #Putting title on the begining.
166
 
                 txt = "\n".join(sorted(v[:len(v)-2]))
167
 
                 res[key][k] = txt
 
171
            for k, v in res[key].iteritems():
 
172
                # TODO Make Generic or with regEx
 
173
                # Putting title on the begining.
 
174
                txt = "\n".join(sorted(v[:len(v)-2]))
 
175
                res[key][k] = txt
168
176
        return res
169
 
        
170
 
    _columns={
171
 
    'doc_on_module': fields.function(_get_docs, method=True, string='Documentation', type='text', multi="meta", store=False),
 
177
 
 
178
    _columns = {
 
179
        'doc_on_module': fields.function(_get_docs, method=True,
 
180
            string='Documentation', type='text', multi="meta", store=False),
172
181
    }
173
 
 
174
 
module()