Browse Source

partner_sector

pull/329/head
Javier Iniesta 9 years ago
committed by Pedro M. Baeza
parent
commit
c9a9d9ac8b
  1. 71
      partner_sector/README.rst
  2. 5
      partner_sector/__init__.py
  3. 24
      partner_sector/__openerp__.py
  4. 0
      partner_sector/i18n/.gitkeep
  5. 106
      partner_sector/i18n/es.po
  6. 106
      partner_sector/i18n/partner_sector.pot
  7. 6
      partner_sector/models/__init__.py
  8. 22
      partner_sector/models/res_partner.py
  9. 34
      partner_sector/models/res_partner_sector.py
  10. 5
      partner_sector/security/ir.model.access.csv
  11. BIN
      partner_sector/static/description/icon.png
  12. 5
      partner_sector/tests/__init__.py
  13. 16
      partner_sector/tests/test_res_partner.py
  14. 32
      partner_sector/views/res_partner_sector_view.xml
  15. 54
      partner_sector/views/res_partner_view.xml

71
partner_sector/README.rst

@ -0,0 +1,71 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==============
Partner Sector
==============
This module adds the concept of economic sector for partners.
Configuration
=============
To manage sectors, you need to:
* Go to *Sales > Configuration > Address Book > Sectors*.
Usage
=====
To use this module, you need to:
* Go to any partner's form.
Only companies have sectors.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/8.0
Known issues / Roadmap
======================
* Add a unique constraint for name per parent sector.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_sector%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Rafael Blasco <rafabn@antiun.com>
* Antonio Espinosa <antonioea@antiun.com>
* Javier Iniesta <javieria@antiun.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

5
partner_sector/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

24
partner_sector/__openerp__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner Sector",
"summary": "Add partner sectors",
"version": "8.0.1.0.0",
"category": "Customer Relationship Management",
"website": "http://www.antiun.com",
"author": "Antiun Ingeniería, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"base",
],
"data": [
"security/ir.model.access.csv",
"views/res_partner_sector_view.xml",
"views/res_partner_view.xml",
]
}

0
partner_sector/i18n/.gitkeep

106
partner_sector/i18n/es.po

@ -0,0 +1,106 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_sector
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-17 13:49+0000\n"
"PO-Revision-Date: 2015-12-17 13:49+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: partner_sector
#: field:res.partner.sector,child_ids:0
msgid "Children"
msgstr "Hijos"
#. module: partner_sector
#: field:res.partner.sector,create_uid:0
msgid "Created by"
msgstr "Creado por"
#. module: partner_sector
#: field:res.partner.sector,create_date:0
msgid "Created on"
msgstr "Creado en"
#. module: partner_sector
#: field:res.partner.sector,id:0
msgid "ID"
msgstr "ID"
#. module: partner_sector
#: field:res.partner.sector,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"
#. module: partner_sector
#: field:res.partner.sector,write_date:0
msgid "Last Updated on"
msgstr "Última actualización en"
#. module: partner_sector
#: field:res.partner,sector_id:0
msgid "Main Sector"
msgstr "Sector principal"
#. module: partner_sector
#: field:res.partner.sector,name:0
msgid "Name"
msgstr "Nombre"
#. module: partner_sector
#: field:res.partner.sector,parent_left:0
msgid "Parent Left"
msgstr "Padre izquierdo"
#. module: partner_sector
#: field:res.partner.sector,parent_right:0
msgid "Parent Right"
msgstr "Padre derecho"
#. module: partner_sector
#: field:res.partner.sector,parent_id:0
msgid "Parent id"
msgstr "ID del padre"
#. module: partner_sector
#: model:ir.model,name:partner_sector.model_res_partner
msgid "Partner"
msgstr "Empresa"
#. module: partner_sector
#: view:res.partner:partner_sector.view_res_partner_filter_sector
msgid "Salesperson"
msgstr "Comercial"
#. module: partner_sector
#: field:res.partner,secondary_sector_ids:0
msgid "Secondary Sectors"
msgstr "Sectores secundarios"
#. module: partner_sector
#: model:ir.model,name:partner_sector.model_res_partner_sector
#: view:res.partner:partner_sector.view_partner_form_sector
#: view:res.partner:partner_sector.view_res_partner_filter_sector
msgid "Sector"
msgstr "Sector"
#. module: partner_sector
#: model:ir.actions.act_window,name:partner_sector.res_partner_sector_action
#: model:ir.ui.menu,name:partner_sector.menu_res_partner_sector
#: view:res.partner.sector:partner_sector.res_partner_sector_tree_view
msgid "Sectors"
msgstr "Sectores"
#. module: partner_sector
#: code:addons/partner_sector/models/res_partner.py:21
#, python-format
msgid "The main sector must be different from the secondary sectors."
msgstr "El sector principal debe ser diferente a los sectores secundarios."

106
partner_sector/i18n/partner_sector.pot

@ -0,0 +1,106 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_sector
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-17 13:49+0000\n"
"PO-Revision-Date: 2015-12-17 13:49+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: partner_sector
#: field:res.partner.sector,child_ids:0
msgid "Children"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,create_uid:0
msgid "Created by"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,create_date:0
msgid "Created on"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,id:0
msgid "ID"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: partner_sector
#: field:res.partner,sector_id:0
msgid "Main Sector"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,name:0
msgid "Name"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,parent_left:0
msgid "Parent Left"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,parent_right:0
msgid "Parent Right"
msgstr ""
#. module: partner_sector
#: field:res.partner.sector,parent_id:0
msgid "Parent id"
msgstr ""
#. module: partner_sector
#: model:ir.model,name:partner_sector.model_res_partner
msgid "Partner"
msgstr ""
#. module: partner_sector
#: view:res.partner:partner_sector.view_res_partner_filter_sector
msgid "Salesperson"
msgstr ""
#. module: partner_sector
#: field:res.partner,secondary_sector_ids:0
msgid "Secondary Sectors"
msgstr ""
#. module: partner_sector
#: model:ir.model,name:partner_sector.model_res_partner_sector
#: view:res.partner:partner_sector.view_partner_form_sector
#: view:res.partner:partner_sector.view_res_partner_filter_sector
msgid "Sector"
msgstr ""
#. module: partner_sector
#: model:ir.actions.act_window,name:partner_sector.res_partner_sector_action
#: model:ir.ui.menu,name:partner_sector.menu_res_partner_sector
#: view:res.partner.sector:partner_sector.res_partner_sector_tree_view
msgid "Sectors"
msgstr ""
#. module: partner_sector
#: code:addons/partner_sector/models/res_partner.py:21
#, python-format
msgid "The main sector must be different from the secondary sectors."
msgstr ""

6
partner_sector/models/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner
from . import res_partner_sector

22
partner_sector/models/res_partner.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api, exceptions, _
class ResPartner(models.Model):
_inherit = 'res.partner'
sector_id = fields.Many2one(comodel_name='res.partner.sector',
string='Main Sector')
secondary_sector_ids = fields.Many2many(
comodel_name='res.partner.sector', string="Secondary Sectors",
domain="[('id', '!=', sector_id)]")
@api.constrains('sector_id', 'secondary_sector_ids')
def _check_sectors(self):
if self.sector_id in self.secondary_sector_ids:
raise exceptions.Warning(_('The main sector must be different '
'from the secondary sectors.'))

34
partner_sector/models/res_partner_sector.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api
class ResPartnerSector(models.Model):
_name = 'res.partner.sector'
_order = "parent_left"
_parent_order = "name"
_parent_store = True
_description = "Sector"
name = fields.Char(required=True, translate=True)
parent_id = fields.Many2one(comodel_name='res.partner.sector',
ondelete='restrict')
child_ids = fields.One2many(comodel_name='res.partner.sector',
inverse_name='parent_id',
string="Children")
parent_left = fields.Integer('Parent Left', select=True)
parent_right = fields.Integer('Parent Right', select=True)
@api.multi
def name_get(self):
def get_names(cat):
""" Return the list [cat.name, cat.parent_id.name, ...] """
res = []
while cat:
res.append(cat.name)
cat = cat.parent_id
return res
return [(cat.id, " / ".join(reversed(get_names(cat)))) for cat in self]

5
partner_sector/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_res_partner_sector_public","res_partner_sector group_public","model_res_partner_sector","base.group_public",1,0,0,0
"access_res_partner_sector_portal","res_partner_sector group_portal","model_res_partner_sector","base.group_portal",1,0,0,0
"access_res_partner_sector_group_partner_manager","res_partner_sector group_partner_manager","model_res_partner_sector","base.group_partner_manager",1,1,1,1
"access_res_partner_sector_group_user","res_partner_sector group_user","model_res_partner_sector","base.group_user",1,0,0,0

BIN
partner_sector/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

5
partner_sector/tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_res_partner

16
partner_sector/tests/test_res_partner.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Javier Iniesta
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
from openerp.exceptions import ValidationError
class TestResPartner(TransactionCase):
def test_check_sectors(self):
sector = self.env['res.partner.sector'].create({'name': 'Test'})
with self.assertRaises(ValidationError):
self.env['res.partner'].create(
{'name': 'Test', 'sector_id': sector.id,
'secondary_sector_ids': [(4, sector.id)]})

32
partner_sector/views/res_partner_sector_view.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Antiun Ingenieria S.L. - Javier Iniesta
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<record id="res_partner_sector_action" model="ir.actions.act_window">
<field name="name">Sectors</field>
<field name="res_model">res.partner.sector</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<record id="res_partner_sector_tree_view" model="ir.ui.view">
<field name="name">Partner Sector tree</field>
<field name="model">res.partner.sector</field>
<field name="arch" type="xml">
<tree string="Sectors" editable="top">
<field name="name"/>
<field name="parent_id"/>
</tree>
</field>
</record>
<menuitem action="res_partner_sector_action"
id="menu_res_partner_sector"
name="Sectors"
parent="base.menu_config_address_book"
sequence="3"/>
</data>
</openerp>

54
partner_sector/views/res_partner_view.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Antiun Ingenieria S.L. - Javier Iniesta
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<record model="ir.ui.view" id="view_partner_form_sector">
<field name="name">Partner form with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="phone" position="before">
<field name="sector_id" placeholder="Sector"
options='{"no_open": True}'
attrs="{'invisible': [('is_company', '=', False)]}"/>
<field name="secondary_sector_ids" widget="many2many_tags"
attrs="{'invisible': [('is_company', '=', False)]}"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_partner_tree_sector">
<field name="name">Partner tree with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<field name="email" position="after">
<field name="sector_id"
attrs="{'invisible': [('is_company', '=', False)]}"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_res_partner_filter_sector">
<field name="name">Partner search with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml">
<field name="category_id" position="after">
<field name="sector_id"
string="Sector"
filter_domain="['|',('sector_id','ilike',self),
('secondary_sector_ids','ilike',self)]"/>
</field>
<filter string="Salesperson" position="after">
<filter string="Sector"
domain="[('is_company','=', True)]"
context="{'group_by': 'sector_id'}"/>
</filter>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save