base/models/entity: return the current entity if no parent of the right level is found
refs #4015
This commit is contained in:
parent
9a4e653735
commit
a0e0b69071
|
@ -109,10 +109,13 @@ class Entity(models.Model):
|
|||
get_description.short_description = _(u'Description')
|
||||
|
||||
def level1_parent(self):
|
||||
'''
|
||||
Show parent of level between 1 or 3 if found, self return the current entity.
|
||||
'''
|
||||
parents = self.parents()
|
||||
if len(parents) > 1:
|
||||
return parents[1]
|
||||
return None
|
||||
if len(parents) > 3:
|
||||
return parents[3]
|
||||
return self
|
||||
|
||||
class AccountingCode(models.Model):
|
||||
class Meta:
|
||||
|
|
Reference in New Issue