diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index 421b7ae680f..99a8be878be 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -688,9 +688,9 @@ - - @@ -767,9 +767,11 @@ - - --> + @@ -1157,11 +1159,18 @@ - + - - - + + + + + + + + + diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 41ebe76ba51..84970c33fb7 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -387,8 +387,9 @@ class actions_server(osv.osv): 'action_id': fields.many2one('ir.actions.actions', 'Client Action'), 'trigger_name': fields.char('Trigger Name', size=128), 'trigger_obj_id': fields.reference('Trigger On', selection=model_get, size=128), + 'email': fields.many2one('ir.model.fields', 'Contact'), 'message': fields.text('Message', translate=True), - 'address': fields.many2one('ir.model.fields', 'Email / Mobile'), + 'mobile': fields.many2one('ir.model.fields', 'Contact'), 'sms': fields.char('SMS', size=160, translate=True), 'child_ids': fields.one2many('ir.actions.actions', 'parent_id', 'Others Actions'), 'usage': fields.char('Action Usage', size=32), @@ -416,17 +417,39 @@ class actions_server(osv.osv): 'otype': lambda *a: 'copy', } - def get_field_value(self, cr, uid, action, context): + + def get_email(self, cr, uid, action, context): obj_pool = self.pool.get(action.model_id.model) id = context.get('active_id') obj = obj_pool.browse(cr, uid, id) fields = None - if '/' in action.address.complete_name: - fields = action.address.complete_name.split('/') - elif '.' in action.address.complete_name: - fields = action.address.complete_name.split('.') + if '/' in action.email.complete_name: + fields = action.email.complete_name.split('/') + elif '.' in action.email.complete_name: + fields = action.email.complete_name.split('.') + + for field in fields: + try: + obj = getattr(obj, field) + except Exception,e : + logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (match.group())) + + return obj + + + def get_mobile(self, cr, uid, action, context): + obj_pool = self.pool.get(action.model_id.model) + id = context.get('active_id') + obj = obj_pool.browse(cr, uid, id) + + fields = None + + if '/' in action.mobile.complete_name: + fields = action.mobile.complete_name.split('/') + elif '.' in action.mobile.complete_name: + fields = action.mobile.complete_name.split('.') for field in fields: try: @@ -442,13 +465,13 @@ class actions_server(osv.osv): obj_pool = self.pool.get(action.model_id.model) id = context.get('active_id') obj = obj_pool.browse(cr, uid, id) - return eval(match[2:-2], {'object':obj, 'context': context,'time':time}) + exp = str(match.group()[2:-2]).strip() + return eval(exp, {'object':obj, 'context': context,'time':time}) com = re.compile('(\[\[.+?\]\])') message = com.sub(merge, keystr) return message - # # Context should contains: # ids : original ids # id : current id of the object @@ -478,11 +501,14 @@ class actions_server(osv.osv): if action.state == 'email': user = config['email_from'] subject = action.name - address = self.get_field_value(cr, uid, action, context) + address = self.get_email(cr, uid, action, context) if not address: raise osv.except_osv(_('Error'), _("Please specify the Partner Email address !")) + if not user: + raise osv.except_osv(_('Error'), _("Please specify server option --smtp-from !")) + body = self.merge_message(cr, uid, str(action.message), action, context) - if tools.email_send_attach(user, address, subject, body, debug=False) == True: + if tools.email_send(user, address, subject, body, debug=False) == True: logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (address)) else: logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (address)) @@ -499,7 +525,7 @@ class actions_server(osv.osv): # for the sms gateway user / password api_id = '' text = action.sms - to = self.get_field_value(cr, uid, action, context) + to = self.get_mobile(cr, uid, action, context) #TODO: Apply message mearge with the field if tools.sms_send(user, password, api_id, text, to) == True: logger.notifyChannel('sms', netsvc.LOG_INFO, 'SMS successfully send to : %s' % (action.address)) diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 4d8e2175d9d..2c2ba419e39 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -193,7 +193,9 @@ class ir_model_fields(osv.osv): _columns = { 'name': fields.char('Name', required=True, size=64, select=1), 'model': fields.char('Object Name', size=64, required=True), + 'relation_id':fields.many2one('ir.model', 'Object Relation'), 'relation': fields.char('Object Relation', size=64), + 'relation_field_id':fields.many2one('ir.model.fields', 'Relation Field'), 'relation_field': fields.char('Relation Field', size=64), 'model_id': fields.many2one('ir.model', 'Object id', required=True, select=True, ondelete='cascade'), 'field_description': fields.char('Field Label', required=True, size=256), @@ -231,8 +233,26 @@ class ir_model_fields(osv.osv): # MAY BE ADD A ALTER TABLE DROP ? # return super(ir_model_fields, self).unlink(cr, user, ids, context) - + + def write(self, cr, uid, ids, vals, context=None): + res = False + if 'relation_id' in vals: + model_data = self.pool.get('ir.model').browse(cr, uid, vals['relation_id']) + vals['relation'] = model_data.model + if 'relation_field_id' in vals: + field_data = self.pool.get('ir.model.fields').browse(cr, uid, vals['relation_field_id']) + vals['relation'] = field_data.name + + res = super(ir_model_fields, self).write(cr, uid, ids, vals, context) + return res + def create(self, cr, user, vals, context=None): + if 'relation_id' in vals: + model_data = self.pool.get('ir.model').browse(cr,user,vals['relation_id']) + vals['relation']=model_data.model + if 'relation_field_id' in vals: + field_data = self.pool.get('ir.model.fields').browse(cr, uid, vals['relation_field_id']) + vals['relation'] = field_data.name if 'model_id' in vals: model_data=self.pool.get('ir.model').browse(cr,user,vals['model_id']) vals['model']=model_data.model diff --git a/bin/addons/base/ir/ir_translation.py b/bin/addons/base/ir/ir_translation.py index c7eb75211fe..dac4a550e45 100644 --- a/bin/addons/base/ir/ir_translation.py +++ b/bin/addons/base/ir/ir_translation.py @@ -48,7 +48,7 @@ class ir_translation(osv.osv, Cacheable): lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)], context=context) langs = lang_obj.browse(cr, uid, lang_ids, context=context) - res = [(lang.code, unicode(lang.name,'utf-8')) for lang in langs] + res = [(lang.code, lang.name) for lang in langs] for lang_dict in tools.scan_languages(): if lang_dict not in res: res.append(lang_dict) diff --git a/bin/addons/base/res/res_lang.py b/bin/addons/base/res/res_lang.py index c90c02e3b98..4c01687e4a5 100644 --- a/bin/addons/base/res/res_lang.py +++ b/bin/addons/base/res/res_lang.py @@ -44,7 +44,6 @@ class lang(osv.osv): 'grouping':fields.char('Separator Format',size=64,required=True,help="The Separator Format should be like [,n] where 0 < n :starting from Unit digit.-1 will end the separation. e.g. [3,2,-1] will represent 106500 to be 1,06,500;[1,2,-1] will represent it to be 106,50,0;[3] will represent it as 106,500. Provided ',' as the thousand separator in each case."), 'decimal_point':fields.char('Decimal Separator', size=64,required=True), 'thousands_sep':fields.char('Thousands Separator',size=64), - 'legend':fields.text('Legends for Date and Time Formats',readonly=True), } _defaults = { 'active': lambda *a: 1, @@ -55,40 +54,6 @@ class lang(osv.osv): 'grouping':lambda *a: '[]', 'decimal_point':lambda *a: '.', 'thousands_sep':lambda *a: ',', - 'legend': lambda *a: '%a - Abbreviated weekday name.\ -\n%A - Full weekday name.\ -\n%b - Abbreviated month name.\ -\n%B - Full month name. \ -\n%c - Appropriate date and time representation.\ -\n%d - Day of the month as a decimal number [01,31].\ -\n%H - Hour (24-hour clock) as a decimal number [00,23].\ -\n%I - Hour (12-hour clock) as a decimal number [01,12].\ -\n%j - Day of the year as a decimal number [001,366].\ -\n%m - Month as a decimal number [01,12].\ -\n%M - Minute as a decimal number [00,59].\ -\n%p - Equivalent of either AM or PM.\ -\n%S - Second as a decimal number [00,61].\ -\n%U - Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.\ -\n%w - Weekday as a decimal number [0(Sunday),6].\ -\n%W - Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.\ -\n%x - Appropriate date representation.\ -\n%X - Appropriate time representation.\ -\n%y - Year without century as a decimal number [00,99].\ -\n%Y - Year with century as a decimal number.\ -\n ==========================================\ -\n\nExamples:\ -\n1. %c ==> Fri Dec 5 18:25:20 2008\ -\n2. %a ,%A ==> Fri, Friday\ -\n3. %x ,%X ==> 12/05/08, 18:25:20\ -\n4. %b, %B ==> Dec, December\ -\n5. %y, %Y ==> 08, 2008\ -\n6. %d, %m ==> 05, 12\ -\n7. %H:%M:%S ==> 18:25:20\ -\n8. %I:%M:%S %p ==> 06:25:20 PM\ -\n9. %j ==> 340\ -\n10. %S ==> 20\ -\n11. %U or %W ==> 48 (49th week)\ -\n12. %w ==> 5 ( Friday is the 6th day)', } def _group(self,cr,uid,ids,s, monetary=False): diff --git a/bin/addons/base/res/res_lang_view.xml b/bin/addons/base/res/res_lang_view.xml index 428edcdad44..e212e997051 100644 --- a/bin/addons/base/res/res_lang_view.xml +++ b/bin/addons/base/res/res_lang_view.xml @@ -27,18 +27,72 @@ + - - - - + + + + + + + +