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.

28 lines
1.1 KiB

  1. # Copyright 2016 Tecnativa - Pedro M. Baeza
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import fields, models
  4. class BasePartnerMergeAutomaticWizard(models.TransientModel):
  5. _inherit = "base.partner.merge.automatic.wizard"
  6. group_by_website = fields.Boolean('Website')
  7. def _generate_query(self, fields, maximum_group=100):
  8. """Inject the additional criteria 'website IS NOT NULL' when needed.
  9. There's no better way to do it, as there are no hooks for adding
  10. this criteria regularly.
  11. """
  12. query = super(BasePartnerMergeAutomaticWizard, self)._generate_query(
  13. fields, maximum_group=maximum_group)
  14. if 'website' in fields:
  15. if 'WHERE' in query:
  16. index = query.find('WHERE')
  17. query = (query[:index + 6] + "website IS NOT NULL AND " +
  18. query[index + 6:])
  19. else:
  20. index = query.find(' GROUP BY')
  21. query = (query[:index] + " WHERE website IS NOT NULL" +
  22. query[index:])
  23. return query