Files
tryton/modules/sale_subscription/invoice.py
T
Cédric Krier e18d53e99c Test if origin id is greater or equals to 0 before accessing the target record
Closes #13498
(grafted from 497490225779fc8dc210c9cee997cd5ce4b4381e)

--HG--
branch : 7.0
2024-09-09 12:46:16 +02:00

23 lines
761 B
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
@property
def origin_name(self):
pool = Pool()
SubscriptionLine = pool.get('sale.subscription.line')
name = super(InvoiceLine, self).origin_name
if isinstance(self.origin, SubscriptionLine) and self.origin.id >= 0:
name = self.origin.subscription.rec_name
return name
@classmethod
def _get_origin(cls):
models = super(InvoiceLine, cls)._get_origin()
models.append('sale.subscription.line')
return models