[MERGE]
bzr revid: christophe@tinyerp.com-20081211114753-qm3sni5owmowqofn
This commit is contained in:
@@ -688,9 +688,9 @@
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Field Type" colspan="2"/>
|
||||
<field name="ttype" select="2"/>
|
||||
<field name="relation" select="2" attrs="{'required': [('ttype','in',['many2one','one2many','many2many'])],
|
||||
<field name="relation_id" select="2" attrs="{'required': [('ttype','in',['many2one','one2many','many2many'])],
|
||||
'readonly': [('ttype','not in', ['many2one','one2many','many2many'])]}"/>
|
||||
<field name="relation_field" attrs="{'required': [('ttype','=','one2many')],
|
||||
<field name="relation_field_id" domain="[('model_id','=',relation_id)]" attrs="{'required': [('ttype','=','one2many')],
|
||||
'readonly': [('ttype','!=','one2many')]}"/>
|
||||
<field name="selection" attrs="{'required': [('ttype','=','selection')], 'readonly': [('ttype','!=','selection')]}"/>
|
||||
<field name="size" attrs="{'required': [('ttype','=','char')], 'readonly': [('ttype','!=','char')]}"/>
|
||||
@@ -767,9 +767,11 @@
|
||||
<page string="Properties">
|
||||
<group colspan="2" col="2">
|
||||
<field name="ttype" select="2"/>
|
||||
<field name="relation" select="2" attrs="{'required': [('ttype','in', ['many2one','one2many','many2many'])],
|
||||
<field name="relation_id" select="2" on_change="on_relation_change(relation_id)" attrs="{'required': [('ttype','in', ['many2one','one2many','many2many'])],
|
||||
'readonly': [('ttype','not in', ['many2one','one2many','many2many'])]}"/>
|
||||
<field name="relation_field" attrs="{'required': [('ttype','=','one2many')],
|
||||
<!-- <field name="relation" select="2" attrs="{'required': [('ttype','in', ['many2one','one2many','many2many'])],-->
|
||||
<!-- 'readonly': [('ttype','not in', ['many2one','one2many','many2many'])]}"/>-->
|
||||
<field name="relation_field_id" domain="[('model_id','=',relation_id)]" attrs="{'required': [('ttype','=','one2many')],
|
||||
'readonly': [('ttype','!=','one2many')]}"/>
|
||||
<field name="selection" attrs="{'required': [('ttype','=','selection')], 'readonly': [('ttype','!=','selection')]}"/>
|
||||
<field name="size" attrs="{'required': [('ttype','=','char')], 'readonly': [('ttype','!=','char')]}"/>
|
||||
@@ -1157,11 +1159,18 @@
|
||||
<field name="action_id" select="2" colspan="4"/>
|
||||
</page>
|
||||
|
||||
<page string="Email / SMS" attrs="{'invisible':[('state','!=','sms'),('state','!=','email')]}">
|
||||
<page string="Email Configuration" attrs="{'invisible':[('state','!=','email')]}">
|
||||
<separator colspan="4" string="Email Configuration"/>
|
||||
<field name="address" domain="[('model_id','=',model_id)]"/>
|
||||
<field name="sms" colspan="4" attrs="{'readonly':[('state','!=','sms')]}"/>
|
||||
<field name="message" select="2" colspan="4" attrs="{'readonly':[('state','!=','email')]}" />
|
||||
<field name="email" domain="[('model_id','=',model_id)]"/>
|
||||
<field name="message" select="2" colspan="4"/>
|
||||
<newline/>
|
||||
<label colspan="4" string="Access all the fields related to the current object using expression in double brackets, i.e. [[ object.partner_id.name ]]" align="0.0"/>
|
||||
</page>
|
||||
|
||||
<page string="SMS Configuration" attrs="{'invisible':[('state','!=','sms')]}">
|
||||
<separator colspan="4" string="SMS Configuration"/>
|
||||
<field name="mobile" domain="[('model_id','=',model_id)]"/>
|
||||
<field name="sms" colspan="4"/>
|
||||
<newline/>
|
||||
<label colspan="4" string="Access all the fields related to the current object using expression in double brackets, i.e. [[ object.partner_id.name ]]" align="0.0"/>
|
||||
</page>
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -27,18 +27,72 @@
|
||||
<field name="active" />
|
||||
<field name="translatable"/>
|
||||
<field name="grouping" />
|
||||
<field name="direction" />
|
||||
<newline/>
|
||||
<field name="date_format"/>
|
||||
<field name="time_format"/>
|
||||
<field name="decimal_point"/>
|
||||
<field name="thousands_sep"/>
|
||||
<newline/>
|
||||
<field name="direction" />
|
||||
</group>
|
||||
|
||||
<newline/>
|
||||
<separator colspan="4" string="Legends for Date and Time Formats"/>
|
||||
<field name="legend" nolabel="1" colspan="4"/>
|
||||
<group col="4" colspan="4">
|
||||
<label align="0.0" string="%%a - Abbreviated weekday name."/>
|
||||
<label align="0.0" string="%%A - Full weekday name."/>
|
||||
<newline/>
|
||||
<label align="0.0" string="%%b - Abbreviated month name."/>
|
||||
<label align="0.0" string="%%B - Full month name." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%c - Appropriate date and time representation." />
|
||||
<label align="0.0" string="%%d - Day of the month as a decimal number [01,31]." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%H - Hour (24-hour clock) as a decimal number [00,23]." />
|
||||
<label align="0.0" string="%%I - Hour (12-hour clock) as a decimal number [01,12]." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%j - Day of the year as a decimal number [001,366]." />
|
||||
<label align="0.0" string="%%m - Month as a decimal number [01,12]." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%M - Minute as a decimal number [00,59]." />
|
||||
<label align="0.0" string="%%p - Equivalent of either AM or PM." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%S - Second as a decimal number [00,61]." />
|
||||
<label align="0.0" string="%%w - Weekday as a decimal number [0(Sunday),6]." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%x - Appropriate date representation." />
|
||||
<label align="0.0" string="%%X - Appropriate time representation." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%y - Year without century as a decimal number [00,99]." />
|
||||
<label align="0.0" string="%%Y - Year with century as a decimal number." />
|
||||
<newline/>
|
||||
<label align="0.0" string="%%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." />
|
||||
<label align="0.0" string="%%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." />
|
||||
<newline/>
|
||||
<label align="0.0" string="======================================================" />
|
||||
</group>
|
||||
<newline/>
|
||||
<group colspan="4" col="4">
|
||||
<separator string="Examples"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="1. %%c ==> Fri Dec 5 18:25:20 2008"/>
|
||||
<label align="0.0" string="2. %%a ,%%A ==> Fri, Friday"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="3. %%x ,%%X ==> 12/05/08, 18:25:20"/>
|
||||
<label align="0.0" string="4. %%b, %%B ==> Dec, December"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="5. %%y, %%Y ==> 08, 2008"/>
|
||||
<label align="0.0" string="6. %%d, %%m ==> 05, 12"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="7. %%H:%%M:%%S ==> 18:25:20"/>
|
||||
<label align="0.0" string="8. %%I:%%M:%%S %%p ==> 06:25:20 PM"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="9. %%j ==> 340"/>
|
||||
<label align="0.0" string="10. %%S ==> 20"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="11. %%U or %%W ==> 48 (49th week)"/>
|
||||
<label align="0.0" string="12. %%w ==> 5 ( Friday is the 6th day)"/>
|
||||
<newline/>
|
||||
</group>
|
||||
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user