diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index fd1b27ba6bc..61d964b0076 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -240,6 +240,7 @@ class crm_case_rule(osv.osv):
'trg_priority_from': fields.selection([('','')] + AVAILABLE_PRIORITIES, 'Minimum Priority'),
'trg_priority_to': fields.selection([('','')] + AVAILABLE_PRIORITIES, 'Maximim Priority'),
+ 'trg_max_history': fields.integer('Maximum Communication History'),
'act_method': fields.char('Call Object Method', size=64),
'act_state': fields.selection([('','')]+AVAILABLE_STATES, 'Set state to', size=16),
@@ -418,6 +419,7 @@ class crm_case(osv.osv):
ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==case.categ_id.id)
ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==case.user_id.id)
ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==case.partner_id.id)
+ ok = ok and (not action.trg_max_history or action.trg_max_history<=(len(case.history_line)+1))
ok = ok and (
not action.trg_partner_categ_id.id or
(
@@ -797,6 +799,14 @@ class crm_case_history(osv.osv):
_description = "Case history"
_order = "id desc"
_inherits = {'crm.case.log':"log_id"}
+
+ def create(self, cr, user, vals, context=None):
+ if vals.has_key('case_id') and vals['case_id']:
+ case_obj = self.pool.get('crm.case')
+ cases = case_obj.browse(cr, user, [vals['case_id']])
+ case_obj._action(cr, user, cases, '')
+ return super(crm_case_history, self).create(cr, user, vals, context)
+
def _note_get(self, cursor, user, ids, name, arg, context=None):
res = {}
for hist in self.browse(cursor, user, ids, context or {}):
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 327f861c314..964abe153c2 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -20,7 +20,7 @@
-
+
crm.case.section.form
crm.case.section
@@ -100,7 +100,7 @@
-
+
Categories
crm.case.categ
@@ -108,7 +108,7 @@
-
+
crm.case.rule.form
@@ -123,7 +123,7 @@
-
+
@@ -141,6 +141,8 @@
+
+
@@ -200,8 +202,8 @@
-
-
+
+
crm.case.log.tree
@@ -218,8 +220,8 @@
-
-
+
+
crm.case.history.tree
crm.case.history
@@ -234,7 +236,7 @@
-
+
crm.case.calendar
crm.case
@@ -247,8 +249,8 @@
-
-
+
+
crm.case.tree
crm.case
@@ -268,7 +270,7 @@
-
+
crm.case.form
crm.case
@@ -292,7 +294,7 @@
-
+
-
+
All Cases
crm.case
@@ -370,7 +372,7 @@
-
+
Open Cases
crm.case
@@ -378,8 +380,8 @@
[('state','<>','done'),('state','<>','cancel'),('state','<>','pending')]
-
-
+
+
My cases
crm.case
@@ -396,10 +398,10 @@
[('user_id','=',uid),('state','<>','done'),('state','<>','cancel'),('state','<>','pending')]
-
-
-
-
+
+
+
+
crm.case.section.open
crm.case
@@ -414,8 +416,8 @@
-
-
+
+
crm.case.history.form
crm.case.history
@@ -450,7 +452,7 @@
[('user_id','=',uid)]
-
+
crm.segmentation.line.tree
crm.segmentation.line
@@ -465,7 +467,7 @@
-
+
crm.segmentation.line.form
crm.segmentation.line
@@ -483,7 +485,7 @@
-
+
crm.segmentation.form
crm.segmentation
@@ -532,14 +534,14 @@
-
+
Segmentations
crm.segmentation
form
-
+
Segmentations
crm.segmentation
@@ -547,17 +549,17 @@
tree,form
-
+
-
+
-
+
-
+
-
+
-
-
+
+