[ADD] full suffix field

bzr revid: mat@openerp.com-20130410084940-rl1ykxdu3626rfc3
This commit is contained in:
Martin Trigaux
2013-04-10 10:49:40 +02:00
parent 5fe85f2278
commit 47e0b51da8
2 changed files with 23 additions and 2 deletions
+21 -1
View File
@@ -40,12 +40,32 @@ class gamification_goal_type(osv.Model):
_name = 'gamification.goal.type'
_description = 'Gamification goal type'
def _get_suffix(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
for goal in self.browse(cr, uid, ids, context):
if goal.unit and not goal.monetary:
res[goal.id] = goal.unit
elif goal.monetary:
# use the current user's company currency
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if goal.unit:
res[goal.id] = "%s %s" % (user.company_id.currency_id.symbol, goal.unit)
else:
res[goal.id] = user.company_id.currency_id.symbol
else:
res[goal.id] = ""
return res
_columns = {
'name': fields.char('Goal Type Name', required=True, translate=True),
'description': fields.text('Goal Description'),
'monetary': fields.boolean('Monetary Value', help="The target and current value are defined in the company currency."),
'unit': fields.char('Suffix',
help="The unit of the target and current values", translate=True),
'full_suffix': fields.function(_get_suffix, type="char",
string="Full Suffix", help="The currency and suffix field"),
'computation_mode': fields.selection([
('manually', 'Recorded manually'),
('count', 'Automatic: number of records'),
@@ -64,7 +84,7 @@ class gamification_goal_type(osv.Model):
help='The date to use for the time period evaluated'),
'domain': fields.char("Filter Domain",
help="Technical filters rules to apply",
required=True), # how to apply it ?
required=True),
'condition': fields.selection([
('higher', 'The higher the better'),
('lower', 'The lower the better')
+2 -1
View File
@@ -237,7 +237,7 @@ class gamification_goal_plan(osv.Model):
for plan in self.browse(cr, uid, ids, context=context):
if plan.autojoin_group_id:
self.plan_subscribe_users(cr, uid, ids, [user.id for user in plan.autojoin_group_id.users], context=context)
self.plan_subscribe_users(cr, uid, [plan.id], [user.id for user in plan.autojoin_group_id.users], context=context)
self.generate_goals_from_plan(cr, uid, [plan.id], context=context)
# goals closed but still opened at the last report date
@@ -577,4 +577,5 @@ class gamification_goal_planline(osv.Model):
readonly=True, string="Condition", selection=[('lower', '<='), ('higher', '>=')]),
'type_unit': fields.related('type_id', 'unit', type="char", readonly=True, string="Unit"),
'type_monetary': fields.related('type_id', 'monetary', type="boolean", readonly=True, string="Monetary"),
'type_full_suffix': fields.related('type_id', 'full_suffix', type="char", readonly=True, string="Suffix"),
}