Reviewers: ,
Please review this at http://codereview.tryton.org/819002/ Affected files: work.py Index: work.py =================================================================== --- a/work.py +++ b/work.py @@ -88,8 +88,10 @@ def get_invoice_method(self, name): if self.type == 'project': return self.project_invoice_method + elif self.parent: + return self.parent.invoice_method else: - return self.parent.invoice_method + return None @staticmethod def default_invoiced_hours(): @@ -207,8 +209,9 @@ for work in works: method2works.setdefault(work.invoice_method, []).append(work) for method, m_works in method2works.iteritems(): - method = getattr(cls, '_get_%s_%s' % (name, method)) - values.update(method(m_works)) + if method: + method = getattr(cls, '_get_%s_%s' % (name, method)) + values.update(method(m_works)) default = getattr(cls, 'default_%s' % name)() return cls.sum_tree(works, lambda w: values.get(w.id, default))
