first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,101 @@
# 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.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
class TaxTemplate(metaclass=PoolMeta):
__name__ = 'account.tax.template'
non_deductible = fields.Boolean(
"Non-Deductible",
help="Check to always include the tax amount as expense.")
@classmethod
def default_non_deductible(cls):
return False
def _get_tax_value(self, tax=None):
value = super()._get_tax_value(tax=tax)
if not tax or tax.non_deductible != self.non_deductible:
value['non_deductible'] = self.non_deductible
return value
class Tax(metaclass=PoolMeta):
__name__ = 'account.tax'
non_deductible = fields.Boolean("Non-Deductible")
@classmethod
def default_non_deductible(cls):
return False
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
@fields.depends(
'type', 'invoice', '_parent_invoice.type', methods=['_get_taxes'])
def on_change_with_amount(self):
amount = super().on_change_with_amount()
if self.type == 'line':
invoice_type = (
self.invoice.type if self.invoice else self.invoice_type)
if invoice_type == 'in':
with Transaction().set_context(
_non_deductible=True, _deductible_rate=1):
tax_amount = sum(
t.amount for t in self._get_taxes().values())
amount += tax_amount
return amount
@property
def taxable_lines(self):
context = Transaction().context
lines = super().taxable_lines
if (getattr(self, 'invoice', None)
and getattr(self.invoice, 'type', None)):
invoice_type = self.invoice.type
else:
invoice_type = getattr(self, 'invoice_type', None)
if invoice_type == 'in':
if context.get('_non_deductible'):
for line in lines:
taxes = line[0]
for tax in list(taxes):
if not tax.non_deductible:
taxes.remove(tax)
else:
for line in lines:
taxes = line[0]
for tax in list(taxes):
if tax.non_deductible:
taxes.remove(tax)
return lines
def _compute_taxes(self):
pool = Pool()
Currency = pool.get('currency.currency')
TaxLine = pool.get('account.tax.line')
tax_lines = super()._compute_taxes()
with Transaction().set_context(
_non_deductible=True, _deductible_rate=1):
taxes = self._get_taxes().values()
for tax in taxes:
for type_, amount in [('base', 'base'), ('tax', 'amount')]:
amount = getattr(tax, amount)
with Transaction().set_context(
date=self.invoice.currency_date):
amount = Currency.compute(
self.invoice.currency, amount,
self.invoice.company.currency)
tax_line = TaxLine()
tax_line.amount = amount
tax_line.type = type_
tax_line.tax = tax.tax
tax_lines.append(tax_line)
return tax_lines

View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="tax_template_view_form">
<field name="model">account.tax.template</field>
<field name="inherit" ref="account.tax_template_view_form"/>
<field name="name">tax_form</field>
</record>
<record model="ir.ui.view" id="tax_view_form">
<field name="model">account.tax</field>
<field name="inherit" ref="account.tax_view_form"/>
<field name="name">tax_form</field>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "No deduïble"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "No deduïble"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Marca per incloure sempre l'import de l'impost com a despesa."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "Nicht abzugsfähig"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "Nicht abzugsfähig"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Auswählen um den Steuerbetrag als Aufwand zu behandeln."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "No deducible"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "No deducible"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Marcar para incluir siempre los impuestos como gasto."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "Non-déductible"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "Non-déductible"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Cochez pour toujours inclure le montant de la taxe comme dépense."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "Non deducibile"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "Non deducibile"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Spunta per includere sempre l'importo dell'imposta come spesa."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "Niet aftrekbaar"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "Niet aftrekbaar"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Vink aan om altijd de belasting als onkosten op te nemen."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,16 @@
#
#, fuzzy
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr "Nedeductibil"
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr "Nedeductibil"
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr "Bifaţi pentru a include impozitul că cheltuiala."

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,15 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.tax,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "field:account.tax.template,non_deductible:"
msgid "Non-Deductible"
msgstr ""
msgctxt "help:account.tax.template,non_deductible:"
msgid "Check to always include the tax amount as expense."
msgstr ""

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,101 @@
===================================
Account Tax Non Deductible Scenario
===================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, create_tax, create_tax_code, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
>>> today = dt.date.today()
Activate modules::
>>> config = activate_modules(
... 'account_tax_non_deductible', create_company, create_chart)
>>> Invoice = Model.get('account.invoice')
>>> Party = Model.get('party.party')
>>> TaxCode = Model.get('account.tax.code')
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(today=today))
>>> fiscalyear.click('create_period')
>>> period_ids = [p.id for p in fiscalyear.periods]
Get accounts::
>>> accounts = get_accounts()
Create taxes::
>>> tax = create_tax(Decimal('.10'))
>>> tax.save()
>>> tax_non_deductible = create_tax(Decimal('.05'))
>>> tax_non_deductible.non_deductible = True
>>> tax_non_deductible.save()
>>> base_code = create_tax_code(tax, 'base', 'invoice')
>>> base_code.save()
>>> tax_code = create_tax_code(tax, 'tax', 'invoice')
>>> tax_code.save()
>>> base_non_deductible_code = create_tax_code(
... tax_non_deductible, 'base', 'invoice')
>>> base_non_deductible_code.save()
>>> tax_non_deductible_code = create_tax_code(
... tax_non_deductible, 'tax', 'invoice')
>>> tax_non_deductible_code.save()
Create party::
>>> party = Party(name='Party')
>>> party.save()
Create invoice::
>>> invoice = Invoice(type='in')
>>> invoice.party = party
>>> invoice.invoice_date = today
>>> line = invoice.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('100.0000')
>>> line.account = accounts['expense']
>>> line.taxes_deductible_rate = Decimal('.50')
>>> line.taxes.extend([tax, tax_non_deductible])
>>> line.amount
Decimal('110.00')
>>> invoice.untaxed_amount
Decimal('110.00')
>>> invoice.tax_amount
Decimal('5.00')
>>> invoice.total_amount
Decimal('115.00')
>>> invoice.click('post')
>>> invoice.state
'posted'
Check tax code::
>>> with config.set_context(periods=period_ids):
... base_code = TaxCode(base_code.id)
... tax_code = TaxCode(tax_code.id)
... base_non_deductible_code = TaxCode(base_non_deductible_code.id)
... tax_non_deductible_code = TaxCode(tax_non_deductible_code.id)
>>> base_code.amount
Decimal('50.00')
>>> tax_code.amount
Decimal('5.00')
>>> base_non_deductible_code.amount
Decimal('100.00')
>>> tax_non_deductible_code.amount
Decimal('5.00')

View File

@@ -0,0 +1,12 @@
# 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.tests.test_tryton import ModuleTestCase
class AccountTaxNonDeductibleTestCase(ModuleTestCase):
'Test Account Tax Non Deductible module'
module = 'account_tax_non_deductible'
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# 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.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)

View File

@@ -0,0 +1,14 @@
[tryton]
version=7.8.0
depends:
account
account_invoice
ir
xml:
account.xml
[register]
model:
account.TaxTemplate
account.Tax
account.InvoiceLine

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//group[@id='amount_rate']" position="inside">
<label name="non_deductible"/>
<field name="non_deductible" xexpand="0" width="25"/>
</xpath>
</data>