38
from tools.parse_version import parse_version
39
from tools.translate import _
41
from osv import fields, osv, orm
42
class module(osv.osv):
43
_inherit='ir.module.module'
46
def get_doc_inside(self,cr,uid,ids,context=None):
36
import openerp.tools as tools
38
from openerp.tools.parse_version import parse_version
40
from openerp.tools.translate import _
43
from openerp.osv import osv, fields, orm
46
class module(osv.Model):
47
_inherit = 'ir.module.module'
49
def get_doc_inside(self, cr, uid, ids, context=None):
48
51
Doc in classes on my module
62
64
'XmlId':data_id.name}
63
65
:return docStr Variable with wiki text.
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')
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')
72
docStr=docStr+"===%s==="%Name
74
docStr = docStr+"===%s===" % Name
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
78
docStr=docStr+"\n%s"%ActionHelp
80
docStr = docStr+"\n%s" % ActionHelp
82
def title_help(self,cr,uid,mod_id,module,context={}):
83
def title_help(self, cr, uid, mod_id, module, context={}):
84
85
{'CompleteModuleName':action.__module__
85
86
'ModuleName':action.__module__}
86
87
:return docStr Variable with wiki text.
88
docStr="==%s==\n%s"%(self.browse(cr,uid,
90
context=context).shortdesc,
91
self.sub_title_help(cr,uid,module,
89
docStr = "==%s==\n%s" % (self.browse(cr, uid,
91
context=context).shortdesc,
92
self.sub_title_help(cr, uid, module,
96
def sub_title_help(self,cr,uid,module_name,context={}):
96
def sub_title_help(self, cr, uid, module_name, context={}):
99
99
:return docStr Variable with wiki text.
101
docStr="'''Technical Name: ''' ''%s''"%module_name
101
docStr = "'''Technical Name: ''' ''%s''" % module_name
104
104
def _get_docs(self, cr, uid, ids, field_name=None, arg=None, context=None):
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
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':
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},
150
res_mod_dic['doc_on_module'].append(self.title_help(cr,uid,
151
mnames[data_id.module],data_id.module,context=context))
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},
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)
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,
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]))
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]))
171
'doc_on_module': fields.function(_get_docs, method=True, string='Documentation', type='text', multi="meta", store=False),
179
'doc_on_module': fields.function(_get_docs, method=True,
180
string='Documentation', type='text', multi="meta", store=False),