Browse Source

[IMP] partner_multi_relation_tabs: improve tab performance

Restrict partner relation tab loading to contact forms
12.0
Stephan Keller 5 years ago
parent
commit
aa2f171a84
  1. 2
      partner_multi_relation_tabs/models/res_partner.py
  2. 4
      partner_multi_relation_tabs/tests/test_partner_tabs.py
  3. 3
      partner_multi_relation_tabs/views/menu.xml

2
partner_multi_relation_tabs/models/res_partner.py

@ -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()] = \

4
partner_multi_relation_tabs/tests/test_partner_tabs.py

@ -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()

3
partner_multi_relation_tabs/views/menu.xml

@ -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"

Loading…
Cancel
Save