mirror of
https://github.com/NaN-tic/trytond-account_invoice_taxes_required.git
synced 2023-12-14 04:32:55 +01:00
parent
4d8eefe75a
commit
3063672059
2 changed files with 13 additions and 5 deletions
16
invoice.py
16
invoice.py
|
@ -1,12 +1,10 @@
|
|||
# This file is part account_invoice_taxes_required module for 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
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
__all__ = ['Invoice', 'InvoiceLine']
|
||||
from trytond.model import fields
|
||||
|
||||
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
|
@ -15,6 +13,7 @@ class Invoice(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def validate(cls, invoices):
|
||||
InvoiceLine = Pool().get('account.invoice.line')
|
||||
|
||||
super(Invoice, cls).validate(invoices)
|
||||
for invoice in invoices:
|
||||
InvoiceLine.validate(invoice.lines)
|
||||
|
@ -22,6 +21,11 @@ class Invoice(metaclass=PoolMeta):
|
|||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
taxes_required = fields.Boolean('Taxes Required', readonly=True)
|
||||
|
||||
@classmethod
|
||||
def default_taxes_required(cls):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def validate(cls, lines):
|
||||
|
@ -30,8 +34,10 @@ class InvoiceLine(metaclass=PoolMeta):
|
|||
line.check_tax_required()
|
||||
|
||||
def check_tax_required(self):
|
||||
if not self.invoice or self.invoice.state in ('draft', 'cancelled') or \
|
||||
self.type != 'line':
|
||||
if (not self.invoice
|
||||
or not self.taxes_required
|
||||
or self.invoice.state in ('draft', 'cancelled')
|
||||
or self.type != 'line'):
|
||||
return
|
||||
if not self.taxes:
|
||||
raise UserError(gettext(
|
||||
|
|
|
@ -102,6 +102,8 @@ Create invoice Without Taxes::
|
|||
>>> line.description = 'Test'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(20)
|
||||
>>> line.taxes_required == True
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('220.00')
|
||||
>>> invoice.tax_amount
|
||||
|
|
Loading…
Reference in a new issue