summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/account/models/chart_template.py4
-rw-r--r--addons/account/wizard/wizard_tax_adjustments.py54
-rw-r--r--addons/account/wizard/wizard_tax_adjustments_view.xml15
-rw-r--r--addons/l10n_be/data/account_tax_template_data.xml70
-rw-r--r--doc/webservices/localization.rst1
5 files changed, 28 insertions, 116 deletions
diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py
index 09d85002816..bcd8d8c8d7b 100644
--- a/addons/account/models/chart_template.py
+++ b/addons/account/models/chart_template.py
@@ -798,8 +798,8 @@ class AccountTaxTemplate(models.Model):
chart_template_id = fields.Many2one('account.chart.template', string='Chart Template', required=True)
name = fields.Char(string='Tax Name', required=True)
- type_tax_use = fields.Selection([('sale', 'Sales'), ('purchase', 'Purchases'), ('none', 'None'), ('adjustment', 'Adjustment')], string='Tax Scope', required=True, default="sale",
- help="Determines where the tax is selectable. Note : 'None' means a tax can't be used by itself, however it can still be used in a group. 'adjustment' is used to perform tax adjustment.")
+ type_tax_use = fields.Selection([('sale', 'Sales'), ('purchase', 'Purchases'), ('none', 'None')], string='Tax Scope', required=True, default="sale",
+ help="Determines where the tax is selectable. Note : 'None' means a tax can't be used by itself, however it can still be used in a group.")
amount_type = fields.Selection(default='percent', string="Tax Computation", required=True,
selection=[('group', 'Group of Taxes'), ('fixed', 'Fixed'), ('percent', 'Percentage of Price'), ('division', 'Percentage of Price Tax Included')])
active = fields.Boolean(default=True, help="Set active to false to hide the tax without removing it.")
diff --git a/addons/account/wizard/wizard_tax_adjustments.py b/addons/account/wizard/wizard_tax_adjustments.py
index 4dd21030802..736396531fb 100644
--- a/addons/account/wizard/wizard_tax_adjustments.py
+++ b/addons/account/wizard/wizard_tax_adjustments.py
@@ -18,28 +18,27 @@ class TaxAdjustments(models.TransientModel):
debit_account_id = fields.Many2one('account.account', string='Debit account', required=True, domain=[('deprecated', '=', False)])
credit_account_id = fields.Many2one('account.account', string='Credit account', required=True, domain=[('deprecated', '=', False)])
amount = fields.Monetary(currency_field='company_currency_id', required=True)
- adjustment_type = fields.Selection([('debit', 'Applied on debit journal item'), ('credit', 'Applied on credit journal item')], string="Adjustment Type", store=False, required=True)
- company_currency_id = fields.Many2one('res.currency', readonly=True, default=lambda self: self.env.company.currency_id)
- tax_id = fields.Many2one('account.tax', string='Adjustment Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'adjustment')], required=True)
+ adjustment_type = fields.Selection([('debit', 'Applied on debit journal item'), ('credit', 'Applied on credit journal item')], string="Adjustment Type", required=True)
+ tax_report_line_id = fields.Many2one(string="Report Line", comodel_name='account.tax.report.line', required=True, help="The report line to make an adjustment for.")
+ company_currency_id = fields.Many2one('res.currency', readonly=True, default=lambda x: x.env.company_id.currency_id)
+ country_id = fields.Many2one(string="Country", comodel_name='res.country', readonly=True, default=lambda x: x.env.company_id.country_id)
- @api.multi
- def _create_move(self):
- adjustment_type = self.env.context.get('adjustment_type', (self.amount > 0.0 and 'debit' or 'credit'))
+ def create_move(self):
move_line_vals = []
- is_debit = adjustment_type == 'debit'
- for tax_vals in self.tax_id.compute_all(abs(self.amount))['taxes']:
- repartition_line = self.env['account.tax.repartition.line'].browse(tax_vals['tax_repartition_line_id'])
- # Vals for the amls corresponding to the tax
- move_line_vals.append((0, 0, {
- 'name': self.reason,
- 'debit': is_debit and abs(self.amount) or 0,
- 'credit': not is_debit and abs(self.amount) or 0,
- 'account_id': is_debit and self.debit_account_id.id or self.credit_account_id.id,
- 'tax_repartition_line_id': repartition_line.id,
- 'tax_base_amount': tax_vals['base'],
- 'tag_ids': [(6, False, repartition_line.tag_ids.ids)],
- }))
+ is_debit = self.adjustment_type == 'debit'
+ sign_multiplier = (self.amount<0 and -1 or 1) * (self.adjustment_type == 'credit' and -1 or 1)
+ filter_lambda = (sign_multiplier < 0) and (lambda x: x.tax_negate) or (lambda x: not x.tax_negate)
+ adjustment_tag = self.tax_report_line_id.tag_ids.filtered(filter_lambda)
+
+ # Vals for the amls corresponding to the ajustment tag
+ move_line_vals.append((0, 0, {
+ 'name': self.reason,
+ 'debit': is_debit and abs(self.amount) or 0,
+ 'credit': not is_debit and abs(self.amount) or 0,
+ 'account_id': is_debit and self.debit_account_id.id or self.credit_account_id.id,
+ 'tag_ids': [(6, False, [adjustment_tag.id])],
+ }))
# Vals for the counterpart line
move_line_vals.append((0, 0, {
@@ -47,7 +46,6 @@ class TaxAdjustments(models.TransientModel):
'debit': not is_debit and abs(self.amount) or 0,
'credit': is_debit and abs(self.amount) or 0,
'account_id': is_debit and self.credit_account_id.id or self.debit_account_id.id,
- 'tax_repartition_line_id': False,
}))
# Create the move
@@ -59,22 +57,10 @@ class TaxAdjustments(models.TransientModel):
}
move = self.env['account.move'].create(vals)
move.post()
- return move.id
- @api.multi
- def create_move_debit(self):
- return self.with_context(adjustment_type='debit').create_move()
-
- @api.multi
- def create_move_credit(self):
- return self.with_context(adjustment_type='credit').create_move()
-
- def create_move(self):
- #create the adjustment move
- move_id = self._create_move()
- #return an action showing the created move
+ # Return an action opening the created move
action = self.env.ref(self.env.context.get('action', 'account.action_move_line_form'))
result = action.read()[0]
result['views'] = [(False, 'form')]
- result['res_id'] = move_id
+ result['res_id'] = move.id
return result
diff --git a/addons/account/wizard/wizard_tax_adjustments_view.xml b/addons/account/wizard/wizard_tax_adjustments_view.xml
index 3295a28f373..8c0bf8f826e 100644
--- a/addons/account/wizard/wizard_tax_adjustments_view.xml
+++ b/addons/account/wizard/wizard_tax_adjustments_view.xml
@@ -10,12 +10,15 @@
<field name="reason" class="oe_inline" placeholder="Reason..."/>
</h1>
<group>
+ <field name="country_id" invisible="1"/>
+ <field name="tax_report_line_id" widget="selection" domain="[('tag_name', '!=', None), ('country_id', '=', country_id)]"/>
+ </group>
+ <group>
<group>
<field name="amount"/>
- <field name="adjustment_type"/>
</group>
<group>
- <field name="tax_id" widget="selection"/>
+ <field name="adjustment_type"/>
</group>
<group string="Accounts">
<field name="debit_account_id" options="{'no_create': True}"/>
@@ -27,14 +30,8 @@
</group>
</group>
<footer>
- <div attrs="{'invisible': [('adjustment_type', '=', 'credit')]}">
- <button name="create_move_debit" string="Create and post move" type="object" default_focus="1" class="oe_highlight"/>
- <button string="Cancel" class="btn btn-secondary" special="cancel" />
- </div>
- <div attrs="{'invisible': [('adjustment_type', '!=', 'credit')]}">
- <button name="create_move_credit" string="Create and post move" type="object" default_focus="1" class="oe_highlight"/>
+ <button name="create_move" string="Create and post move" type="object" default_focus="1" class="oe_highlight"/>
<button string="Cancel" class="btn btn-secondary" special="cancel" />
- </div>
</footer>
</form>
</field>
diff --git a/addons/l10n_be/data/account_tax_template_data.xml b/addons/l10n_be/data/account_tax_template_data.xml
index 70c71a446b2..45268c90b81 100644
--- a/addons/l10n_be/data/account_tax_template_data.xml
+++ b/addons/l10n_be/data/account_tax_template_data.xml
@@ -3260,74 +3260,4 @@
]"/>
</record>
- <record id="attn_VAT-IN-V61" model="account.tax.template">
- <field name="sequence">9000</field>
- <field name="description">Régularisation en faveur de l'état</field>
- <field name="name">Régularisation en faveur de l'état</field>
- <field name="price_include" eval="0"/>
- <field name="amount">0.0</field>
- <field name="amount_type">fixed</field>
- <field name="type_tax_use">adjustment</field>
- <field name="chart_template_id" ref="l10nbe_chart_template"/>
- <field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'base',
- }),
-
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'tax',
- 'plus_report_line_ids': [ref('tax_report_line_61')],
- }),
- ]"/>
- <field name="refund_repartition_line_ids" eval="[(5, 0, 0),
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'base',
- }),
-
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'tax',
- 'minus_report_line_ids': [ref('tax_report_line_61')],
- }),
- ]"/>
- </record>
-
- <record id="attn_VAT-IN-V62" model="account.tax.template">
- <field name="sequence">9010</field>
- <field name="description">Régularisation en faveur du déclarant</field>
- <field name="name">Régularisation en faveur du déclarant</field>
- <field name="price_include" eval="0"/>
- <field name="amount">0.0</field>
- <field name="amount_type">fixed</field>
- <field name="type_tax_use">adjustment</field>
- <field name="chart_template_id" ref="l10nbe_chart_template"/>
- <field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'base',
- }),
-
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'tax',
- 'plus_report_line_ids': [ref('tax_report_line_62')],
- }),
- ]"/>
- <field name="refund_repartition_line_ids" eval="[(5, 0, 0),
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'base',
- }),
-
- (0,0, {
- 'factor_percent': 100,
- 'repartition_type': 'tax',
- 'minus_report_line_ids': [ref('tax_report_line_62')],
- }),
- ]"/>
- </record>
-
</odoo>
diff --git a/doc/webservices/localization.rst b/doc/webservices/localization.rst
index 238e49788e6..38cb6c0947c 100644
--- a/doc/webservices/localization.rst
+++ b/doc/webservices/localization.rst
@@ -213,7 +213,6 @@ The only difference being that you must use the ``account.tax.template`` model.
<!-- [Optional] Define the tax's type.
'sale', 'purchase' or 'none' are the allowed values. 'sale' is the default value.
- 'adjustment' is also available to do some tax adjustments.
Note: 'none' means a tax can't be used by itself, however it can still be used in a group. -->
<field name="type_tax_use">...</field>