Vir (Open ERP)
2010-09-27 14:22:03 +05:30
10 changed files with 62 additions and 66 deletions
+1 -18
View File
@@ -209,16 +209,6 @@ class act_window(osv.osv):
res[act.id] = str(form_arch)
return res
def _get_help_status(self, cr, uid, ids, name, arg, context={}):
activate_tips = self.pool.get('res.users').browse(cr, uid, uid).menu_tips
if activate_tips:
cr.execute(""" SELECT action.id,
CASE WHEN r.uid IS NULL THEN True ELSE False END
AS help_status FROM ir_act_window action
LEFT JOIN ir_act_window_user_rel r ON
(action.id = r.act_id AND (r.uid IS NULL or r.uid= %s)) WHERE action.id = ANY(%s)""",(uid,ids,))
return dict(cr.fetchall())
_columns = {
'name': fields.char('Action Name', size=64, translate=True),
'type': fields.char('Action Type', size=32, required=True),
@@ -252,8 +242,6 @@ class act_window(osv.osv):
'menus': fields.char('Menus', size=4096),
'help': fields.text('Action description',
help='Optional help text for the users with a description of the target view, such as its usage and purpose.'),
'display_help':fields.function(_get_help_status, type='boolean', method=True, string='Display Help',
help='It gives the status if the help message has to be displayed or not when a user performs an action')
}
_defaults = {
@@ -266,12 +254,7 @@ class act_window(osv.osv):
'auto_refresh': lambda *a: 0,
'auto_search':lambda *a: True
}
def _auto_init(self, cr, context={}):
super(act_window, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'act_window_action_uid_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX act_window_action_uid_index ON ir_act_window_user_rel (act_id, uid)')
cr.commit()
act_window()
class act_window_view(osv.osv):
+2 -2
View File
@@ -162,9 +162,9 @@
<field name="installed_version"/>
<field name="latest_version"/>
<field name="state"/>
<button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object" help="Schedule for Installation"/>
<button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/>
<button name="button_install_cancel" states="to install" string="Cancel Install" icon="gtk-cancel" type="object"/>
<button name="button_upgrade" states="installed" string="Schedule Upgrade" icon="terp-gtk-go-back-rtl" type="object" help="Schedule Upgrade"/>
<button name="button_upgrade" states="installed" string="Schedule Upgrade" icon="terp-gtk-go-back-rtl" type="object"/>
<button name="button_uninstall" states="installed" string="Uninstall (beta)" icon="terp-dialog-close" type="object"/>
<button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" icon="gtk-cancel" type="object"/>
<button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" icon="gtk-cancel" type="object"/>
@@ -3,27 +3,24 @@
<data>
<record id="view_base_language_install" model="ir.ui.view">
<field name="name">Install Language</field>
<field name="name">Load Official Translation</field>
<field name="model">base.language.install</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="System Upgrade">
<group colspan="2" col="4">
<separator string="System Upgrade" colspan="6"/>
<newline/>
<label align="0.0" string="Choose a language to install:" colspan="4"/>
<field name="lang" colspan="4"/>
<label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/>
<separator string="" colspan="6"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="lang_install" string="Start installation" type="object" icon="gtk-ok"/>
</group>
</form>
<form string="Load Official Translation">
<separator string="Load an Official Translation" colspan="4"/>
<group colspan="4"><field name="lang"/></group>
<label string="" colspan="4"/>
<label string="Please be patient, as this operation may take a few minutes..." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="lang_install" string="Load" type="object" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="action_view_base_language_install" model="ir.actions.act_window">
<field name="name">Install Language</field>
<field name="name">Load Official Translation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.language.install</field>
<field name="view_type">form</field>
@@ -38,23 +35,21 @@
parent="menu_translation"/>
<record id="view_base_language_install_msg" model="ir.ui.view">
<field name="name">Install Language Message</field>
<field name="name">Official Translation Loaded</field>
<field name="model">base.module.import.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Language file loaded.">
<group colspan="2" col="4">
<separator string="Installation Done" colspan="4"/>
<label align="0.0" string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view changes." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="OK" icon="gtk-ok"/>
</group>
<form string="Official Translation Loaded">
<separator string="Official Translation Loaded" colspan="4"/>
<label string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view the changes." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="OK" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="action_view_base_language_install_msg" model="ir.actions.act_window">
<field name="name">Install Language Message</field>
<field name="name">Official Translation Loaded</field>
<field name="res_model">base.module.import.msg</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
+4 -4
View File
@@ -20,8 +20,9 @@
##############################################################################
from osv import osv,fields
from operator import attrgetter
from tools.misc import attrgetter
import time
# -------------------------------------------------------------------------
# Properties
# -------------------------------------------------------------------------
@@ -31,7 +32,6 @@ class ir_property(osv.osv):
def _models_field_get(self, cr, uid, field_key, field_value, context=None):
get = attrgetter(field_key, field_value)
obj = self.pool.get('ir.model.fields')
ids = obj.search(cr, uid, [('view_load','=',1)], context=context)
res = set()
@@ -40,7 +40,7 @@ class ir_property(osv.osv):
return res
def _models_get(self, cr, uid, context=None):
return self._models_field_get(cr, uid, 'model', 'name', context)
return self._models_field_get(cr, uid, 'model', 'model_id.name', context)
def _models_get2(self, cr, uid, context=None):
return self._models_field_get(cr, uid, 'relation', 'relation', context)
@@ -50,7 +50,7 @@ class ir_property(osv.osv):
'name': fields.char('Name', size=128, select=1),
'res_id': fields.reference('Resource', selection=_models_get, size=128,
help="If not set, act as default property", select=1),
help="If not set, acts as a default value for new resources", select=1),
'company_id': fields.many2one('res.company', 'Company', select=1),
'fields_id': fields.many2one('ir.model.fields', 'Field', ondelete='cascade', required=True, select=1),
+1 -1
View File
@@ -5,7 +5,7 @@
<assert
model="res.currency.rate"
search="[('currency_id', '=', ref('INR'))]"
count="3"
count="1"
string="Rate entries for Indian rupee">
<test expr="True"/>
</assert>
+3 -3
View File
@@ -6,15 +6,15 @@
<!-- model="res.currency"-->
<!-- id="INR"-->
<!-- string="Indian rupee rate in 2009">-->
<!-- <!-- date specified in data element's context -->-->
<!-- date specified in data element's context -->
<!-- <test expr="str(rate)">65.8287</test>-->
<!-- </assert>-->
<!-- </assert> -->
<assert
model="res.currency"
id="INR"
string="Indian rupee rate in 2002"
context="{'date': '2010-06-01'}">
<test expr="str(rate)">58.8287</test>
<test expr="str(rate)">59.9739</test>
</assert>
</data>
</openerp>
+2 -2
View File
@@ -350,7 +350,7 @@ class Agent(object):
delattr(current_thread, 'dbname')
task_thread = threading.Thread(target=function, name='netsvc.Agent.task', args=args, kwargs=kwargs)
# force non-daemon task threads (the runner thread must be daemon, and this property is inherited by default)
task_thread.daemon = False
task_thread.setDaemon(False)
task_thread.start()
time.sleep(1)
time.sleep(60)
@@ -359,7 +359,7 @@ agent_runner = threading.Thread(target=Agent.runner, name="netsvc.Agent.runner")
# the agent runner is a typical daemon thread, that will never quit and must be
# terminated when the main process exits - with no consequence (the processing
# threads it spawns are not marked daemon)
agent_runner.daemon = True
agent_runner.setDaemon(True)
agent_runner.start()
+4 -4
View File
@@ -182,8 +182,9 @@ def handler(signum, frame):
def dumpstacks(signum, frame):
# code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
# modified for python 2.5 compatibility
thread_map = dict(threading._active, **threading._limbo)
id2name = dict([(threadId, thread.getName()) for threadId, thread in thread_map.items()])
code = []
for threadId, stack in sys._current_frames().items():
code.append("\n# Thread: %s(%d)" % (id2name[threadId], threadId))
@@ -191,7 +192,6 @@ def dumpstacks(signum, frame):
code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
if line:
code.append(" %s" % (line.strip()))
logging.getLogger('dumpstacks').info("\n".join(code))
for signum in SIGNALS:
@@ -214,7 +214,7 @@ def quit():
# to trigger _force_quit() in case some non-daemon threads won't exit cleanly.
# threading.Thread.join() should not mask signals (at least in python 2.5)
for thread in threading.enumerate():
if thread != threading.currentThread() and not thread.daemon:
if thread != threading.currentThread() and not thread.isDaemon():
while thread.isAlive():
# need a busyloop here as thread.join() masks signals
# and would present the forced shutdown
+1 -2
View File
@@ -548,11 +548,10 @@ class orm_template(object):
else:
return False
lines = []
data = map(lambda x: '', range(len(fields)))
done = []
for fpos in range(len(fields)):
done = []
f = fields[fpos]
if f:
r = row
+26 -7
View File
@@ -419,6 +419,13 @@ def _email_send(smtp_from, smtp_to_list, message, openobject_id=None, ssl=False,
:return: True if the mail was delivered successfully to the smtp,
else False (+ exception logged)
"""
class WriteToLogger(object):
def __init__(self):
self.logger = netsvc.Logger()
def write(self, s):
self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s)
if openobject_id:
message['Message-Id'] = generate_tracking_message_id(openobject_id)
@@ -534,13 +541,6 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
part.add_header('Content-Disposition', 'attachment; filename="%s"' % (fname,))
msg.attach(part)
class WriteToLogger(object):
def __init__(self):
self.logger = netsvc.Logger()
def write(self, s):
self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s)
return _email_send(email_from, flatten([email_to, email_cc, email_bcc]), msg, openobject_id=openobject_id, ssl=ssl, debug=debug)
#----------------------------------------------------------
@@ -1406,5 +1406,24 @@ def upload_data(email, data, type='SURVEY'):
a = upload_data_thread(email, data, type)
a.start()
return True
# port of python 2.6's attrgetter with support for dotted notation
def resolve_attr(obj, attr):
for name in attr.split("."):
obj = getattr(obj, name)
return obj
def attrgetter(*items):
if len(items) == 1:
attr = items[0]
def g(obj):
return resolve_attr(obj, attr)
else:
def g(obj):
return tuple(resolve_attr(obj, attr) for attr in items)
return g
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: