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.

36 lines
1.2 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 fields, 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 context.get("active_ids") and context.get("active_model") == "res.partner":
  20. partners = self.env["res.partner"].browse(context["active_ids"])
  21. corp_partners = partners.filtered("parent_id")
  22. partners -= corp_partners
  23. partners |= corp_partners.mapped("commercial_partner_id")
  24. return partners.ids
  25. company_id = fields.Many2one(
  26. comodel_name="res.company",
  27. default=lambda self: self.env.company.id,
  28. required=False,
  29. string="Company",
  30. )