Add sale, purchase or other kind on Tax Rule and Tax Group

review587003
This commit is contained in:
Cédric Krier committed 2012-12-05 13:00:13 +01:00
1 parent 3b88d537bb
commit 925c4fadd3
4 files changed
+75 -3

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Add sale, purchase or other kind on Tax Rule and Tax Group
Version 2.6.0 - 2012-10-22
* Bug fixes (see mercurial logs for details)
* Rename:
+8 -2
View File
@@ -32,13 +32,19 @@ class Party:
}))
customer_tax_rule = fields.Property(fields.Many2One('account.tax.rule',
'Customer Tax Rule',
domain=[('company', '=', Eval('context', {}).get('company', 0))],
domain=[
('company', '=', Eval('context', {}).get('company', 0)),
('kind', 'in', ['sale', 'both']),
],
states={
'invisible': ~Eval('context', {}).get('company'),
}, help='Apply this rule on taxes when party is customer.'))
supplier_tax_rule = fields.Property(fields.Many2One('account.tax.rule',
'Supplier Tax Rule',
domain=[('company', '=', Eval('context', {}).get('company', 0))],
domain=[
('company', '=', Eval('context', {}).get('company', 0)),
('kind', 'in', ['purchase', 'both']),
],
states={
'invisible': ~Eval('context', {}).get('company'),
}, help='Apply this rule on taxes when party is supplier.'))
+56 -1
View File
@@ -16,12 +16,19 @@ __all__ = ['TaxGroup', 'TaxCodeTemplate', 'TaxCode',
'AccountTemplateTaxTemplate', 'AccountTemplate2', 'AccountTax', 'Account2']
__metaclass__ = PoolMeta
KINDS = [
('sale', 'Sale'),
('purchase', 'Purchase'),
('both', 'Both'),
]
class TaxGroup(ModelSQL, ModelView):
'Tax Group'
__name__ = 'account.tax.group'
name = fields.Char('Name', size=None, required=True, translate=True)
code = fields.Char('Code', size=None, required=True)
kind = fields.Selection(KINDS, 'Kind', required=True)
@classmethod
def __register__(cls, module_name):
@@ -32,6 +39,10 @@ class TaxGroup(ModelSQL, ModelView):
# Migration from 1.4 drop code_uniq constraint
table.drop_constraint('code_uniq')
@staticmethod
def default_kind():
return 'both'
class TaxCodeTemplate(ModelSQL, ModelView):
'Tax Code Template'
@@ -867,10 +878,15 @@ class TaxRuleTemplate(ModelSQL, ModelView):
'Tax Rule Template'
__name__ = 'account.tax.rule.template'
name = fields.Char('Name', required=True, translate=True)
kind = fields.Selection(KINDS, 'Kind', required=True)
lines = fields.One2Many('account.tax.rule.line.template', 'rule', 'Lines')
account = fields.Many2One('account.account.template', 'Account Template',
domain=[('parent', '=', None)], required=True)
@staticmethod
def default_kind():
return 'both'
def _get_tax_rule_value(self, rule=None):
'''
Set values for tax rule creation.
@@ -878,6 +894,8 @@ class TaxRuleTemplate(ModelSQL, ModelView):
res = {}
if not rule or rule.name != self.name:
res['name'] = self.name
if not rule or rule.kind != self.kind:
res['kind'] = self.kind
if not rule or rule.template.id != self.id:
res['template'] = self.id
return res
@@ -929,6 +947,7 @@ class TaxRule(ModelSQL, ModelView):
'Tax Rule'
__name__ = 'account.tax.rule'
name = fields.Char('Name', required=True, translate=True)
kind = fields.Selection(KINDS, 'Kind', required=True)
company = fields.Many2One('company.company', 'Company', required=True,
select=True, domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
@@ -1003,7 +1022,16 @@ class TaxRuleLineTemplate(ModelSQL, ModelView):
origin_tax = fields.Many2One('account.tax.template', 'Original Tax',
domain=[
('account', '=', Eval('_parent_rule', {}).get('account', 0)),
('group', '=', Eval('group'))
('group', '=', Eval('group')),
['OR',
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
If(Eval('_parent_rule', {}).get('kind', 'both') ==
'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
],
help='If the original tax template is filled, the rule will be ' \
'applied only for this tax template.',
@@ -1012,6 +1040,15 @@ class TaxRuleLineTemplate(ModelSQL, ModelView):
domain=[
('account', '=', Eval('_parent_rule', {}).get('account', 0)),
('group', '=', Eval('group')),
['OR',
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
If(Eval('_parent_rule', {}).get('kind', 'both') ==
'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
],
depends=['group'])
sequence = fields.Integer('Sequence',
@@ -1094,6 +1131,15 @@ class TaxRuleLine(ModelSQL, ModelView):
domain=[
('company', '=', Eval('_parent_rule', {}).get('company')),
('group', '=', Eval('group')),
['OR',
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
If(Eval('_parent_rule', {}).get('kind', 'both') ==
'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
],
help='If the original tax is filled, the rule will be applied ' \
'only for this tax.',
@@ -1102,6 +1148,15 @@ class TaxRuleLine(ModelSQL, ModelView):
domain=[
('company', '=', Eval('_parent_rule', {}).get('company')),
('group', '=', Eval('group')),
['OR',
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
If(Eval('_parent_rule', {}).get('kind', 'both') ==
'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
],
depends=['group'])
sequence = fields.Integer('Sequence',
+9
View File
@@ -16,6 +16,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<label name="code"/>
<field name="code"/>
<label name="kind"/>
<field name="kind"/>
</form>
]]>
</field>
@@ -28,6 +30,7 @@ this repository contains the full copyright notices and license terms. -->
<tree string="Tax Groups">
<field name="name"/>
<field name="code"/>
<field name="kind"/>
</tree>
]]>
</field>
@@ -646,6 +649,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<label name="account"/>
<field name="account"/>
<label name="kind"/>
<field name="kind"/>
<field name="lines" colspan="4"/>
</form>
]]>
@@ -660,6 +665,7 @@ this repository contains the full copyright notices and license terms. -->
<tree string="Tax Rules">
<field name="account"/>
<field name="name"/>
<field name="kind"/>
</tree>
]]>
</field>
@@ -700,6 +706,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<label name="company"/>
<field name="company"/>
<label name="kind"/>
<field name="kind"/>
<field name="lines" colspan="4"
view_ids="account.tax_rule_line_view_tree_sequence"/>
</form>
@@ -714,6 +722,7 @@ this repository contains the full copyright notices and license terms. -->
<![CDATA[
<tree string="Tax Rules">
<field name="name"/>
<field name="kind"/>
</tree>
]]>
</field>