Esempio n. 1
0
    def matches(self,
                query,
                mode=MATCH_MODE_NORMAL,
                stop_on_first=False,
                threshold=None):
        """
        Given an query find recordset that is strongly similar
        @TODO implement threshold
        """
        matches = self.env['openg2p.beneficiary']
        work = WorkContext(model_name=self._name,
                           collection=self.with_context(active_test=False))
        matchers = [
            matcher
            for matcher in work.many_components(usage='beneficiary.matcher')
            if matcher.mode <= mode
        ]
        matchers.sort(key=lambda r: r.sequence)

        for matcher in matchers:
            res = matcher.match(query)
            if res:
                matches += res
                if stop_on_first:
                    break

        return matches if len(matches) else False
 def _get_all_provider(self):
     work = WorkContext(model_name=self._name, collection=self)
     return [
         provider
         for provider in work.many_components(usage='gateway.provider')
     ]