Files
tryton/modules/account_asset/purchase.py
T

25 lines
1.1 KiB
Python
Raw Normal View History

# This file is part of Tryton. The COPYRIGHT file at the top level of this
# repository contains the full copyright notices and license terms.
2018-12-29 14:20:28 +01:00
from trytond.i18n import gettext
from trytond.modules.account_product.exceptions import AccountError
2021-12-11 17:58:41 +01:00
from trytond.pool import PoolMeta
2018-12-29 14:20:28 +01:00
2020-03-01 12:33:51 +01:00
class Line(metaclass=PoolMeta):
__name__ = 'purchase.line'
2016-03-20 22:58:04 +01:00
def get_invoice_line(self):
2020-03-01 12:33:51 +01:00
invoice_lines = super().get_invoice_line()
if (self.product
and self.product.type == 'assets'
and self.product.depreciable):
for invoice_line in invoice_lines:
if invoice_line.product == self.product:
invoice_line.account = self.product.account_asset_used
if not invoice_line.account:
2018-12-29 14:20:28 +01:00
raise AccountError(
gettext('account_asset'
'.msg_purchase_product_missing_account_asset',
purchase=self.purchase.rec_name,
product=self.product.rec_name))
return invoice_lines