Created
March 31, 2017 23:54
-
-
Save josemoralesp/aa0de070e7c2e0949d35373c9a8d2b4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
magia = defaultdict(self.env['account.tax']) | |
for i in self.tax_line_ids: | |
magia[i.tax_group_id.name] += i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@josemoralesp what about use also dict.fromkeys()?
UPDATE
Better to use
defaultdict
instead ofdict.fromkeys()
: the first one if a key does not exists wont be turn a KeyError that the second one does