You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. # Copyright 2013-2018 Therp BV <https://therp.nl>.
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import fields, models
  4. class ResPartnerRelationTypeSelection(models.Model):
  5. """Virtual relation types"""
  6. _inherit = 'res.partner.relation.type.selection'
  7. tab_id = fields.Many2one(
  8. comodel_name='res.partner.tab',
  9. string='Show relation on tab',
  10. readonly=True,
  11. )
  12. def _get_additional_view_fields(self):
  13. """Add tab_id to fields in view."""
  14. return ','.join([
  15. super(ResPartnerRelationTypeSelection, self)
  16. ._get_additional_view_fields(),
  17. "CASE"
  18. " WHEN NOT bas.is_inverse"
  19. " THEN lefttab.id"
  20. " ELSE righttab.id"
  21. " END as tab_id"])
  22. def _get_additional_tables(self):
  23. """Add two links to res_partner_tab."""
  24. return ' '.join([
  25. super(ResPartnerRelationTypeSelection, self)
  26. ._get_additional_tables(),
  27. "LEFT OUTER JOIN res_partner_tab lefttab"
  28. " ON typ.tab_left_id = lefttab.id",
  29. "LEFT OUTER JOIN res_partner_tab righttab"
  30. " ON typ.tab_right_id = righttab.id"])