diff --git a/partner_contact_department/README.rst b/partner_contact_department/README.rst new file mode 100644 index 000000000..34548936e --- /dev/null +++ b/partner_contact_department/README.rst @@ -0,0 +1,19 @@ +Department field in CRM contact +=============================== + +This module adds the concept of department to the CRM main objects (lead, +opportunity, partner), and propagate them through the workflow. + +Department is a drop-down field in lead, opportunity and partner forms. It +refers to contact department in its own company + +Departments available list must be defined first at +Sales > Configuration > Leads & Opportunities > Departments + +Credits +======= + +Contributors +------------ +* Pedro M. Baeza +* Antonio Espinosa diff --git a/partner_contact_department/__init__.py b/partner_contact_department/__init__.py new file mode 100644 index 000000000..054c8853d --- /dev/null +++ b/partner_contact_department/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import models diff --git a/partner_contact_department/__openerp__.py b/partner_contact_department/__openerp__.py new file mode 100644 index 000000000..4ffb8fe2b --- /dev/null +++ b/partner_contact_department/__openerp__.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Odoo Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com) +# Antonio Espinosa +# +# 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 . +# +############################################################################## + +{ + 'name': 'Department field in CRM contact', + 'version': '1.0', + 'category': 'Customer Relationship Management', + 'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' + 'Antiun Ingeniería S.L.', + 'website': 'http://www.serviciosbaeza.com, http://www.antiun.com', + 'depends': [ + 'crm', + ], + 'data': [ + 'views/crm_department_view.xml', + 'views/crm_lead_view.xml', + 'views/res_partner_view.xml', + 'security/ir.model.access.csv', + ], + "installable": True, +} diff --git a/partner_contact_department/i18n/crm_department.pot b/partner_contact_department/i18n/crm_department.pot new file mode 100644 index 000000000..9a33d3ef9 --- /dev/null +++ b/partner_contact_department/i18n/crm_department.pot @@ -0,0 +1,108 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_partner_department +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-27 08:51+0000\n" +"PO-Revision-Date: 2015-05-27 08:51+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_partner_department +#: field:crm.department,children:0 +msgid "Children" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,create_date:0 +msgid "Created on" +msgstr "" + +#. module: crm_partner_department +#: view:crm.lead:crm_partner_department.crm_case_form_view_leads_department +#: view:crm.lead:crm_partner_department.crm_case_form_view_oppor_department +#: view:crm.lead:crm_partner_department.view_crm_case_leads_filter_department +#: view:crm.lead:crm_partner_department.view_crm_case_opportunities_filter_department +#: field:crm.lead,department:0 +#: model:ir.model,name:crm_partner_department.model_crm_department +#: view:res.partner:crm_partner_department.view_partner_form_department +#: view:res.partner:crm_partner_department.view_res_partner_filter_department +#: field:res.partner,department:0 +msgid "Department" +msgstr "" + +#. module: crm_partner_department +#: view:crm.department:crm_partner_department.crm_department_tree_view +#: model:ir.actions.act_window,name:crm_partner_department.crm_department_action +#: model:ir.ui.menu,name:crm_partner_department.menu_crm_department +msgid "Departments" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,id:0 +msgid "ID" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: crm_partner_department +#: model:ir.model,name:crm_partner_department.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,name:0 +msgid "Name" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,parent_left:0 +msgid "Parent Left" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,parent_right:0 +msgid "Parent Right" +msgstr "" + +#. module: crm_partner_department +#: field:crm.department,parent_id:0 +msgid "Parent id" +msgstr "" + +#. module: crm_partner_department +#: model:ir.model,name:crm_partner_department.model_res_partner +msgid "Partner" +msgstr "" + +#. module: crm_partner_department +#: view:crm.lead:crm_partner_department.view_crm_case_leads_filter_department +#: view:crm.lead:crm_partner_department.view_crm_case_opportunities_filter_department +msgid "Sales Team" +msgstr "" + +#. module: crm_partner_department +#: view:res.partner:crm_partner_department.view_res_partner_filter_department +msgid "Salesperson" +msgstr "" + diff --git a/partner_contact_department/i18n/es.po b/partner_contact_department/i18n/es.po new file mode 100644 index 000000000..2c519e3c8 --- /dev/null +++ b/partner_contact_department/i18n/es.po @@ -0,0 +1,108 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_partner_department +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-27 08:51+0000\n" +"PO-Revision-Date: 2015-05-27 08:51+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_partner_department +#: field:crm.department,children:0 +msgid "Children" +msgstr "Hijos" + +#. module: crm_partner_department +#: field:crm.department,create_uid:0 +msgid "Created by" +msgstr "Creado por" + +#. module: crm_partner_department +#: field:crm.department,create_date:0 +msgid "Created on" +msgstr "Creado en" + +#. module: crm_partner_department +#: view:crm.lead:crm_partner_department.crm_case_form_view_leads_department +#: view:crm.lead:crm_partner_department.crm_case_form_view_oppor_department +#: view:crm.lead:crm_partner_department.view_crm_case_leads_filter_department +#: view:crm.lead:crm_partner_department.view_crm_case_opportunities_filter_department +#: field:crm.lead,department:0 +#: model:ir.model,name:crm_partner_department.model_crm_department +#: view:res.partner:crm_partner_department.view_partner_form_department +#: view:res.partner:crm_partner_department.view_res_partner_filter_department +#: field:res.partner,department:0 +msgid "Department" +msgstr "Departamento" + +#. module: crm_partner_department +#: view:crm.department:crm_partner_department.crm_department_tree_view +#: model:ir.actions.act_window,name:crm_partner_department.crm_department_action +#: model:ir.ui.menu,name:crm_partner_department.menu_crm_department +msgid "Departments" +msgstr "Departamentos" + +#. module: crm_partner_department +#: field:crm.department,id:0 +msgid "ID" +msgstr "ID" + +#. module: crm_partner_department +#: field:crm.department,write_uid:0 +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: crm_partner_department +#: field:crm.department,write_date:0 +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: crm_partner_department +#: model:ir.model,name:crm_partner_department.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: crm_partner_department +#: field:crm.department,name:0 +msgid "Name" +msgstr "Nombre" + +#. module: crm_partner_department +#: field:crm.department,parent_left:0 +msgid "Parent Left" +msgstr "Padre Izquierdo" + +#. module: crm_partner_department +#: field:crm.department,parent_right:0 +msgid "Parent Right" +msgstr "Padre Derecho" + +#. module: crm_partner_department +#: field:crm.department,parent_id:0 +msgid "Parent id" +msgstr "ID Padre" + +#. module: crm_partner_department +#: model:ir.model,name:crm_partner_department.model_res_partner +msgid "Partner" +msgstr "Empresa" + +#. module: crm_partner_department +#: view:crm.lead:crm_partner_department.view_crm_case_leads_filter_department +#: view:crm.lead:crm_partner_department.view_crm_case_opportunities_filter_department +msgid "Sales Team" +msgstr "Equipo de ventas" + +#. module: crm_partner_department +#: view:res.partner:crm_partner_department.view_res_partner_filter_department +msgid "Salesperson" +msgstr "Comercial" + diff --git a/partner_contact_department/models/__init__.py b/partner_contact_department/models/__init__.py new file mode 100644 index 000000000..006c33b3b --- /dev/null +++ b/partner_contact_department/models/__init__.py @@ -0,0 +1,8 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import crm_department +from . import crm_lead +from . import res_partner diff --git a/partner_contact_department/models/crm_department.py b/partner_contact_department/models/crm_department.py new file mode 100644 index 000000000..71bc4067e --- /dev/null +++ b/partner_contact_department/models/crm_department.py @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## +from openerp import models, fields + + +class CrmDepartment(models.Model): + _name = 'crm.department' + _order = "parent_left" + _parent_order = "name" + _parent_store = True + _description = "Department" + + name = fields.Char(required=True, translate=True) + parent_id = fields.Many2one(comodel_name='crm.department') + children = fields.One2many(comodel_name='crm.department', + inverse_name='parent_id') + parent_left = fields.Integer('Parent Left', select=True) + parent_right = fields.Integer('Parent Right', select=True) diff --git a/partner_contact_department/models/crm_lead.py b/partner_contact_department/models/crm_lead.py new file mode 100644 index 000000000..33fa82850 --- /dev/null +++ b/partner_contact_department/models/crm_lead.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## +from openerp import models, fields + + +class CrmLead(models.Model): + _inherit = 'crm.lead' + + department = fields.Many2one(comodel_name='crm.department') + + def _lead_create_contact(self, cr, uid, lead, name, is_company, + parent_id=False, context=None): + """Propagate department to created partner. + """ + partner_id = super(CrmLead, self)._lead_create_contact( + cr, uid, lead, name, is_company, parent_id=parent_id, + context=context) + self.pool['res.partner'].write( + cr, uid, partner_id, {'department': lead.department.id}, + context=context) + return partner_id diff --git a/partner_contact_department/models/res_partner.py b/partner_contact_department/models/res_partner.py new file mode 100644 index 000000000..b8c7cd3a8 --- /dev/null +++ b/partner_contact_department/models/res_partner.py @@ -0,0 +1,11 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## +from openerp import models, fields + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + department = fields.Many2one(comodel_name='crm.department') diff --git a/partner_contact_department/security/ir.model.access.csv b/partner_contact_department/security/ir.model.access.csv new file mode 100644 index 000000000..dc285f926 --- /dev/null +++ b/partner_contact_department/security/ir.model.access.csv @@ -0,0 +1,5 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_crm_department_public","crm_department group_public","model_crm_department","base.group_public",1,0,0,0 +"access_crm_department_portal","crm_department group_portal","model_crm_department","base.group_portal",1,0,0,0 +"access_crm_department_group_partner_manager","crm_department group_partner_manager","model_crm_department","base.group_partner_manager",1,1,1,1 +"access_crm_department_group_user","crm_department group_user","model_crm_department","base.group_user",1,0,0,0 diff --git a/partner_contact_department/static/description/icon.png b/partner_contact_department/static/description/icon.png new file mode 100644 index 000000000..add81b17a Binary files /dev/null and b/partner_contact_department/static/description/icon.png differ diff --git a/partner_contact_department/views/crm_department_view.xml b/partner_contact_department/views/crm_department_view.xml new file mode 100644 index 000000000..981e7d7b7 --- /dev/null +++ b/partner_contact_department/views/crm_department_view.xml @@ -0,0 +1,30 @@ + + + + + + Departments + crm.department + form + tree + + + + CRM department tree + crm.department + + + + + + + + + + + + \ No newline at end of file diff --git a/partner_contact_department/views/crm_lead_view.xml b/partner_contact_department/views/crm_lead_view.xml new file mode 100644 index 000000000..6b4d289af --- /dev/null +++ b/partner_contact_department/views/crm_lead_view.xml @@ -0,0 +1,64 @@ + + + + + + Add department field + crm.lead + + + + + + + + + + Add department field for searching and grouping + crm.lead + + + + + + + + + + + + + Add department field + crm.lead + + + + + + + + + + Add department field for searching and grouping + crm.lead + + + + + + + + + + + + + \ No newline at end of file diff --git a/partner_contact_department/views/res_partner_view.xml b/partner_contact_department/views/res_partner_view.xml new file mode 100644 index 000000000..8856abd93 --- /dev/null +++ b/partner_contact_department/views/res_partner_view.xml @@ -0,0 +1,55 @@ + + + + + + Partner form with department + res.partner + + + + + + + + + + + + + + + Partner search with department + res.partner + + + + + + + + + + + + + \ No newline at end of file