Skip to content

Commit

Permalink
[FIX] l10n_fr_account_vat_return: filter on VAT taxes for France
Browse files Browse the repository at this point in the history
This commit adapts the code to the scenario where you have VAT taxes for
other countries (EU B2C over 10k€, Polynésie française, ...).
It "backports" the field country_id on account.tax which is introduced in
the account module in odoo v15.
  • Loading branch information
alexis-via committed Feb 3, 2025
1 parent dcfbc8d commit e61e876
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion l10n_fr_account_vat_return/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "France VAT Return",
"version": "14.0.7.1.0",
"version": "14.0.7.2.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "VAT return for France: CA3, 3310-A, 3519",
Expand Down
18 changes: 18 additions & 0 deletions l10n_fr_account_vat_return/migrations/14.0.7.2.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"UPDATE account_tax SET country_id=res_partner.country_id "
"FROM res_partner, res_company "
"WHERE account_tax.company_id=res_company.id AND "
"res_company.partner_id=res_partner.id AND "
"res_partner.country_id IS NOT NULL AND "
"account_tax.country_id IS NULL",
)
9 changes: 9 additions & 0 deletions l10n_fr_account_vat_return/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class AccountTax(models.Model):
fr_vat_autoliquidation = fields.Boolean(
compute="_compute_fr_vat_autoliquidation", store=True, string="Autoliquidation"
)
# The country_id field on account.tax is added in Odoo v15
# We just "backport" this field here, to be able to support scenarios
# where you have VAT taxes for other countries
country_id = fields.Many2one(
"res.country",
string="Country",
required=True,
help="The country for which this tax is applicable.",
)

@api.depends(
"type_tax_use",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def _prepare_speedy(self):
("amount_type", "=", "percent"),
("amount", ">", 0),
("unece_type_code", "=", "VAT"),
("country_id", "=", self.env.ref("base.fr").id),
]
sale_regular_vat_tax_domain = vat_tax_domain + [
("fr_vat_autoliquidation", "=", False),
Expand Down
11 changes: 4 additions & 7 deletions l10n_fr_account_vat_return/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -419,9 +418,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
6 changes: 5 additions & 1 deletion l10n_fr_account_vat_return/views/account_tax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<field name="inherit_id" ref="account.view_tax_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='tax_scope']/.." position="inside">
<field name="fr_vat_autoliquidation" />
<field name="fr_vat_autoliquidation" />
</xpath>
<xpath expr="//field[@name='description']/.." position="inside">
<field name="country_id" />
</xpath>
</field>
</record>
Expand All @@ -21,6 +24,7 @@
<field name="inherit_id" ref="account.view_tax_tree" />
<field name="arch" type="xml">
<field name="company_id" position="before">
<field name="country_id" optional="hide" />
<field name="fr_vat_autoliquidation" optional="hide" />
</field>
</field>
Expand Down

0 comments on commit e61e876

Please sign in to comment.