[Tryton] Adding a default account(ing) category to product (templates)

(0 comments)

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.

Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

Recent Posts

Archive

2021
2020
2019
2018
2014
2012
2011
2010
2009
2008
2007

Categories

Authors

Feeds

RSS / Atom