Browse Source

partner_contact_department

* Add tests
    * Other minor changes
pull/695/head
cubells 8 years ago
committed by Nikul-Chaudhary
parent
commit
517b9de594
  1. 11
      partner_contact_department/README.rst
  2. 7
      partner_contact_department/__init__.py
  3. 16
      partner_contact_department/__openerp__.py
  4. 7
      partner_contact_department/models/__init__.py
  5. 16
      partner_contact_department/models/res_partner.py
  6. 5
      partner_contact_department/tests/__init__.py
  7. 31
      partner_contact_department/tests/test_recursion.py
  8. 25
      partner_contact_department/views/res_partner_department_view.xml
  9. 24
      partner_contact_department/views/res_partner_view.xml

11
partner_contact_department/README.rst

@ -29,7 +29,7 @@ To use this module, you need to:
.. 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
:target: https://runbot.odoo-community.org/runbot/134/9.0
Bug Tracker
===========
@ -37,11 +37,7 @@ 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
<https://github.com/OCA/
partner-contact/issues/new?body=module:%20
partner_contact_department%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
=======
@ -49,7 +45,7 @@ Credits
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
------------
@ -58,6 +54,7 @@ Contributors
* Antonio Espinosa <antonioea@antiun.com>
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
Maintainer
----------

7
partner_contact_department/__init__.py

@ -1,9 +1,6 @@
# -*- 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-2015 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

16
partner_contact_department/__openerp__.py

@ -1,21 +1,17 @@
# -*- 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-2015 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Contact department',
"summary": "Assign contacts to departments",
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'category': 'Customer Relationship Management',
'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, '
'Antiun Ingeniería S.L., '
"Odoo Community Association (OCA)",
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
"license": "AGPL-3",
'website': 'http://www.antiun.com',
'website': 'http://www.tecnativa.com',
"application": False,
'depends': [
'base',

7
partner_contact_department/models/__init__.py

@ -1,9 +1,6 @@
# -*- 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-2015 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner

16
partner_contact_department/models/res_partner.py

@ -1,12 +1,10 @@
# -*- 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-2015 Tecnativa S.L. - Jairo Llopis
# © 2016 Tecnativa S.L. - Vicent Cubells
# 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):
@ -37,3 +35,9 @@ class ResPartnerDepartment(models.Model):
oldname="children")
parent_left = 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 departments.'))

5
partner_contact_department/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

31
partner_contact_department/tests/test_recursion.py

@ -0,0 +1,31 @@
# -*- 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.department_obj = cls.env['res.partner.department']
# Instances
cls.dpt1 = cls.department_obj.create(vals=dict(name='Dpt. 1'))
cls.dpt2 = cls.department_obj.create(
vals=dict(
name='Dpt. 2',
parent_id=cls.dpt1.id
))
def test_recursion(self):
""" Testing recursion """
self.dpt3 = self.department_obj.create(vals=dict(
name='Dpt. 3',
parent_id=self.dpt2.id
))
# Creating a parent's child department using dpt1.
with self.assertRaises(ValidationError):
self.dpt1.write(vals={'parent_id': self.dpt3.id})

25
partner_contact_department/views/res_partner_department_view.xml

@ -1,20 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
© 2015 Antiun Ingeniería S.L. - Antonio Espinosa
© 2015 Antiun Ingeniería S.L. - Jairo Llopis
<!-- © 2014-2015 Tecnativa S.L. - Jairo Llopis
© 2016 Tecnativa S.L. - Vicent Cubells
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<odoo>
<record id="res_partner_department_action" model="ir.actions.act_window">
<record id="res_partner_department_action" model="ir.actions.act_window">
<field name="name">Departments</field>
<field name="res_model">res.partner.department</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
</record>
<record id="res_partner_department_tree_view" model="ir.ui.view">
<record id="res_partner_department_tree_view" model="ir.ui.view">
<field name="name">CRM department tree</field>
<field name="model">res.partner.department</field>
<field name="arch" type="xml">
@ -23,9 +21,9 @@
<field name="parent_id"/>
</tree>
</field>
</record>
</record>
<record id="res_partner_department_form_view" model="ir.ui.view">
<record id="res_partner_department_form_view" model="ir.ui.view">
<field name="name">CRM department form</field>
<field name="model">res.partner.department</field>
<field name="arch" type="xml">
@ -37,11 +35,10 @@
</group>
</form>
</field>
</record>
</record>
<menuitem action="res_partner_department_action"
<menuitem action="res_partner_department_action"
id="menu_res_partner_department"
parent="base.menu_config_address_book"/>
</data>
</openerp>
</odoo>

24
partner_contact_department/views/res_partner_view.xml

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
© 2015 Antiun Ingeniería S.L. - Antonio Espinosa
© 2015 Antiun Ingeniería S.L. - Jairo Llopis
<!-- © 2014-2015 Tecnativa S.L. - Jairo Llopis
© 2016 Tecnativa S.L. - Vicent Cubells
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<odoo>
<record model="ir.ui.view" id="view_partner_form_department">
<record model="ir.ui.view" id="view_partner_form_department">
<field name="name">Partner form with department</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
@ -27,9 +25,9 @@
options='{"no_open": True}'/>
</xpath>
</field>
</record>
</record>
<record model="ir.ui.view" id="view_res_partner_filter_department">
<record model="ir.ui.view" id="view_res_partner_filter_department">
<field name="name">Partner search with department</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
@ -37,13 +35,13 @@
<field name="category_id" position="after">
<field name="department_id"/>
</field>
<filter string="Salesperson" position="after">
<filter string="Department"
<filter name="salesperson" position="after">
<filter name="department"
string="Department"
domain="[('is_company', '=', False)]"
context="{'group_by': 'department_id'}"/>
</filter>
</field>
</record>
</record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save