[MOV] crm_project(_issue): Rename module and move feature on project.task
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': 'Lead to Issue',
|
||||
'summary': 'Create Issues from Leads',
|
||||
'name': 'Lead to Tasks',
|
||||
'summary': 'Create Tasks from Leads',
|
||||
'sequence': '19',
|
||||
'category': 'Project',
|
||||
'complexity': 'easy',
|
||||
'description': """
|
||||
Lead to Issues
|
||||
==============
|
||||
Lead to Tasks
|
||||
=============
|
||||
|
||||
Link module to map leads to issues
|
||||
Link module to map leads to tasks
|
||||
""",
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/crm_lead2projectissue_wizard_view.xml',
|
||||
'wizard/crm_lead_convert2task_views.xml',
|
||||
'views/crm_lead_views.xml'
|
||||
],
|
||||
'depends': ['crm', 'project_issue'],
|
||||
'depends': ['crm', 'project'],
|
||||
}
|
||||
+5
-5
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- inherit view of Lead Form : adding the "convert to issue" button -->
|
||||
<record id="crm_case_form_view_leads_project_issue" model="ir.ui.view">
|
||||
<field name="name">crm.lead.form.inherit.lead2projectissue</field>
|
||||
<!-- inherit view of Lead Form : adding the "convert to task" button -->
|
||||
<record id="crm_lead_view_form" model="ir.ui.view">
|
||||
<field name="name">crm.lead.form</field>
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='toggle_active']" position="before">
|
||||
<button class="oe_stat_button" type="action" name="%(convert_lead2projectissue_wizard_action)d" icon="fa-bug" help="Convert to Issue">
|
||||
<button class="oe_stat_button" type="action" name="%(crm_lead_convert2task_action)d" icon="fa-bug" help="Convert to Task">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_text">Convert To</span>
|
||||
<span class="o_stat_text">Issue</span>
|
||||
<span class="o_stat_text">Task</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import crm_lead2projectissue_wizard
|
||||
from . import crm_lead_convert2task
|
||||
+15
-15
@@ -2,32 +2,32 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class CrmLeadToProjectIssueWizard(models.TransientModel):
|
||||
""" wizard to convert a Lead into a Project Issue and move the Mail Thread """
|
||||
class CrmLeadConvert2Task(models.TransientModel):
|
||||
""" wizard to convert a Lead into a Project task and move the Mail Thread """
|
||||
|
||||
_name = "crm.lead2projectissue.wizard"
|
||||
_name = "crm.lead.convert2task"
|
||||
_inherit = 'crm.partner.binding'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
result = super(CrmLeadToProjectIssueWizard, self).default_get(fields)
|
||||
result = super(CrmLeadConvert2Task, self).default_get(fields)
|
||||
lead_id = self.env.context.get('active_id')
|
||||
if lead_id:
|
||||
result['lead_id'] = lead_id
|
||||
return result
|
||||
|
||||
lead_id = fields.Many2one('crm.lead', string='Lead', domain=[('type', '=', 'lead')])
|
||||
project_id = fields.Many2one('project.project', string='Project', domain=[('use_issues', '=', True)])
|
||||
project_id = fields.Many2one('project.project', string='Project', domain=[('use_tasks', '=', True)])
|
||||
|
||||
@api.multi
|
||||
def action_lead_to_project_issue(self):
|
||||
def action_lead_to_project_task(self):
|
||||
self.ensure_one()
|
||||
# get the lead to transform
|
||||
lead = self.lead_id
|
||||
partner_id = self._find_matching_partner()
|
||||
if not partner_id and (lead.partner_name or lead.contact_name):
|
||||
partner_id = lead.handle_partner_assignation()[lead.id]
|
||||
# create new project.issue
|
||||
# create new project.task
|
||||
vals = {
|
||||
"name": lead.name,
|
||||
"description": lead.description,
|
||||
@@ -36,23 +36,23 @@ class CrmLeadToProjectIssueWizard(models.TransientModel):
|
||||
"partner_id": partner_id,
|
||||
"user_id": None
|
||||
}
|
||||
issue = self.env['project.issue'].create(vals)
|
||||
task = self.env['project.task'].create(vals)
|
||||
# move the mail thread
|
||||
lead.message_change_thread(issue)
|
||||
lead.message_change_thread(task)
|
||||
# move attachments
|
||||
attachments = self.env['ir.attachment'].search([('res_model', '=', 'crm.lead'), ('res_id', '=', lead.id)])
|
||||
attachments.write({'res_model': 'project.issue', 'res_id': issue.id})
|
||||
attachments.write({'res_model': 'project.task', 'res_id': task.id})
|
||||
# archive the lead
|
||||
lead.write({'active': False})
|
||||
# return the action to go to the form view of the new Issue
|
||||
view = self.env.ref('project_issue.project_issue_form_view')
|
||||
# return the action to go to the form view of the new Task
|
||||
view = self.env.ref('project.view_task_form2')
|
||||
return {
|
||||
'name': 'Issue created',
|
||||
'name': 'Task created',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'view_id': view.id,
|
||||
'res_model': 'project.issue',
|
||||
'res_model': 'project.task',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id': issue.id,
|
||||
'res_id': task.id,
|
||||
'context': self.env.context
|
||||
}
|
||||
+8
-8
@@ -2,16 +2,16 @@
|
||||
<odoo>
|
||||
|
||||
<!-- view of the Wizard Form -->
|
||||
<record id="view_crm_lead2projectissue_wizard" model="ir.ui.view">
|
||||
<field name="name">crm.lead2projectissue.wizard.form</field>
|
||||
<field name="model">crm.lead2projectissue.wizard</field>
|
||||
<record id="crm_lead_convert2task_view_form" model="ir.ui.view">
|
||||
<field name="name">crm.lead.convert2task.form</field>
|
||||
<field name="model">crm.lead.convert2task</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Convert to Issue">
|
||||
<form string="Convert to Task">
|
||||
<group>
|
||||
<field name="project_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button type="object" name="action_lead_to_project_issue" string="Create Issue" class="btn-primary"/>
|
||||
<button type="object" name="action_lead_to_project_task" string="Create Task" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
@@ -19,9 +19,9 @@
|
||||
</record>
|
||||
|
||||
<!-- action of converting, via wizard -->
|
||||
<record id="convert_lead2projectissue_wizard_action" model="ir.actions.act_window">
|
||||
<field name="name">Convert to Issue</field>
|
||||
<field name="res_model">crm.lead2projectissue.wizard</field>
|
||||
<record id="crm_lead_convert2task_action" model="ir.actions.act_window">
|
||||
<field name="name">Convert to Task</field>
|
||||
<field name="res_model">crm.lead.convert2task</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
Reference in New Issue
Block a user