Skip to content

Commit

Permalink
Merge b46b457 into 77efa6f
Browse files Browse the repository at this point in the history
  • Loading branch information
mstuttgart committed Sep 7, 2015
2 parents 77efa6f + b46b457 commit 1813268
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 0 deletions.
3 changes: 3 additions & 0 deletions l10n_br_crm_zip/README.md
@@ -0,0 +1,3 @@
Módulo de Cep para o CRM
========================
ZIP Search Integration for Brazilian Localization of CRM module
20 changes: 20 additions & 0 deletions l10n_br_crm_zip/__init__.py
@@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-
###############################################################################
# #
# Copyright (C) 2011 Renato Lima - Akretion #
# #
# 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 <http://www.gnu.org/licenses/>. #
###############################################################################

from . import models
38 changes: 38 additions & 0 deletions l10n_br_crm_zip/__openerp__.py
@@ -0,0 +1,38 @@
# -*- encoding: utf-8 -*-
###############################################################################
# #
# Copyright (C) 2011 Fabio Negrini - Akretion #
# #
# 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 <http://www.gnu.org/licenses/>. #
###############################################################################

{
'name': 'Brazilian Localization CRM Zip',
'category': 'Localization',
'license': 'AGPL-3',
'author': 'Fabio Negrini - OpenERP Brasil',
'website': 'http://openerpbrasil.org',
'version': '8.0',
'depends': [
'l10n_br_zip',
'l10n_br_crm',
],
'data': [
'views/crm_lead_view.xml',
'views/crm_opportunity_view.xml',
],
'demo': [],
'installable': True,
'auto_install': True,
}
20 changes: 20 additions & 0 deletions l10n_br_crm_zip/i18n/pt_BR.po
@@ -0,0 +1,20 @@
#. module: base
#: model:ir.module.module,shortdesc:base.module_l10n_br_crm_zip
msgid "Brazilian Localization CRM Zip"
msgstr "Localização Brasileira - Módulo de Cep para o CRM"

#. module: base
#: model:ir.module.module,description:base.module_l10n_br_crm_zip
msgid "ZIP Search Integration for Brazilian Localization of CRM module"
msgstr "Localização Brasileira - Integra a busca de cep ao módulo de CRM"

#. module: l10n_br_crm_zip
#: model:ir.model,name:l10n_br_crm_zip.model_crm_lead
msgid "Lead/Opportunity"
msgstr "Prospecto/Oportunidade"

#. module: l10n_br_crm_zip
#: code:addons/l10n_br_crm_zip/models/crm_lead.py:64
#, python-format
msgid "No records found!"
msgstr "Nenhum registro encontrado!"
22 changes: 22 additions & 0 deletions l10n_br_crm_zip/models/__init__.py
@@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
###############################################################################
# #
# Copyright (C) 2015 KMEE - www.kmee.com.br #
# Michell Stuttgart <michell.stuttgart@kmee.com.br> #
# #
# 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################

from . import crm_lead
64 changes: 64 additions & 0 deletions l10n_br_crm_zip/models/crm_lead.py
@@ -0,0 +1,64 @@
# -*- encoding: utf-8 -*-
###############################################################################
# #
# Copyright (C) 2012 Renato Lima - Akretion #
# #
# 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 <http://www.gnu.org/licenses/>. #
###############################################################################

from openerp import models, api
from openerp.tools.translate import _
from openerp.exceptions import Warning


class CrmLead(models.Model):
""" CRM Lead Case """
_inherit = "crm.lead"

@api.multi
def zip_search(self):
self.ensure_one()
obj_zip = self.env['l10n_br.zip']

zip_ids = obj_zip.zip_search_multi(
country_id=self.country_id.id,
state_id=self.state_id.id,
l10n_br_city_id=self.l10n_br_city_id.id,
district=self.district,
street=self.street,
zip_code=self.zip,
)

obj_zip_result = self.env['l10n_br.zip.result']
zip_ids = obj_zip_result.map_to_zip_result(zip_ids, self._name,
self.id)
if len(zip_ids) == 1:
result = obj_zip.set_result(zip_ids[0])
self.write(result)
return True
else:
if len(zip_ids) > 1:
return obj_zip.create_wizard(
self._name,
self.id,
country_id=self.country_id.id,
state_id=self.state_id.id,
l10n_br_city_id=self.l10n_br_city_id.id,
district=self.district,
street=self.street,
zip_code=self.zip,
zip_ids=[z.id for z in zip_ids],
)
else:
raise Warning(_('No records found!'))
20 changes: 20 additions & 0 deletions l10n_br_crm_zip/views/crm_lead_view.xml
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<!-- CRM Lead Form View -->
<record model="ir.ui.view" id="l10n_br_crm_case_form_view_leads1">
<field name="name">l10n_br_crm.leads1</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="zip" position="after">
<button name="zip_search" type="object" class="oe_inline">
<i class="fa fa-search"></i>
</button>
</field>
</field>
</record>

</data>
</openerp>
20 changes: 20 additions & 0 deletions l10n_br_crm_zip/views/crm_opportunity_view.xml
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<!-- CRM Opportunity Form View -->
<record model="ir.ui.view" id="l10n_br_crm_case_form_view_oppor1">
<field name="name">l10n_br_crm.opportunities1</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
<field name="arch" type="xml">
<field name="zip" position="after">
<button name="zip_search" type="object" class="oe_inline">
<i class="fa fa-search"></i>
</button>
</field>
</field>
</record>

</data>
</openerp>

0 comments on commit 1813268

Please sign in to comment.