Add default customer and supplier tax rule
issue8542 review267741002
This commit is contained in:
1 parent
70671164bb
commit
74ce1bacd5
5 files changed
+63
-6
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add default customer and supplier tax rule
|
||||
* Update sequence name in renew fiscal year
|
||||
* Make tax required on tax line
|
||||
* Use today as default date when inside the period
|
||||
|
||||
+5
-4
@@ -4,7 +4,7 @@
|
||||
from trytond.pool import Pool
|
||||
from .fiscalyear import *
|
||||
from .account import *
|
||||
from .configuration import *
|
||||
from . import configuration
|
||||
from .period import *
|
||||
from .journal import *
|
||||
from .move import *
|
||||
@@ -39,8 +39,9 @@ def register():
|
||||
UpdateChartSucceed,
|
||||
AgedBalanceContext,
|
||||
AgedBalance,
|
||||
Configuration,
|
||||
ConfigurationDefaultAccount,
|
||||
configuration.Configuration,
|
||||
configuration.ConfigurationDefaultAccount,
|
||||
configuration.DefaultTaxRule,
|
||||
Period,
|
||||
Journal,
|
||||
JournalSequence,
|
||||
@@ -48,7 +49,7 @@ def register():
|
||||
JournalPeriod,
|
||||
Move,
|
||||
Reconciliation,
|
||||
ConfigurationTaxRounding,
|
||||
configuration.ConfigurationTaxRounding,
|
||||
Line,
|
||||
WriteOff,
|
||||
OpenJournalAsk,
|
||||
|
||||
+35
-2
@@ -7,8 +7,6 @@ from trytond.pyson import Eval
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
|
||||
__all__ = ['Configuration', 'ConfigurationDefaultAccount',
|
||||
'ConfigurationTaxRounding']
|
||||
tax_roundings = [
|
||||
('document', 'Per Document'),
|
||||
('line', 'Per Line'),
|
||||
@@ -33,6 +31,20 @@ class Configuration(
|
||||
('party_required', '=', True),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
]))
|
||||
default_customer_tax_rule = fields.MultiValue(fields.Many2One(
|
||||
'account.tax.rule', "Default Customer Tax Rule",
|
||||
domain=[
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
('kind', 'in', ['sale', 'both']),
|
||||
]),
|
||||
help="Default customer tax rule for new parties.")
|
||||
default_supplier_tax_rule = fields.MultiValue(fields.Many2One(
|
||||
'account.tax.rule', "Default Supplier Tax Rule",
|
||||
domain=[
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
('kind', 'in', ['purchase', 'both']),
|
||||
]),
|
||||
help="Default supplier tax rule for new parties.")
|
||||
tax_rounding = fields.MultiValue(fields.Selection(
|
||||
tax_roundings, "Tax Rounding"))
|
||||
|
||||
@@ -41,6 +53,8 @@ class Configuration(
|
||||
pool = Pool()
|
||||
if field in {'default_account_receivable', 'default_account_payable'}:
|
||||
return pool.get('account.configuration.default_account')
|
||||
if field in {'default_customer_tax_rule', 'default_supplier_tax_rule'}:
|
||||
return pool.get('account.configuration.default_tax_rule')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
@@ -69,6 +83,25 @@ class ConfigurationDefaultAccount(ModelSQL, CompanyValueMixin):
|
||||
depends=['company'])
|
||||
|
||||
|
||||
class DefaultTaxRule(ModelSQL, CompanyValueMixin):
|
||||
"Account Configuration Default Tax Rule"
|
||||
__name__ = 'account.configuration.default_tax_rule'
|
||||
default_customer_tax_rule = fields.Many2One(
|
||||
'account.tax.rule', "Default Customer Tax Rule",
|
||||
domain=[
|
||||
('company', '=', Eval('company', -1)),
|
||||
('kind', 'in', ['sale', 'both']),
|
||||
],
|
||||
depends=['company'])
|
||||
default_supplier_tax_rule = fields.Many2One(
|
||||
'account.tax.rule', "Default Supplier Tax Rule",
|
||||
domain=[
|
||||
('company', '=', Eval('company', -1)),
|
||||
('kind', 'in', ['purchase', 'both']),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
|
||||
class ConfigurationTaxRounding(ModelSQL, CompanyValueMixin):
|
||||
'Account Configuration Tax Rounding'
|
||||
__name__ = 'account.configuration.tax_rounding'
|
||||
|
||||
@@ -93,6 +93,24 @@ class Party(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||
return pool.get('party.party.account')
|
||||
return super(Party, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
def _default_tax_rule(cls, type_, **pattern):
|
||||
pool = Pool()
|
||||
Configuration = pool.get('account.configuration')
|
||||
config = Configuration(1)
|
||||
assert type_ in {'customer', 'supplier'}
|
||||
tax_rule = config.get_multivalue(
|
||||
'default_%s_tax_rule' % type_, **pattern)
|
||||
return tax_rule.id if tax_rule else None
|
||||
|
||||
@classmethod
|
||||
def default_customer_tax_rule(cls, **pattern):
|
||||
return cls._default_tax_rule('customer', **pattern)
|
||||
|
||||
@classmethod
|
||||
def default_supplier_tax_rule(cls, **pattern):
|
||||
return cls._default_tax_rule('supplier', **pattern)
|
||||
|
||||
@classmethod
|
||||
def get_currency_digits(cls, parties, name):
|
||||
pool = Pool()
|
||||
|
||||
@@ -8,6 +8,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="default_account_payable"/>
|
||||
<field name="default_account_payable"/>
|
||||
<separator id="invoice" string="Invoice" colspan="4"/>
|
||||
<label name="default_customer_tax_rule"/>
|
||||
<field name="default_customer_tax_rule"/>
|
||||
<label name="default_supplier_tax_rule"/>
|
||||
<field name="default_supplier_tax_rule"/>
|
||||
<label name="tax_rounding"/>
|
||||
<field name="tax_rounding"/>
|
||||
</form>
|
||||
Reference in new issue
Block a user