Browse Source
Merge pull request #891 from skeller1/12.0-imp-partner_multi_relation_tabs-browse
[12.0][IMP] partner_multi_relation_tabs: improve res.partner browse performance
12.0
Ronald Portier
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
17 additions and
10 deletions
-
partner_multi_relation_tabs/models/res_partner.py
-
partner_multi_relation_tabs/tests/test_partner_tabs.py
-
partner_multi_relation_tabs/views/menu.xml
|
|
@ -15,6 +15,7 @@ class ResPartner(models.Model): |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def browse(self, arg=None, prefetch=None): |
|
|
|
if "update_relation_tab" in self.env.context: |
|
|
|
for tab in self._get_tabs(): |
|
|
|
fieldname = tab.get_fieldname() |
|
|
|
if fieldname not in self._fields: |
|
|
@ -71,6 +72,7 @@ class ResPartner(models.Model): |
|
|
|
@api.depends('is_company', 'category_id') |
|
|
|
def _compute_tabs_visibility(self): |
|
|
|
"""Compute for all tabs wether they should be visible.""" |
|
|
|
if "update_relation_tab" in self.env.context: |
|
|
|
for tab in self._get_tabs(): # get all tabs |
|
|
|
for this in self: |
|
|
|
this[tab.get_visible_fieldname()] = \ |
|
|
|
|
|
@ -140,7 +140,9 @@ class TestPartnerTabs(common.TestCommon): |
|
|
|
def test_compute_visibility(self): |
|
|
|
"""Check the computation of visibility on partners.""" |
|
|
|
# pylint: disable=protected-access |
|
|
|
main_partner = self.env.ref('base.main_partner') |
|
|
|
main_partner = self.env.ref('base.main_partner').with_context({ |
|
|
|
'update_relation_tab': 1 |
|
|
|
}) |
|
|
|
main_partner._compute_tabs_visibility() |
|
|
|
tab_obj = Tab(self.tab_departments) |
|
|
|
fieldname = tab_obj.get_fieldname() |
|
|
|
|
|
@ -1,5 +1,8 @@ |
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
|
|
<odoo> |
|
|
|
<record id="contacts.action_contacts" model="ir.actions.act_window"> |
|
|
|
<field name="context">{'update_relation_tab': 1}</field> |
|
|
|
</record> |
|
|
|
|
|
|
|
<act_window |
|
|
|
id="action_res_partner_tab" |
|
|
|