[IMP] website_crm_score: improve usability + misc
Review kanban to have only create by default without the search view Rename model leads_dry_run into crm_leads_dry_run Fix bug when toggle the running field on kanban was done before save Remove useless link Assign now and Dry Run Add dry run action_server in team.user more context
This commit is contained in:
@@ -5,7 +5,15 @@
|
||||
'depends': ['base', 'sales_team', 'marketing', 'website_crm'],
|
||||
'author': "Odoo S.A.",
|
||||
'description': """\
|
||||
Lead scoring""",
|
||||
Lead Scoring
|
||||
===================
|
||||
|
||||
This module allows you to...
|
||||
- Track specific page view on your website.
|
||||
- Assign score on lead: sort your lead automatically and consider the more important at first.
|
||||
- Assign lead to salesteams: define your own filters and sort automatically your leads by saleteam.
|
||||
- Assign lead to salesmen: define filter by saleman and dispatch automatically your leads to the right saleman.
|
||||
""",
|
||||
'data': [
|
||||
'views/website_crm_score.xml',
|
||||
'views/reporting.xml',
|
||||
@@ -17,4 +25,5 @@
|
||||
'demo/website_crm_score_demo.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
from openerp import fields, models, api
|
||||
|
||||
|
||||
class leads_dry_run(models.TransientModel):
|
||||
_name = "leads.dry.run"
|
||||
class crm_leads_dry_run(models.TransientModel):
|
||||
_name = "crm.leads.dry.run"
|
||||
|
||||
lead_id = fields.Many2one('crm.lead', string='Lead', required=True)
|
||||
team_id = fields.Many2one('crm.team', string='SaleTeam', required=True, oldname='section_id')
|
||||
@@ -28,5 +28,5 @@ class leads_dry_run(models.TransientModel):
|
||||
|
||||
# Avoid to re-assign the same leads for nothing
|
||||
self._cr.execute("""
|
||||
TRUNCATE TABLE leads_dry_run;
|
||||
TRUNCATE TABLE crm_leads_dry_run;
|
||||
""")
|
||||
|
||||
@@ -69,7 +69,8 @@ class team_user(models.Model):
|
||||
|
||||
@api.one
|
||||
def toggle_active(self):
|
||||
self.running = not self.running
|
||||
if isinstance(self.id, int): # if already saved
|
||||
self.running = not self.running
|
||||
|
||||
|
||||
class crm_team(osv.osv):
|
||||
@@ -150,7 +151,7 @@ class crm_team(osv.osv):
|
||||
if dry:
|
||||
for lead in leads:
|
||||
values = {'lead_id': lead.id, 'team_id': salesteam['id']}
|
||||
self.env['leads.dry.run'].create(values)
|
||||
self.env['crm.leads.dry.run'].create(values)
|
||||
else:
|
||||
leads.write({'team_id': salesteam['id']})
|
||||
|
||||
@@ -188,7 +189,7 @@ class crm_team(osv.osv):
|
||||
limit = int(math.ceil(su.maximum_user_leads / 15.0))
|
||||
|
||||
if dry:
|
||||
dry_leads = self.env["leads.dry.run"].search([('team_id', '=', su.team_id.id)])
|
||||
dry_leads = self.env["crm.leads.dry.run"].search([('team_id', '=', su.team_id.id)])
|
||||
domain.append(['id', 'in', dry_leads.mapped('lead_id.id')])
|
||||
else:
|
||||
domain.append(('team_id', '=', su.team_id.id))
|
||||
@@ -219,12 +220,12 @@ class crm_team(osv.osv):
|
||||
del users[i]
|
||||
continue
|
||||
|
||||
#lead convert for this user
|
||||
# lead convert for this user
|
||||
lead = user['leads'][0]
|
||||
assigned.add(lead)
|
||||
if dry:
|
||||
values = {'lead_id': lead.id, 'team_id': user['su'].team_id.id, 'user_id': user['su'].user_id.id}
|
||||
self.env['leads.dry.run'].create(values)
|
||||
self.env['crm.leads.dry.run'].create(values)
|
||||
else:
|
||||
# Assign date will be setted by write function
|
||||
data = {'user_id': user['su'].user_id.id}
|
||||
@@ -241,7 +242,7 @@ class crm_team(osv.osv):
|
||||
def _assign_leads(self, dry=False):
|
||||
# Emptying the table
|
||||
self._cr.execute("""
|
||||
TRUNCATE TABLE leads_dry_run;
|
||||
TRUNCATE TABLE crm_leads_dry_run;
|
||||
""")
|
||||
|
||||
all_salesteams = self.search_read(fields=['score_team_domain'], domain=[('score_team_domain', '!=', False)])
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestScoring(common.TransactionCase):
|
||||
|
||||
# Usefull models
|
||||
self.crm_lead = self.registry('crm.lead')
|
||||
self.leads_dry_run = self.registry('leads.dry.run')
|
||||
self.crm_leads_dry_run = self.registry('crm.leads.dry.run')
|
||||
self.pageview = self.registry('website.crm.pageview')
|
||||
self.website_crm_score = self.registry('website.crm.score')
|
||||
self.team = self.registry('crm.team')
|
||||
|
||||
@@ -25,13 +25,13 @@ class test_dry_run(TestScoring):
|
||||
|
||||
fields = ['team_id', 'user_id', 'lead_id']
|
||||
|
||||
dr0_sect = self.leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead0), ('user_id', '=', False)], fields)[0]
|
||||
dr0_user = self.leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead0), ('user_id', '!=', False)], fields)[0]
|
||||
dr0_sect = self.crm_leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead0), ('user_id', '=', False)], fields)[0]
|
||||
dr0_user = self.crm_leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead0), ('user_id', '!=', False)], fields)[0]
|
||||
|
||||
dr1_sect = self.leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead1), ('user_id', '=', False)], fields)[0]
|
||||
dr1_user = self.leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead1), ('user_id', '!=', False)], fields)[0]
|
||||
dr1_sect = self.crm_leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead1), ('user_id', '=', False)], fields)[0]
|
||||
dr1_user = self.crm_leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead1), ('user_id', '!=', False)], fields)[0]
|
||||
|
||||
dr2 = self.leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead2)], fields)
|
||||
dr2 = self.crm_leads_dry_run.search_read(cr, uid, [('lead_id', '=', self.lead2)], fields)
|
||||
|
||||
self.assertEqual(dr0_sect['team_id'][0], self.team0, 'dry run failed')
|
||||
self.assertEqual(dr0_user['team_id'][0], self.team0, 'dry run failed')
|
||||
@@ -43,11 +43,11 @@ class test_dry_run(TestScoring):
|
||||
|
||||
self.assertEqual(dr2, [], 'dry run failed')
|
||||
|
||||
ldr = self.leads_dry_run.search_count(cr, uid, [], None)
|
||||
ldr = self.crm_leads_dry_run.search_count(cr, uid, [], None)
|
||||
self.assertEqual(ldr, 4, 'wrong number of dry run created')
|
||||
|
||||
# assignement after dry run
|
||||
self.leads_dry_run.assign_leads(cr, uid, None)
|
||||
self.crm_leads_dry_run.assign_leads(cr, uid, None)
|
||||
|
||||
l0 = self.crm_lead.read(cr, uid, self.lead0, ['team_id', 'user_id'], None)
|
||||
l1 = self.crm_lead.read(cr, uid, self.lead1, ['team_id', 'user_id'], None)
|
||||
@@ -61,6 +61,6 @@ class test_dry_run(TestScoring):
|
||||
self.assertEqual(l1['user_id'][0], self.salesmen1, 'assignation failed')
|
||||
self.assertEqual(l2['user_id'], False, 'assignation failed')
|
||||
|
||||
ldr = self.leads_dry_run.search_count(cr, uid, [], None)
|
||||
ldr = self.crm_leads_dry_run.search_count(cr, uid, [], None)
|
||||
|
||||
self.assertEqual(ldr, 0, 'dry run not removed correctly')
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
<!-- Lead dry run From View -->
|
||||
<record model="ir.ui.view" id="view_crm_lead_dry_run_form">
|
||||
<field name="name">Assignation Dry Run Form</field>
|
||||
<field name="model">leads.dry.run</field>
|
||||
<field name="model">crm.leads.dry.run</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Assignation Dry Run">
|
||||
<sheet>
|
||||
@@ -272,7 +272,6 @@
|
||||
<group>
|
||||
<field name="team_id"/>
|
||||
<field name="user_id"/>
|
||||
<button name="assign_leads" type="object" string="Assign Now" class="oe_link"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
@@ -282,7 +281,7 @@
|
||||
<!-- Lead dry run Tree View -->
|
||||
<record model="ir.ui.view" id="view_lead_dry_run_tree">
|
||||
<field name="name">Assignation Dry Run tree</field>
|
||||
<field name="model">leads.dry.run</field>
|
||||
<field name="model">crm.leads.dry.run</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assignation Dry Run">
|
||||
<field name="lead_id"/>
|
||||
@@ -295,7 +294,7 @@
|
||||
<!-- Lead dry run Action - form - tree -->
|
||||
<record model="ir.actions.act_window" id="lead_dry_run_action">
|
||||
<field name="name">Assignation dry run</field>
|
||||
<field name="res_model">leads.dry.run</field>
|
||||
<field name="res_model">crm.leads.dry.run</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
@@ -198,19 +198,11 @@
|
||||
<field name="capacity" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="min_for_assign" class="oe_inline"/>
|
||||
<div>
|
||||
<br/>
|
||||
<button name="direct_assign_leads" type="object" string="Assign Now" class="oe_link"/>
|
||||
<span groups="base.group_no_one">
|
||||
<br/>
|
||||
<button name="dry_assign_leads" type="object" string="Dry Assign" class="oe_link"/>
|
||||
</span>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//page[@string='Team Members']" position="replace">
|
||||
<page string="Assignation">
|
||||
<field name="team_user_ids" widget="many2many_kanban" context="{'default_team_id':active_id, 'ro_team':True}">
|
||||
<kanban quick_create="true" create="true" delete="true">
|
||||
<field name="team_user_ids" widget="one2many" mode="kanban" context="{'default_team_id':active_id, 'ro_team':True}">
|
||||
<kanban>
|
||||
<field name="user_id"/>
|
||||
<field name="running"/>
|
||||
<templates>
|
||||
@@ -253,7 +245,6 @@
|
||||
<li><a type="open">
|
||||
<b><field name="name"/></b>
|
||||
</a></li>
|
||||
<!-- <li><field name="team_user_domain" widget="smart_filters"/></li> -->
|
||||
<li><field name="team_user_domain" widget='filters'/></li>
|
||||
</ul>
|
||||
</td>
|
||||
@@ -278,79 +269,21 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
IR FILTER - NOT IN USE RIGHT NOW
|
||||
-->
|
||||
<!-- Ir Filters Search Filter - action_id added -->
|
||||
<record model="ir.ui.view" id="ir_filters_view_search_inherit">
|
||||
<field name="name">ir.filters.inherit</field>
|
||||
<field name="model">ir.filters</field>
|
||||
<field name="inherit_id" ref="base.ir_filters_view_search" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<field name="action_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Ir Filters Tree View -->
|
||||
<record model="ir.ui.view" id="view_ir_filters_tree">
|
||||
<field name="name">Spam ir Filters Tree</field>
|
||||
<field name="model">ir.filters</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Spam Ir Filters">
|
||||
<field name="name"/>
|
||||
<field name="domain"/>
|
||||
<field name="model_id"/>
|
||||
<field name="action_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Ir Filters Action - form - tree -->
|
||||
<record model="ir.actions.act_window" id="spam_ir_filters_action">
|
||||
<field name="name">SpamIrFilter</field>
|
||||
<field name="res_model">ir.filters</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_ir_filters_tree"/>
|
||||
<field name="search_view_id" ref="ir_filters_view_search_inherit"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="spam_ir_filters_action">
|
||||
<field name="context" eval="{'search_default_action_id': ref('spam_ir_filters_action')}"/>
|
||||
</record>
|
||||
|
||||
<!-- Ir Filters Menu Item -->
|
||||
<!-- This menu item allows to see SpamIrFilters, /!\ the parent must be changed -->
|
||||
<!-- <menuitem id="spam_ir_filters" name="SpamIrFilters" parent="leads_menu" action="spam_ir_filters_action" /> -->
|
||||
|
||||
<!-- The following enables the more action that creates the filter on the email address of the lead -->
|
||||
<record id="action_mark_as_spam" model="ir.actions.server">
|
||||
<field name="name">Mark As Spam</field>
|
||||
<field name="model_id" ref="model_crm_lead"/>
|
||||
<record id="action_lead_dry_run" model="ir.actions.server">
|
||||
<field name="name">Lead Dry Run</field>
|
||||
<field name="model_id" ref="model_team_user"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
ir_action_id = self.pool['ir.actions.act_window'].search(cr, uid, [('name', '=', 'SpamIrFilter')], context=context)[0]
|
||||
values = {'model_id': 'crm.lead', 'action_id': ir_action_id}
|
||||
for lead_id in context['active_ids']:
|
||||
mail = self.read(cr, uid, lead_id, fields=['email_from'], context=context)['email_from']
|
||||
vals = values.copy()
|
||||
# str() below changes the encoding of mail from unicode
|
||||
vals['domain'] = [('email_from', '=', str(mail))]
|
||||
vals['name'] = 'spam-' + mail
|
||||
self.pool['ir.filters'].create_or_replace(cr, uid, vals, context=context)
|
||||
self.pool['crm.leads.dry.run'].assign_leads(cr, uid, None, context=context)
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- This record add the possibility to mark as spam in the more action of leads -->
|
||||
<!-- <record id="ir_mark_as_spam" model="ir.values">
|
||||
<record id="ir_lead_dry_run" model="ir.values">
|
||||
<field eval="'client_action_multi'" name="key2"/>
|
||||
<field eval="'crm.lead'" name="model"/>
|
||||
<field name="name">Mark As Spam</field>
|
||||
<field eval="'ir.actions.server,%d'%action_mark_as_spam" name="value"/>
|
||||
</record> -->
|
||||
<field eval="'team.user'" name="model"/>
|
||||
<field name="name">Launch Lead Dry Run</field>
|
||||
<field eval="'ir.actions.server,%d'%action_lead_dry_run" name="value"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user