Test if origin id is greater or equals to 0 before accessing the target record

Closes #13498
This commit is contained in:
Cédric Krier committed 2024-09-09 12:46:16 +02:00
1 parent 04f378c503
commit 6e798f98fc
10 files changed
+13 -10

No files matched your search

+1 -1
View File
@@ -2567,7 +2567,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
+3 -2
View File
@@ -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
+1 -1
View File
@@ -149,7 +149,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
+1 -1
View File
@@ -225,7 +225,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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -217,7 +217,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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+2 -1
View File
@@ -632,7 +632,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
+1
View File
@@ -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