Ensure that move.origin is a Model before getting its rec_name.

This commit is contained in:
Albert Cervera i Areny 2020-10-28 11:53:38 +01:00
parent d3fbb13146
commit f4c55dbae7
1 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@
# copyright notices and license terms.
from itertools import chain
from trytond.model import ModelView, fields, dualmethod
from trytond.model import Model, ModelView, fields, dualmethod
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Bool
from trytond.i18n import gettext
@ -128,7 +128,10 @@ class Move(metaclass=PoolMeta):
for move in moves:
origin = ''
origin_model = ''
if move.origin:
# Ensure that "move.origin" is an instance because if a reference
# field is assigned a model name but not an id "move.origin" will
# return an str
if move.origin and isinstance(move.origin, Model):
origin = move.origin.rec_name
origin_model = move.origin.__names__().get('model')
if move.period.type == 'adjustment':