Test if origin is ModelStorage instance before calling rec_name

The origin could have a negative id and so the value is a string which is not
usable origin for record name.

issue7948
review52581002
This commit is contained in:
Cédric Krier committed 2019-01-15 00:03:52 +01:00
1 parent 33d1d6587c
commit ebe5835f44
1 file changed
+3 -2
+3 -2
View File
@@ -7,7 +7,8 @@ from sql import Literal
from sql.aggregate import Sum
from trytond.i18n import gettext
from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields, Unique
from trytond.model import (
ModelView, ModelSQL, ModelStorage, DeactivableMixin, fields, Unique)
from trytond.pyson import Not, Bool, Eval, If
from trytond.transaction import Transaction
from trytond.pool import Pool
@@ -172,7 +173,7 @@ class Work(DeactivableMixin, ModelSQL, ModelView):
return self.id
def get_rec_name(self, name):
if self.origin:
if isinstance(self.origin, ModelStorage):
return self.origin.rec_name
else:
return self.name