Test if origin id is greater or equals to 0 before accessing the target record
Closes #13498 (grafted from 497490225779fc8dc210c9cee997cd5ce4b4381e) --HG-- branch : 7.0
This commit is contained in:
@@ -2440,7 +2440,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
||||
|
||||
@property
|
||||
def origin_name(self):
|
||||
if isinstance(self.origin, self.__class__):
|
||||
if isinstance(self.origin, self.__class__) and self.origin.id >= 0:
|
||||
return self.origin.invoice.rec_name
|
||||
return self.origin.rec_name if self.origin else None
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class MoveSale(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
SaleLineComponent = pool.get('sale.line.component')
|
||||
name = super().origin_name
|
||||
if isinstance(self.origin, SaleLineComponent):
|
||||
if isinstance(self.origin, SaleLineComponent) and self.origin.id >= 0:
|
||||
name = self.origin.line.sale.rec_name
|
||||
return name
|
||||
|
||||
@@ -227,7 +227,8 @@ class MovePurchase(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
PurchaseLineComponent = pool.get('purchase.line.component')
|
||||
name = super().origin_name
|
||||
if isinstance(self.origin, PurchaseLineComponent):
|
||||
if (isinstance(self.origin, PurchaseLineComponent)
|
||||
and self.origin.id >= 0):
|
||||
name = self.origin.line.purchase.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
name = super(InvoiceLine, self).origin_name
|
||||
if isinstance(self.origin, PurchaseLine):
|
||||
if isinstance(self.origin, PurchaseLine) and self.origin.id >= 0:
|
||||
name = self.origin.purchase.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ class Move(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
name = super(Move, self).origin_name
|
||||
if isinstance(self.origin, PurchaseLine):
|
||||
if isinstance(self.origin, PurchaseLine) and self.origin.id >= 0:
|
||||
name = self.origin.purchase.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class Line(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
SaleLine = pool.get('sale.line')
|
||||
name = super().origin_name
|
||||
if isinstance(self.origin, SaleLine):
|
||||
if isinstance(self.origin, SaleLine) and self.origin.id >= 0:
|
||||
name = self.origin.sale.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class Move(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
SaleLine = pool.get('sale.line')
|
||||
name = super(Move, self).origin_name
|
||||
if isinstance(self.origin, SaleLine):
|
||||
if isinstance(self.origin, SaleLine) and self.origin.id >= 0:
|
||||
name = self.origin.sale.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Condition = pool.get('sale.advance_payment.condition')
|
||||
name = super().origin_name
|
||||
if isinstance(self.origin, Condition):
|
||||
if isinstance(self.origin, Condition) and self.origin.id >= 0:
|
||||
name = self.origin.sale.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
SubscriptionLine = pool.get('sale.subscription.line')
|
||||
name = super(InvoiceLine, self).origin_name
|
||||
if isinstance(self.origin, SubscriptionLine):
|
||||
if isinstance(self.origin, SubscriptionLine) and self.origin.id >= 0:
|
||||
name = self.origin.subscription.rec_name
|
||||
return name
|
||||
|
||||
|
||||
@@ -587,7 +587,8 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
|
||||
@property
|
||||
def origin_name(self):
|
||||
return self.origin.rec_name if self.origin else None
|
||||
if self.origin and self.origin.id >= 0:
|
||||
return self.origin.rec_name
|
||||
|
||||
@classmethod
|
||||
@without_check_access
|
||||
|
||||
@@ -12,6 +12,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
Move = pool.get('stock.move')
|
||||
name = super(InvoiceLine, self).origin_name
|
||||
if (isinstance(self.origin, Move)
|
||||
and self.origin.id >= 0
|
||||
and self.origin.shipment):
|
||||
name = self.origin.shipment.rec_name
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user