cubells
8 years ago
committed by
newtratip
9 changed files with 137 additions and 115 deletions
-
11partner_contact_department/README.rst
-
7partner_contact_department/__init__.py
-
16partner_contact_department/__openerp__.py
-
7partner_contact_department/models/__init__.py
-
16partner_contact_department/models/res_partner.py
-
5partner_contact_department/tests/__init__.py
-
31partner_contact_department/tests/test_recursion.py
-
75partner_contact_department/views/res_partner_department_view.xml
-
84partner_contact_department/views/res_partner_view.xml
@ -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 |
@ -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 |
@ -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 |
@ -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}) |
@ -1,47 +1,44 @@ |
|||
<?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 |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> |
|||
<!-- © 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"> |
|||
<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 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 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"> |
|||
<tree string="Departments" editable="top"> |
|||
<field name="name"/> |
|||
<field name="parent_id"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<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"> |
|||
<form> |
|||
<group> |
|||
<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"> |
|||
<tree string="Departments" editable="top"> |
|||
<field name="name"/> |
|||
<field name="parent_id"/> |
|||
<field name="child_ids"/> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<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"> |
|||
<form> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="parent_id"/> |
|||
<field name="child_ids"/> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<menuitem action="res_partner_department_action" |
|||
id="menu_res_partner_department" |
|||
parent="base.menu_config_address_book"/> |
|||
<menuitem action="res_partner_department_action" |
|||
id="menu_res_partner_department" |
|||
parent="base.menu_config_address_book"/> |
|||
|
|||
</data> |
|||
</openerp> |
|||
</odoo> |
@ -1,49 +1,47 @@ |
|||
<?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 |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> |
|||
<!-- © 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"> |
|||
<field name="name">Partner form with department</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//sheet/group//field[@name='function']" position="after"> |
|||
<field name="department_id" |
|||
placeholder="Department" |
|||
attrs="{'invisible': [('is_company','=', True)]}" |
|||
options='{"no_open": True}'/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='child_ids']/form//field[@name='function']" |
|||
position="after"> |
|||
<field name="is_company" invisible="True"/> |
|||
<field name="department_id" |
|||
placeholder="Department" |
|||
attrs="{'invisible': [('is_company','=', True)]}" |
|||
options='{"no_open": True}'/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
<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"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//sheet/group//field[@name='function']" position="after"> |
|||
<field name="department_id" |
|||
placeholder="Department" |
|||
attrs="{'invisible': [('is_company','=', True)]}" |
|||
options='{"no_open": True}'/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='child_ids']/form//field[@name='function']" |
|||
position="after"> |
|||
<field name="is_company" invisible="True"/> |
|||
<field name="department_id" |
|||
placeholder="Department" |
|||
attrs="{'invisible': [('is_company','=', True)]}" |
|||
options='{"no_open": True}'/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<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"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="category_id" position="after"> |
|||
<field name="department_id"/> |
|||
<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"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="category_id" position="after"> |
|||
<field name="department_id"/> |
|||
</field> |
|||
<filter name="salesperson" position="after"> |
|||
<filter name="department" |
|||
string="Department" |
|||
domain="[('is_company', '=', False)]" |
|||
context="{'group_by': 'department_id'}"/> |
|||
</filter> |
|||
</field> |
|||
<filter string="Salesperson" position="after"> |
|||
<filter string="Department" |
|||
domain="[('is_company', '=', False)]" |
|||
context="{'group_by': 'department_id'}"/> |
|||
</filter> |
|||
</field> |
|||
</record> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue