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.

32 lines
1.0 KiB

  1. # Copyright 2019 Lorenzo Battistini @ TAKOBI
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import models
  4. class AbstractWizard(models.AbstractModel):
  5. _name = 'account_financial_report_abstract_wizard'
  6. _description = 'Abstract Wizard'
  7. def _get_partner_ids_domain(self):
  8. return [
  9. '&',
  10. '|',
  11. ('company_id', '=', self.company_id.id),
  12. ('company_id', '=', False),
  13. '|',
  14. ('parent_id', '=', False),
  15. ('is_company', '=', True),
  16. ]
  17. def _default_partners(self):
  18. context = self.env.context
  19. if (
  20. context.get('active_ids') and
  21. context.get('active_model') == 'res.partner'
  22. ):
  23. partners = self.env['res.partner'].browse(context['active_ids'])
  24. corp_partners = partners.filtered('parent_id')
  25. partners -= corp_partners
  26. partners |= corp_partners.mapped('commercial_partner_id')
  27. return partners.ids