Subject: changeset in modules/timesheet:5.0 Test if origin is ModelStorage 
instance before calling rec_name
From: Cédric Krier <[email protected]>

changeset 01c72a4f7cb5 in modules/timesheet:5.0
details: https://hg.tryton.org/modules/timesheet?cmd=changeset;node=01c72a4f7cb5
description:
        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
        (grafted from 467f0f8755f00983e3846eebf57a8c7e735fe90b)
diffstat:

 work.py |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r bb134bc3b91a -r 01c72a4f7cb5 work.py
--- a/work.py   Sat Jan 26 01:12:04 2019 +0100
+++ b/work.py   Tue Jan 15 00:03:52 2019 +0100
@@ -6,7 +6,8 @@
 from sql import Literal
 from sql.aggregate import Sum
 
-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
@@ -173,7 +174,7 @@
         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

Reply via email to