[ADD]Yaltik CRM Action : ability to link an action with a lead for the partner or its parent + action counts and listings from partner views targetting actions for partner and its parent
This commit is contained in:
parent
7d2a6bac07
commit
2c9d7cd506
@ -18,7 +18,7 @@
|
||||
{
|
||||
'name': 'CRM Actions',
|
||||
'summary': 'Action management, instead of new activity, in CRM',
|
||||
'version': '10.0.1.2.5',
|
||||
'version': '10.0.1.3.0',
|
||||
'category': 'Sales',
|
||||
'author': 'Fabien BOURGEOIS - Yaltik',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-11-24 04:34+0000\n"
|
||||
"PO-Revision-Date: 2017-11-24 04:34+0000\n"
|
||||
"POT-Creation-Date: 2017-11-26 07:15+0000\n"
|
||||
"PO-Revision-Date: 2017-11-26 07:15+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -35,6 +35,7 @@ msgid "Action count"
|
||||
msgstr "Nombre d'actions"
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: code:addons/yaltik_crm_action/models/res_partner.py:62
|
||||
#: model:ir.actions.act_window,name:yaltik_crm_action.crm_action_action
|
||||
#: model:ir.actions.act_window,name:yaltik_crm_action.crm_action_simple_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_lead_action_ids
|
||||
@ -44,6 +45,7 @@ msgstr "Nombre d'actions"
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_case_form_view_leads_inherit_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_case_form_view_oppor_inherit_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_view_partners_form_inherit_yaltik_crm_action
|
||||
#, python-format
|
||||
msgid "Actions"
|
||||
msgstr "Actions"
|
||||
|
||||
@ -198,7 +200,7 @@ msgid "Lead/Opportunity"
|
||||
msgstr "Piste/opportunité"
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: code:addons/yaltik_crm_action/models/crm_action.py:106
|
||||
#: code:addons/yaltik_crm_action/models/crm_action.py:100
|
||||
#, python-format
|
||||
msgid "Linked event"
|
||||
msgstr "Événement lié"
|
||||
@ -263,6 +265,11 @@ msgstr "Adresse du partenaire"
|
||||
msgid "Priority"
|
||||
msgstr "Priorité"
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_action_parent_id
|
||||
msgid "Related Company"
|
||||
msgstr "Société liée"
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_action_form
|
||||
msgid "Remove linked event"
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-11-24 04:33+0000\n"
|
||||
"PO-Revision-Date: 2017-11-24 04:33+0000\n"
|
||||
"POT-Creation-Date: 2017-11-26 07:15+0000\n"
|
||||
"PO-Revision-Date: 2017-11-26 07:15+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -34,6 +34,7 @@ msgid "Action count"
|
||||
msgstr ""
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: code:addons/yaltik_crm_action/models/res_partner.py:62
|
||||
#: model:ir.actions.act_window,name:yaltik_crm_action.crm_action_action
|
||||
#: model:ir.actions.act_window,name:yaltik_crm_action.crm_action_simple_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_lead_action_ids
|
||||
@ -43,6 +44,7 @@ msgstr ""
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_case_form_view_leads_inherit_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_case_form_view_oppor_inherit_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_view_partners_form_inherit_yaltik_crm_action
|
||||
#, python-format
|
||||
msgid "Actions"
|
||||
msgstr ""
|
||||
|
||||
@ -197,7 +199,7 @@ msgid "Lead/Opportunity"
|
||||
msgstr ""
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: code:addons/yaltik_crm_action/models/crm_action.py:106
|
||||
#: code:addons/yaltik_crm_action/models/crm_action.py:100
|
||||
#, python-format
|
||||
msgid "Linked event"
|
||||
msgstr ""
|
||||
@ -262,6 +264,11 @@ msgstr ""
|
||||
msgid "Priority"
|
||||
msgstr ""
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_action_parent_id
|
||||
msgid "Related Company"
|
||||
msgstr ""
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_action_form
|
||||
msgid "Remove linked event"
|
||||
|
@ -40,6 +40,7 @@ class CrmAction(models.Model):
|
||||
details = fields.Text()
|
||||
|
||||
partner_id = fields.Many2one('res.partner', string='Customer', index=True)
|
||||
parent_id = fields.Many2one(related='partner_id.parent_id')
|
||||
date = fields.Datetime(required=True, default=fields.Date.context_today)
|
||||
user_id = fields.Many2one('res.users', string='User', required=True,
|
||||
default=lambda self: self.env.user)
|
||||
@ -50,13 +51,6 @@ class CrmAction(models.Model):
|
||||
default=lambda self: self.env['crm.action.type'].search([], limit=1))
|
||||
action_type_name = fields.Char(related='action_type_id.name')
|
||||
|
||||
@api.onchange('lead_id')
|
||||
def onchange_lead(self):
|
||||
""" If lead change, adapts partner """
|
||||
for action in self:
|
||||
if action.lead_id and action.lead_id.partner_id:
|
||||
action.partner_id = action.lead_id.partner_id
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def onchange_partner(self):
|
||||
""" If partner changes, adapts lead to False """
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
""" Partner adaptations """
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Partner adaptations """
|
||||
@ -30,6 +30,12 @@ class ResPartner(models.Model):
|
||||
def _compute_action_count(self):
|
||||
for partner in self:
|
||||
domain = [('partner_id', '=', partner.id)]
|
||||
if partner.parent_id or partner.child_ids:
|
||||
domain.insert(0, '|')
|
||||
if partner.parent_id:
|
||||
domain.append(('partner_id', '=', partner.parent_id.id))
|
||||
elif partner.child_ids:
|
||||
domain.append(('partner_id', 'in', partner.child_ids.ids))
|
||||
action_count = self.env['crm.action'].search_count(domain)
|
||||
if action_count:
|
||||
domain.append(('state', '=', 'draft'))
|
||||
@ -37,3 +43,24 @@ class ResPartner(models.Model):
|
||||
else:
|
||||
draft_count = 0
|
||||
partner.action_count = u'{} / {}'.format(draft_count, action_count)
|
||||
|
||||
|
||||
@api.model
|
||||
def partner_actions(self):
|
||||
""" Return action for active partner and its parent """
|
||||
active_id = self._context.get('active_id')
|
||||
partner = self.env['res.partner'].browse(active_id)
|
||||
domain = [('partner_id', '=', partner.id)]
|
||||
if partner.parent_id or partner.child_ids:
|
||||
domain.insert(0, '|')
|
||||
if partner.parent_id:
|
||||
domain.append(('partner_id', '=', partner.parent_id.id))
|
||||
elif partner.child_ids:
|
||||
domain.append(('partner_id', 'in', partner.child_ids.ids))
|
||||
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Actions'),
|
||||
'view_mode': 'tree,form,calendar',
|
||||
'res_model': 'crm.action',
|
||||
'context': {'default_partner_id': partner.id},
|
||||
'domain': domain}
|
||||
|
@ -45,7 +45,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="priority" widget="priority" />
|
||||
<field name="details" width="200" />
|
||||
<field name="partner_id" />
|
||||
<field name="lead_id" domain="[('partner_id', '=', partner_id)]"
|
||||
<field name="parent_id" invisible="1" />
|
||||
<field name="lead_id"
|
||||
domain="['|', ('partner_id', '=', partner_id), ('partner_id', '=', parent_id)]"
|
||||
help="Lead for this action, depends on partner" />
|
||||
<field name="user_id" />
|
||||
</group>
|
||||
|
@ -37,12 +37,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</record>
|
||||
|
||||
<!-- Overwrite actity opening -->
|
||||
<record id="crm.crm_activity_report_action_tree"
|
||||
model="ir.actions.act_window">
|
||||
<delete id="crm.crm_activity_report_action_tree" model="ir.actions.act_window" />
|
||||
<record model="ir.actions.server" id="crm.crm_activity_report_action_tree">
|
||||
<field name="name">Actions</field>
|
||||
<field name="res_model">crm.action</field>
|
||||
<field name="view_mode">tree,form,calendar</field>
|
||||
<field name="context">{'search_default_partner_id': active_id}</field>
|
||||
<field name="model_id" ref="model_crm_action" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = env['res.partner'].partner_actions()</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user