[IMP] crm: remove inheritance on base.action.rule, and change demo action rules to use standard stuff

bzr revid: rco@openerp.com-20121221102151-fxepq652rkeba62z
This commit is contained in:
Raphael Collet 2012-12-21 11:21:51 +01:00
parent b2864c4feb
commit 49b843d65f
6 changed files with 12 additions and 84 deletions

View File

@ -20,7 +20,6 @@
##############################################################################
import crm
import crm_action_rule
import crm_segmentation
import crm_lead
import crm_meeting

View File

@ -77,7 +77,6 @@ Dashboard for CRM will include:
'crm_view.xml',
'crm_action_rule_view.xml',
'crm_lead_view.xml',
'crm_lead_menu.xml',

View File

@ -1,63 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
from openerp import tools
from openerp.tools.translate import _
from openerp.tools import ustr
from openerp.osv import fields
from openerp.osv import osv
import crm
class base_action_rule(osv.osv):
""" Base Action Rule """
_inherit = 'base.action.rule'
_description = 'Action Rules'
_columns = {
'act_section_id': fields.many2one('crm.case.section', 'Set Team to'),
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
}
def _process(self, cr, uid, action, record_ids, context=None):
""" process the given action on the records """
res = super(base_action_rule, self)._process(cr, uid, action, record_ids, context=context)
# add record modifications
context = dict(context or {}, action=True)
model = self.pool.get(action.model_id.model)
values = {}
if action.act_section_id and 'section_id' in model._all_columns:
values['section_id'] = action.act_section_id.id
if action.act_categ_id and 'categ_ids' in model._all_columns:
values['categ_ids'] = [(4, action.act_categ_id.id)]
model.write(cr, uid, record_ids, values, context=context)
return res
def state_get(self, cr, uid, context=None):
"""Gets available states for crm"""
res = super(base_action_rule, self).state_get(cr, uid, context=context)
return res + crm.AVAILABLE_STATES
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -40,6 +40,16 @@ Description: [[object.description]]
<field name="domain">[('country_id','=','United States')]</field>
<field name="user_id" eval="False"/>
</record>
<record id="action_set_team_sales_department" model="ir.actions.server">
<field name="name">Set team to Sales Department</field>
<field name="model_id" ref="model_crm_lead"/>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">sales_team = self.pool.get('ir.model.data').get_object(cr, uid, 'crm', 'section_sales_department')
object.write({'section_id': sales_team.id})
</field>
</record>
<record id="rule_set_followers_lead" model="base.action.rule">
<field name="name">Set Auto Followers on leads which are urgent and come from USA.</field>
<field name="model_id" ref="model_crm_lead"/>
@ -47,10 +57,10 @@ Description: [[object.description]]
<field name="filter_id" ref="filter_usa_lead"/>
<field name="act_followers" eval="[(6,0,[ref('base.res_partner_4'), ref('base.res_partner_5'), ref('base.res_partner_6')])]"/>
<field name="act_user_id" ref="base.user_root"/>
<field name="act_section_id" ref="section_sales_department"/>
<field name="trg_date_type">create</field>
<field name="trg_date_range">0</field>
<field name="trg_date_range_type">minutes</field>
<field name="server_action_ids" eval="[(6,0,[ref('action_set_team_sales_department')])]"/>
</record>
</data>
</openerp>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Case rules -->
<record id="view_base_action_rule_line_form1" model="ir.ui.view">
<field name="name">base.action.rule.form.inherit</field>
<field name="model">base.action.rule</field>
<field name="inherit_id" ref="base_action_rule.view_base_action_rule_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='act_user_id']" position="after">
<field name="act_section_id"/>
<field name="act_categ_id"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -30,7 +30,7 @@ access_res_partner,res.partner.crm.user,base.model_res_partner,base.group_sale_s
access_res_partner_category,res.partner.category.crm.user,base.model_res_partner_category,base.group_sale_salesman,1,1,1,0
mail_mailgate_thread,mail.thread,mail.model_mail_thread,base.group_sale_salesman,1,1,1,1
access_crm_case_categ_manager,crm.case.categ manager,model_crm_case_categ,base.group_sale_manager,1,1,1,1
access_base_action_rule_manager,base.action.rule manager,model_base_action_rule,base.group_sale_manager,1,1,1,1
access_base_action_rule_manager,base.action.rule manager,base_action_rule.model_base_action_rule,base.group_sale_manager,1,1,1,1
access_crm_lead_report_user,crm.lead.report user,model_crm_lead_report,base.group_sale_salesman,1,1,1,1
access_res_partner_bank_type_crm_user,res.partner.bank.type.crm.user,base.model_res_partner_bank_type,base.group_sale_salesman,1,0,0,0
access_crm_lead_partner_manager,crm.lead.partner.manager,model_crm_lead,base.group_partner_manager,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
30 access_res_partner_category res.partner.category.crm.user base.model_res_partner_category base.group_sale_salesman 1 1 1 0
31 mail_mailgate_thread mail.thread mail.model_mail_thread base.group_sale_salesman 1 1 1 1
32 access_crm_case_categ_manager crm.case.categ manager model_crm_case_categ base.group_sale_manager 1 1 1 1
33 access_base_action_rule_manager base.action.rule manager model_base_action_rule base_action_rule.model_base_action_rule base.group_sale_manager 1 1 1 1
34 access_crm_lead_report_user crm.lead.report user model_crm_lead_report base.group_sale_salesman 1 1 1 1
35 access_res_partner_bank_type_crm_user res.partner.bank.type.crm.user base.model_res_partner_bank_type base.group_sale_salesman 1 0 0 0
36 access_crm_lead_partner_manager crm.lead.partner.manager model_crm_lead base.group_partner_manager 1 0 0 0