To optimize workflow (and avoid mistakes) I wanted to set a default account(ing) category so that tax,.. is set by default. Took a little bit of experimenting, but I got it:
class Template(metaclass=PoolMeta):
__name__ = 'product.template'
@classmethod
def default_account_category(cls):
try:
return Pool().get('product.category').search([('name', '=', 'MWSt'), ('accounting', '=', True)])[0].id
except:
# FIXME: should I log an error here for not finding a hardcoded accounting category?
return None
I could have of course also returned the number for the tax rate I am usign as well, but I found this to be (a lot) more flexible should I ever want to make it user/admin configurable and not hardcode it. But for now this is more than fine.
Share on Twitter Share on Facebook
Comments
There are currently no comments
New Comment