forked from NaN-tic/trytond-sale_invoice_line_standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.py
23 lines (19 loc) · 895 Bytes
/
invoice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This file is part of the sale_invoice_line_standalone module for Tryton.
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.i18n import gettext
from trytond.exceptions import UserError
__all__ = ['InvoiceLine']
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
@classmethod
def delete(cls, lines):
SaleLine = Pool().get('sale.line')
if (not Transaction().context.get('allow_remove_sale_invoice_lines')
and any(l for l in lines
if isinstance(l.origin, SaleLine) and l.type == 'line')):
raise UserError(
gettext('sale_invoice_line_standalone.delete_sale_invoice_line'))
super(InvoiceLine, cls).delete(lines)