[IMP]CRM Action : smart button now have draft / total actions
This commit is contained in:
parent
60e997ee61
commit
7d2a6bac07
@ -18,7 +18,7 @@
|
||||
{
|
||||
'name': 'CRM Actions',
|
||||
'summary': 'Action management, instead of new activity, in CRM',
|
||||
'version': '10.0.1.2.4',
|
||||
'version': '10.0.1.2.5',
|
||||
'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-23 06:29+0000\n"
|
||||
"PO-Revision-Date: 2017-11-23 06:29+0000\n"
|
||||
"POT-Creation-Date: 2017-11-24 04:34+0000\n"
|
||||
"PO-Revision-Date: 2017-11-24 04:34+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -29,6 +29,8 @@ msgstr "Types d'action"
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_lead_action_count
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_res_partner_action_count
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_res_users_action_count
|
||||
msgid "Action count"
|
||||
msgstr "Nombre d'actions"
|
||||
|
||||
@ -41,6 +43,7 @@ msgstr "Nombre d'actions"
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_action_form
|
||||
#: 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
|
||||
msgid "Actions"
|
||||
msgstr "Actions"
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-11-23 06:29+0000\n"
|
||||
"PO-Revision-Date: 2017-11-23 06:29+0000\n"
|
||||
"POT-Creation-Date: 2017-11-24 04:33+0000\n"
|
||||
"PO-Revision-Date: 2017-11-24 04:33+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -28,6 +28,8 @@ msgstr ""
|
||||
|
||||
#. module: yaltik_crm_action
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_crm_lead_action_count
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_res_partner_action_count
|
||||
#: model:ir.model.fields,field_description:yaltik_crm_action.field_res_users_action_count
|
||||
msgid "Action count"
|
||||
msgstr ""
|
||||
|
||||
@ -40,6 +42,7 @@ msgstr ""
|
||||
#: model:ir.ui.view,arch_db:yaltik_crm_action.crm_action_form
|
||||
#: 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
|
||||
msgid "Actions"
|
||||
msgstr ""
|
||||
|
||||
|
@ -25,10 +25,10 @@ class CrmLead(models.Model):
|
||||
""" CRM Lead adaptations """
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
action_count = fields.Integer(compute='_compute_action_count')
|
||||
action_count = fields.Char(compute='_compute_action_count')
|
||||
action_ids = fields.One2many('crm.action', 'lead_id', string='Actions')
|
||||
next_action_id = fields.Many2one('crm.action', string='Next Action',
|
||||
compute='compute_next_action', store=True)
|
||||
compute='_compute_next_action', store=True)
|
||||
next_action_date = fields.Datetime(related='next_action_id.date', store=True)
|
||||
next_action_title = fields.Char(related='next_action_id.display_name', store=True)
|
||||
|
||||
@ -36,10 +36,13 @@ class CrmLead(models.Model):
|
||||
def _compute_action_count(self):
|
||||
""" Count actions """
|
||||
for lead in self:
|
||||
lead.action_count = len(lead.action_ids)
|
||||
action_count = len(lead.action_ids)
|
||||
draft_count = len(lead.action_ids.filtered(
|
||||
lambda self: self.state == 'draft'))
|
||||
lead.action_count = u'{} / {}'.format(draft_count, action_count)
|
||||
|
||||
@api.depends('action_ids.date', 'action_ids.display_name', 'action_ids.state')
|
||||
def compute_next_action(self):
|
||||
def _compute_next_action(self):
|
||||
""" Computes next action """
|
||||
for lead in self:
|
||||
domain = ['&', ('lead_id', '=', lead.id), ('state', '=', 'draft')]
|
||||
|
@ -18,14 +18,22 @@
|
||||
|
||||
""" Partner adaptations """
|
||||
|
||||
from odoo import models, api
|
||||
from odoo import models, fields, api
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Partner adaptations """
|
||||
_inherit = 'res.partner'
|
||||
|
||||
action_count = fields.Char(compute='_compute_action_count')
|
||||
|
||||
@api.multi
|
||||
def _compute_activities_count(self):
|
||||
def _compute_action_count(self):
|
||||
for partner in self:
|
||||
domain = [('partner_id', '=', partner.id)]
|
||||
partner.activities_count = self.env['crm.action'].search_count(domain)
|
||||
action_count = self.env['crm.action'].search_count(domain)
|
||||
if action_count:
|
||||
domain.append(('state', '=', 'draft'))
|
||||
draft_count = self.env['crm.action'].search_count(domain)
|
||||
else:
|
||||
draft_count = 0
|
||||
partner.action_count = u'{} / {}'.format(draft_count, action_count)
|
||||
|
@ -20,6 +20,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="crm_view_partners_form_inherit_yaltik_crm_action"
|
||||
model="ir.ui.view">
|
||||
<field name="name">CRM Partner form adaptations</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="crm.view_partners_form_crm1" />
|
||||
<field name="arch" type="xml">
|
||||
<button icon="fa-clock-o" position="replace">
|
||||
<button class="oe_stat_button" type="action"
|
||||
name="%(crm.crm_activity_report_action_tree)d" icon="fa-clock-o">
|
||||
<field string="Actions" name="action_count" widget="statinfo" />
|
||||
</button>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Overwrite actity opening -->
|
||||
<record id="crm.crm_activity_report_action_tree"
|
||||
model="ir.actions.act_window">
|
||||
|
Loading…
Reference in New Issue
Block a user