Skip to content

Commit

Permalink
Get rid of cache management
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoRubi committed Mar 3, 2021
1 parent 4fdc442 commit c7fa110
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions account_invoice_triple_discount/models/line_triple_discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,13 @@ def triple_discount_preprocess(self):
this method is called multiple times.
Updating the cache provides consistency through recomputations."""
prev_values = dict()
self.invalidate_cache(
fnames=['discount', 'discount2', 'discount3'],
ids=self.ids)
for line in self:
prev_values[line] = dict(
discount=line.discount,
discount2=line.discount2,
discount3=line.discount3,
)
line._cache.update({
line.update({
'discount': line._get_final_discount(),
'discount2': 0.0,
'discount3': 0.0
Expand All @@ -99,8 +96,5 @@ def triple_discount_preprocess(self):
def triple_discount_postprocess(self, prev_values):
"""Restore the discounts of the lines in the dictionary prev_values.
Updating the cache provides consistency through recomputations."""
self.invalidate_cache(
fnames=['discount', 'discount2', 'discount3'],
ids=[l.id for l in list(prev_values.keys())])
for line, prev_vals_dict in list(prev_values.items()):
line._cache.update(prev_vals_dict)
line.update(prev_vals_dict)

0 comments on commit c7fa110

Please sign in to comment.