Add a domain to MatchMixin
When the number of records in a price list or any other MatchMixin model is relatively large, the computation time can become a problem. Fortunately that is easy to optimize by discarding before hand those records that we know will never match.
That is what we implemented here, for example:
https://bitbucket.org/trytonspain/trytond-sale_discount_price_list/src/8724eb5bde8328d555231d0ef8c3f55f6c83177b/price_list.py#lines-27
Which drastically cut the computation time for a customer with around 2000 pricelist lines on a single pricelist.
Here's the MatchMixin implementation for reference:
http://hg.tryton.org/trytond/file/tip/trytond/model/match.py
So I propose that we add a method that looks more or less like this in MatchMixin:
@classmethod
def match_domain(cls, pattern):
domain = []
for field, pattern_value in pattern.iteritems():
if pattern_value is None:
continue
domain += ['OR', (field, '=', None), (field, '=', pattern_value)]
return domain
Files
Download | Creator | Timestamp | Type |
---|---|---|---|
unnamed | @albertca | 2018-08-21 15:33:44.190000 UTC | text/plain |