diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 79b883c0236..b1ef4f5ca13 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -61,7 +61,6 @@ class base_action_rule(osv.osv): _columns = { 'name': fields.many2one('ir.model', 'Object', required=True), - 'max_level': fields.integer('Max Level', help='Specifies maximum level.'), 'create_date': fields.datetime('Create Date', readonly=1), 'active': fields.boolean('Active', help="If the active field is set to False,\ it will allow you to hide the rule without removing it."), @@ -111,19 +110,16 @@ the rule to mark CC(mail to any other person defined in actions)."), \nNote: This is case sensitive search."), 'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"), 'filter_id':fields.many2one('ir.filters', 'Filter', required=False), - 'domain':fields.char('Domain', size=124, required=False, readonly=False), } _defaults = { 'active': lambda *a: True, - 'max_level': lambda *a: 15, 'trg_date_type': lambda *a: 'none', 'trg_date_range_type': lambda *a: 'day', 'act_mail_to_user': lambda *a: 0, 'act_remind_partner': lambda *a: 0, 'act_remind_user': lambda *a: 0, 'act_mail_to_watchers': lambda *a: 0, - 'domain': lambda *a: '[]' } _order = 'sequence' @@ -249,9 +245,13 @@ the rule to mark CC(mail to any other person defined in actions)."), @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ ok = True - if eval(action.domain): - obj_ids = obj._table.search(cr, uid, eval(action.domain), context=context) - if not obj.id in obj_ids: + if action.filter_id: + if action.name.model == action.filter_id.model_id: + context.update(eval(action.filter_id.context)) + obj_ids = obj._table.search(cr, uid, eval(action.filter_id.domain), context=context) + if not obj.id in obj_ids: + ok = False + else: ok = False if hasattr(obj, 'user_id'): ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==obj.user_id.id) @@ -344,9 +344,6 @@ the rule to mark CC(mail to any other person defined in actions)."), if not scrit: scrit = [] for action in self.browse(cr, uid, ids): - level = action.max_level - if not level: - break model_obj = self.pool.get(action.name.model) for obj in objects: ok = self.do_check(cr, uid, action, obj, context=context) @@ -391,7 +388,6 @@ the rule to mark CC(mail to any other person defined in actions)."), if ok: self.do_action(cr, uid, action, model_obj, obj, context) break - level -= 1 context.update({'action': False}) return True diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml index 36140e62649..ef0b70ebdc2 100644 --- a/addons/base_action_rule/base_action_rule_view.xml +++ b/addons/base_action_rule/base_action_rule_view.xml @@ -17,8 +17,6 @@ - - @@ -96,10 +94,9 @@ tree - - - + + diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index a490a800beb..f23b61df5ea 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -85,6 +85,8 @@ Create dashboard for CRM that includes: 'wizard/crm_forward_to_partner_view.xml', 'wizard/crm_send_email_view.xml', + 'wizard/crm_custom_create_menu_view.xml', + 'crm_view.xml', 'crm_action_rule_view.xml', diff --git a/addons/crm/board_crm_statistical_view.xml b/addons/crm/board_crm_statistical_view.xml index b23fdeac1cd..01d0472c21e 100644 --- a/addons/crm/board_crm_statistical_view.xml +++ b/addons/crm/board_crm_statistical_view.xml @@ -36,7 +36,7 @@ - + @@ -60,7 +60,7 @@ - Number of Opportunities by stage + Planned revenue by user and stage crm.lead.report form graph,tree,form @@ -93,7 +93,7 @@ diff --git a/addons/crm/board_crm_view.xml b/addons/crm/board_crm_view.xml index ed6044a6fd6..ccaf0f7e35c 100644 --- a/addons/crm/board_crm_view.xml +++ b/addons/crm/board_crm_view.xml @@ -51,7 +51,7 @@ form graph,tree,form - ['&', ('user_id','=',uid), '!' , '&', ('state', '=', 'done'), ('date_closed','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%Y-%m-%d'))] + ['&', '&', ('user_id','=',uid), ('type', '=', 'opportunity'), '!' , '&', ('state', '=', 'done'), ('date_closed','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%Y-%m-%d'))] @@ -84,11 +84,11 @@ diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 575c2a8a3e3..ba05269c474 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -639,4 +639,86 @@ class res_partner(osv.osv): } res_partner() + +class crm_case_section_custom(osv.osv): + _name = "crm.case.section.custom" + _description = 'Custom CRM Case Section' + + _columns = { + 'name': fields.char('Case Section',size=64, required=True, translate=True), + 'code': fields.char('Section Code',size=8), + 'active': fields.boolean('Active'), + 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), + 'sequence': fields.integer('Sequence'), + 'user_id': fields.many2one('res.users', 'Responsible User'), + 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this section"), + 'parent_id': fields.many2one('crm.case.section.custom', 'Parent Section'), + 'note': fields.text('Notes'), + } + + _defaults = { + 'active': 1, + 'allow_unlink': 1, + } + + _sql_constraints = [ + ('code_uniq', 'unique (code)', 'The code of the section must be unique !') + ] + + def _check_recursion(self, cr, uid, ids): + level = 100 + while len(ids): + cr.execute('SELECT DISTINCT parent_id FROM crm_case_section_custom '\ + 'WHERE id IN %s', + (tuple(ids),)) + ids = filter(None, map(lambda x:x[0], cr.fetchall())) + if not level: + return False + level -= 1 + return True + _constraints = [ + (_check_recursion, 'Error ! You cannot create recursive sections.', ['parent_id']) + ] + +crm_case_section_custom() + + +class crm_case_custom(osv.osv, crm_case): + _name = 'crm.case.custom' + _inherit = 'mailgate.thread' + _description = "Custom CRM Case" + + _columns = { + 'id': fields.integer('ID', readonly=True), + 'name': fields.char('Name',size=64,required=True), + 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'), + 'active': fields.boolean('Active'), + 'description': fields.text('Description'), + 'section_id': fields.many2one('crm.case.section.custom', 'Section', required=True, select=True), + 'probability': fields.float('Probability (%)'), + 'email_from': fields.char('Partner Email', size=128), + 'email_cc': fields.char('CC', size=252), + 'partner_id': fields.many2one('res.partner', 'Partner'), + 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"), + 'date': fields.datetime('Date'), + 'create_date': fields.datetime('Created' ,readonly=True), + 'date_deadline': fields.datetime('Deadline'), + 'date_closed': fields.datetime('Closed', readonly=True), + 'user_id': fields.many2one('res.users', 'Responsible'), + 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True), + 'ref' : fields.reference('Reference', selection=_links_get, size=128), + 'date_action_last': fields.datetime('Last Action', readonly=1), + 'date_action_next': fields.datetime('Next Action', readonly=1), + } + + _defaults = { + 'active': 1, + 'state': 'draft', + 'priority': AVAILABLE_PRIORITIES[2][0], + 'date': time.strftime('%Y-%m-%d %H:%M:%S'), + } + +crm_case_custom() + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index 74786ad91f6..61da1ab6cc9 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -17,6 +17,13 @@ + + + @@ -428,5 +435,262 @@ + + + + + crm.case.section.custom.form + crm.case.section.custom + form + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + crm.case.section.custom.tree + crm.case.section.custom + tree + + + + + + + + + + + + + Custom Cases - Tree + crm.case.custom + tree + + + + + + + + + + + + + + + + + Custom Cases - Form + crm.case.custom + form + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +