Skip to content

Commit

Permalink
[FIX] OCA#2456
Browse files Browse the repository at this point in the history
  • Loading branch information
fredzamoabg authored and Borruso committed May 25, 2023
1 parent bcbb4c9 commit 59d56f5
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 97 deletions.
1 change: 1 addition & 0 deletions l10n_it_intrastat_statement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Contributors
* Lara Baggio <lbaggio@linkgroup.it>
* Glauco Prina <gprina@linkgroup.it>
* Sergio Zanchetta <https://github.com/primes2h>
* Antonio Maria Vigliotti <antoniomaria.vigliotti@gmail.com>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_intrastat_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "ITA - Dichiarazione Intrastat",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"category": "Account",
"summary": "Dichiarazione Intrastat per l'Agenzia delle Dogane",
"author": "Openforce, Link IT srl, Agile Business Group, "
Expand Down
182 changes: 104 additions & 78 deletions l10n_it_intrastat_statement/i18n/l10n_it_intrastat_statement.pot

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ class IntrastatStatementSaleSection4(models.Model):
country_payment_id = fields.Many2one(
comodel_name="res.country", string="Payment Country"
)
cancellation = fields.Boolean(
string="Cancellation",
help="The Adjustment is intended for cancellation",
)

@api.model
def get_section_number(self):
Expand Down Expand Up @@ -435,12 +439,13 @@ def _export_line_checks(self, section_label, section_number):
raise ValidationError(
_("Missing progressive to adjust on 'Sales - Section 4'")
)
if not self.country_payment_id:
if not self.country_payment_id and not self.cancellation:
raise ValidationError(_("Missing payment country on 'Sales - Section 4'"))

@api.model
def _prepare_export_line(self):
self._export_line_checks(_("Sales"), self.get_section_number())
modifying = not self.cancellation

rcd = ""
# Codice della sezione doganale in cui è stato registrata la
Expand All @@ -455,26 +460,26 @@ def _prepare_export_line(self):
rcd += format_9(self.progressive_to_modify, 5)
# Codice dello Stato membro dell’acquirente
country_id = self.country_partner_id or self.partner_id.country_id
rcd += format_x(country_id.code, 2)
rcd += format_x(modifying and country_id.code, 2)
#  Codice IVA dell’acquirente
rcd += format_x(self.vat_code.replace(" ", ""), 12)
rcd += format_x(modifying and self.vat_code.replace(" ", ""), 12)
# Ammontare delle operazioni in euro
rcd += format_9(self.amount_euro, 13)
rcd += format_9(modifying and self.amount_euro, 13)
# Numero Fattura
rcd += format_x(self.invoice_number, 15)
rcd += format_x(modifying and self.invoice_number, 15)
# Data Fattura
invoice_date_ddmmyy = False
if self.invoice_date:
invoice_date_ddmmyy = self.invoice_date.strftime("%d%m%y")
rcd += format_x(invoice_date_ddmmyy, 6)
rcd += format_x(modifying and invoice_date_ddmmyy, 6)
# Codice del servizio
rcd += format_9(self.intrastat_code_id.name, 6)
rcd += format_9(modifying and self.intrastat_code_id.name, 6)
# Modalità di erogazione
rcd += format_x(self.supply_method, 1)
rcd += format_x(modifying and self.supply_method, 1)
# Modalità di incasso
rcd += format_x(self.payment_method, 1)
rcd += format_x(modifying and self.payment_method, 1)
# Codice del paese di pagamento
rcd += format_x(self.country_payment_id.code, 2)
rcd += format_x(modifying and self.country_payment_id.code, 2)

rcd += "\r\n"
return rcd
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None):

def _export_line_checks(self, section_label, section_number):
self.ensure_one()
if not self.vat_code:
if not self.vat_code and section_number != 4:
raise ValidationError(
_("Missing vat code for %s on '%s - Section %s'")
% (self.partner_id.display_name, section_label, section_number)
)
country_id = self.country_partner_id or self.partner_id.country_id
if country_id:
country_id.intrastat_validate()
else:
elif section_number == 4 and not self.cancellation:
raise ValidationError(
_("Missing State for Partner %s") % self.partner_id.display_name
)
Expand Down
3 changes: 2 additions & 1 deletion l10n_it_intrastat_statement/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>ITA - Dichiarazione Intrastat</title>
<style type="text/css">

Expand Down Expand Up @@ -459,6 +459,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>Lara Baggio &lt;<a class="reference external" href="mailto:lbaggio&#64;linkgroup.it">lbaggio&#64;linkgroup.it</a>&gt;</li>
<li>Glauco Prina &lt;<a class="reference external" href="mailto:gprina&#64;linkgroup.it">gprina&#64;linkgroup.it</a>&gt;</li>
<li>Sergio Zanchetta &lt;<a class="reference external" href="https://github.com/primes2h">https://github.com/primes2h</a>&gt;</li>
<li>Antonio Maria Vigliotti &lt;<a class="reference external" href="mailto:antoniomaria.vigliotti&#64;gmail.com">antoniomaria.vigliotti&#64;gmail.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
17 changes: 12 additions & 5 deletions l10n_it_intrastat_statement/views/intrastat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@
<field name="intrastat_code_id" string="Service Code" />
<field name="invoice_number" />
<field name="invoice_date" />
<field name="cancellation" />
<field name="amount_euro" sum="Total" />
</tree>
</field>
Expand All @@ -501,32 +502,38 @@
<field
name="country_partner_id"
string="Buyer State"
required="1"
attrs="{
'required':[('cancellation','=', False)],
'invisible':[('cancellation','=', True)]}"
/>
<field
name="vat_code"
string="Buyer VAT Code"
required="1"
attrs="{
'required':[('cancellation','=', False)],
'invisible':[('cancellation','=', True)]}"
/>
</group>
<group>
<field name="intrastat_custom_id" required="1" />
<field name="year_id" required="1" />
<field name="protocol" required="1" options="{'size': 6}" />
<field name="progressive_to_modify" required="1" />
<field name="cancellation" />
</group>
</group>
<newline />
<group>
<group>
<group attrs="{'invisible':[('cancellation','=', True)]}">
<field
name="intrastat_code_id"
string="Service Code"
required="1"
attrs="{
'required':[('cancellation','=', False)]}"
/>
<field name="amount_euro" />
</group>
<group>
<group attrs="{'invisible':[('cancellation','=', True)]}">
<field name="invoice_number" />
<field name="invoice_date" />
<field name="supply_method" />
Expand Down

0 comments on commit 59d56f5

Please sign in to comment.