[IMP] Refactoring to improve res_log
bzr revid: nicolas.vanhoren@openerp.com-20101123143424-kj9uot206ei491yf
This commit is contained in:
parent
5303b58ef6
commit
226bbfee1b
|
@ -159,16 +159,17 @@ class publisher_warranty_contract(osv.osv):
|
|||
"interval_number": result["interval_number"],
|
||||
})
|
||||
|
||||
self.pool.get('res.log').create(cr, uid,
|
||||
{
|
||||
'name': result["message"] if isinstance(result["message"], str) or \
|
||||
isinstance(result["message"], unicode) else repr(result["message"]),
|
||||
'res_model': "Maintenance Notifications",
|
||||
"read": True,
|
||||
"broadcast": True,
|
||||
},
|
||||
context=context
|
||||
)
|
||||
for message in result["messages"]:
|
||||
self.pool.get('res.log').create(cr, uid,
|
||||
{
|
||||
'name': message if isinstance(message, str) or \
|
||||
isinstance(message, unicode) else message[0],
|
||||
'res_model': "publisher_warranty.contract",
|
||||
"read": True,
|
||||
"user_id": False,
|
||||
},
|
||||
context=context
|
||||
)
|
||||
except:
|
||||
_logger.debug("Exception while interpreting the result of a ping", exc_info=1)
|
||||
if cron_mode:
|
||||
|
@ -184,23 +185,13 @@ class publisher_warranty_contract(osv.osv):
|
|||
@return: An html message, can be False instead.
|
||||
@rtype: string
|
||||
"""
|
||||
ids = self.pool.get('res.log').search(cr, uid, [("res_model", "=", "Maintenance Notifications")]
|
||||
ids = self.pool.get('res.log').search(cr, uid, [("res_model", "=", "publisher_warranty.contract")]
|
||||
, order="create_date desc", limit=1)
|
||||
if not ids:
|
||||
return False
|
||||
message_r = self.pool.get('res.log').browse(cr, uid, ids[0]).name
|
||||
try:
|
||||
message = safe_eval(message_r)
|
||||
except:
|
||||
return message_r # for compatibility with manually entered messages
|
||||
|
||||
user = self.pool.get("res.users").browse(cr, uid, uid)
|
||||
lang = user.context_lang
|
||||
|
||||
if lang in message[1]:
|
||||
return message[1][lang]
|
||||
message = self.pool.get('res.log').browse(cr, uid, ids[0]).name
|
||||
|
||||
return message[0]
|
||||
return message
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Contract Name', size=384, required=True),
|
||||
|
|
|
@ -130,8 +130,8 @@
|
|||
<field name="name">Notifications</field>
|
||||
<field name="res_model">res.log</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{'search_default_my': 1}</field>
|
||||
<field name="domain">[('res_model','=','Maintenance Notifications')]</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="domain">[('res_model','=','publisher_warranty.contract')]</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
|
|
|
@ -20,26 +20,23 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
import tools
|
||||
|
||||
class res_log(osv.osv):
|
||||
_name = 'res.log'
|
||||
_columns = {
|
||||
'name': fields.char('Message', size=128, help='The logging message.', required=True),
|
||||
'user_id': fields.many2one('res.users','User', required=True),
|
||||
'user_id': fields.many2one('res.users','User'),
|
||||
'res_model': fields.char('Object', size=128),
|
||||
'context': fields.char('Context', size=250),
|
||||
'res_id': fields.integer('Object ID'),
|
||||
'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on'),
|
||||
'create_date': fields.datetime('Created Date', readonly=True),
|
||||
'read': fields.boolean('Read', help="If this log item has been read, get() should not send it to the client"),
|
||||
'broadcast': fields.boolean('Broadcast', help="For security, tells if all users should have right to read this log."),
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self,cr,uid,ctx: uid,
|
||||
'context': "{}",
|
||||
'read': False,
|
||||
'broadcast': False,
|
||||
}
|
||||
_order='create_date desc'
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
<field name="user_id" />
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
<field name="broadcast"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue