Browse Source

[MIG] partner_contact_job_position

* Changed icon
    * Change author and web
    * Check recursion
pull/328/head
cubells 8 years ago
committed by Pedro M. Baeza
parent
commit
03bab9c32b
  1. 11
      partner_contact_job_position/README.rst
  2. 7
      partner_contact_job_position/__init__.py
  3. 14
      partner_contact_job_position/__openerp__.py
  4. 7
      partner_contact_job_position/models/__init__.py
  5. 16
      partner_contact_job_position/models/res_partner.py
  6. BIN
      partner_contact_job_position/static/description/icon.png
  7. 5
      partner_contact_job_position/tests/__init__.py
  8. 30
      partner_contact_job_position/tests/test_recursion.py
  9. 20
      partner_contact_job_position/views/res_partner_job_position_view.xml
  10. 19
      partner_contact_job_position/views/res_partner_view.xml

11
partner_contact_job_position/README.rst

@ -28,7 +28,7 @@ To use this module, you need to:
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/8.0
:target: https://runbot.odoo-community.org/runbot/134/9.0
Bug Tracker Bug Tracker
=========== ===========
@ -36,11 +36,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please <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, 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
<https://github.com/OCA/
partner-contact/issues/new?body=module:%20
{module_name}%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
help us smashing it by providing a detailed and welcomed feedback.
Credits Credits
======= =======
@ -48,7 +44,7 @@ Credits
Images Images
------ ------
* `Antiun Ingeniería S.L. <http://www.antiun.com>`_: Icon.
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors Contributors
------------ ------------
@ -57,6 +53,7 @@ Contributors
* Antonio Espinosa <antonioea@antiun.com> * Antonio Espinosa <antonioea@antiun.com>
* Rafael Blasco <rafabn@antiun.com> * Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com> * Jairo Llopis <yajo.sk8@gmail.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
Maintainer Maintainer
---------- ----------

7
partner_contact_job_position/__init__.py

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Antonio Espinosa <antonioea@antiun.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# © 2014-2016 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

14
partner_contact_job_position/__openerp__.py

@ -1,19 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Antonio Espinosa <antonioea@antiun.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# © 2014-2016 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Partner job position", "name": "Partner job position",
"summary": "Categorize job positions for contacts", "summary": "Categorize job positions for contacts",
"version": "8.0.1.0.0",
"version": "9.0.1.0.0",
'category': 'Customer Relationship Management', 'category': 'Customer Relationship Management',
"website": "http://www.antiun.com",
'author': 'Serv. Tecnolog. Avanzados - Pedro M. Baeza, '
'Antiun Ingeniería S.L., '
"website": "http://www.tecnativa.com",
'author': 'Tecnativa, '
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": False, "application": False,

7
partner_contact_job_position/models/__init__.py

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Antonio Espinosa <antonioea@antiun.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# © 2014-2016 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner from . import res_partner

16
partner_contact_job_position/models/res_partner.py

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Antonio Espinosa <antonioea@antiun.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# © 2014-2016 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
class ResPartner(models.Model): class ResPartner(models.Model):
@ -36,3 +34,9 @@ class ResPartnerJobPosition(models.Model):
oldname="children") oldname="children")
parent_left = fields.Integer(index=True) parent_left = fields.Integer(index=True)
parent_right = fields.Integer(index=True) parent_right = fields.Integer(index=True)
@api.constrains('parent_id')
def _check_parent_id(self):
if not self._check_recursion():
raise ValidationError(
_('Error! You cannot create recursive job positions.'))

BIN
partner_contact_job_position/static/description/icon.png

Before

Width: 128  |  Height: 128  |  Size: 22 KiB

After

Width: 128  |  Height: 128  |  Size: 11 KiB

5
partner_contact_job_position/tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from . import test_recursion

30
partner_contact_job_position/tests/test_recursion.py

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# © 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from openerp.tests import common
from openerp.exceptions import ValidationError
class TestRecursion(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestRecursion, cls).setUpClass()
cls.job_obj = cls.env['res.partner.job_position']
# Instances
cls.grand_parent = cls.job_obj.create(vals=dict(name='Grand parent'))
cls.parent = cls.job_obj.create(vals=dict(
name='Parent',
parent_id=cls.grand_parent.id
))
def test_recursion(self):
""" Testing recursion """
self.child = self.job_obj.create(vals=dict(
name='Grand parent',
parent_id=self.parent.id
))
# Creating a parent's child using grand-parent
with self.assertRaises(ValidationError):
self.grand_parent.write(vals={'parent_id': self.child.id})

20
partner_contact_job_position/views/res_partner_job_position_view.xml

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="res_partner_job_position_action" model="ir.actions.act_window">
<record id="res_partner_job_position_action" model="ir.actions.act_window">
<field name="name">Job Positions</field> <field name="name">Job Positions</field>
<field name="res_model">res.partner.job_position</field> <field name="res_model">res.partner.job_position</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree</field> <field name="view_mode">tree</field>
</record>
</record>
<record id="res_partner_job_position_tree_view" model="ir.ui.view">
<record id="res_partner_job_position_tree_view" model="ir.ui.view">
<field name="name">Job position tree</field> <field name="name">Job position tree</field>
<field name="model">res.partner.job_position</field> <field name="model">res.partner.job_position</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -18,9 +17,9 @@
<field name="parent_id"/> <field name="parent_id"/>
</tree> </tree>
</field> </field>
</record>
</record>
<record id="res_partner_job_position_form_view" model="ir.ui.view">
<record id="res_partner_job_position_form_view" model="ir.ui.view">
<field name="name">Job position form</field> <field name="name">Job position form</field>
<field name="model">res.partner.job_position</field> <field name="model">res.partner.job_position</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -32,11 +31,10 @@
</group> </group>
</form> </form>
</field> </field>
</record>
</record>
<menuitem action="res_partner_job_position_action"
<menuitem action="res_partner_job_position_action"
id="menu_res_partner_job_position" id="menu_res_partner_job_position"
parent="base.menu_config_address_book"/> parent="base.menu_config_address_book"/>
</data>
</openerp>
</odoo>

19
partner_contact_job_position/views/res_partner_view.xml

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record model="ir.ui.view" id="view_partner_form_job_position">
<record model="ir.ui.view" id="view_partner_form_job_position">
<field name="name">Partner form with job position</field> <field name="name">Partner form with job position</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="inherit_id" ref="base.view_partner_form"/>
@ -19,9 +18,9 @@
options='{"no_open": True}'/> options='{"no_open": True}'/>
</xpath> </xpath>
</field> </field>
</record>
</record>
<record model="ir.ui.view" id="view_res_partner_filter_job_position">
<record model="ir.ui.view" id="view_res_partner_filter_job_position">
<field name="name">Partner search with job position</field> <field name="name">Partner search with job position</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/> <field name="inherit_id" ref="base.view_res_partner_filter"/>
@ -29,13 +28,13 @@
<field name="category_id" position="after"> <field name="category_id" position="after">
<field name="job_position_id"/> <field name="job_position_id"/>
</field> </field>
<filter string="Salesperson" position="after">
<filter string="Job position"
<filter name="salesperson" position="after">
<filter name="job_position"
string="Job position"
domain="[('is_company','=', True)]" domain="[('is_company','=', True)]"
context="{'group_by': 'job_position_id'}"/> context="{'group_by': 'job_position_id'}"/>
</filter> </filter>
</field> </field>
</record>
</record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save