diff --git a/.copier-answers.yml b/.copier-answers.yml
index 622c021d2900..efb876a901ed 100644
--- a/.copier-answers.yml
+++ b/.copier-answers.yml
@@ -1,14 +1,17 @@
# Do NOT update manually; changes here will be overwritten by Copier
-_commit: v1.3.6
+_commit: v1.5.2
_src_path: gh:oca/oca-addons-repo-template
ci: GitHub
dependency_installation_mode: PIP
generate_requirements_txt: true
include_wkhtmltopdf: false
odoo_version: 14.0
+org_name: Odoo Community Association (OCA)
+org_slug: OCA
rebel_module_groups: []
repo_description: Addons concerning Odoo Italian Localization.
repo_name: l10n-italy
repo_slug: l10n-italy
+repo_website: https://github.com/OCA/l10n-italy
travis_apt_packages: []
travis_apt_sources: []
diff --git a/.eslintrc.yml b/.eslintrc.yml
index d4cc423ccda9..9429bc688aab 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -4,7 +4,7 @@ env:
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions:
- ecmaVersion: 2017
+ ecmaVersion: 2019
overrides:
- files:
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 80ab1a211789..a7a1390461d1 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -2,7 +2,12 @@ name: pre-commit
on:
pull_request:
+ branches:
+ - "14.0*"
push:
+ branches:
+ - "14.0"
+ - "14.0-ocabot-*"
jobs:
pre-commit:
@@ -10,11 +15,21 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
+ - name: Get python version
+ run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
+ - uses: actions/cache@v1
with:
- # The pylint-odoo version we use here does not support python 3.10
- # https://github.com/OCA/oca-addons-repo-template/issues/80
- # We also need to pin to an older version of python for older odoo versions
- # where we are not using black > 21. Older black versions won't work with
- # Python 3.9.8+, and we can't bump black without reformatting.
- python-version: "3.9.7"
- - uses: pre-commit/action@v2.0.0
+ path: ~/.cache/pre-commit
+ key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
+ - name: Install pre-commit
+ run: pip install pre-commit
+ - name: Run pre-commit
+ run: pre-commit run --all-files --show-diff-on-failure --color=always
+ - name: Check that all files generated by pre-commit are in git
+ run: |
+ newfiles="$(git ls-files --others --exclude-from=.gitignore)"
+ if [ "$newfiles" != "" ] ; then
+ echo "Please check-in the following files:"
+ echo "$newfiles"
+ exit 1
+ fi
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 07d7139574d3..1c4fe51716db 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,4 +1,4 @@
-name: test Odoo addons
+name: tests
on:
pull_request:
@@ -6,19 +6,40 @@ on:
- "14.0*"
push:
branches:
- - "14.0*"
+ - "14.0"
+ - "14.0-ocabot-*"
jobs:
+ unreleased-deps:
+ runs-on: ubuntu-latest
+ name: Detect unreleased dependencies
+ steps:
+ - uses: actions/checkout@v2
+ - run: |
+ for reqfile in requirements.txt test-requirements.txt ; do
+ if [ -f ${reqfile} ] ; then
+ result=0
+ # reject non-comment lines that contain a / (i.e. URLs, relative paths)
+ grep "^[^#].*/" ${reqfile} || result=$?
+ if [ $result -eq 0 ] ; then
+ echo "Unreleased dependencies found in ${reqfile}."
+ exit 1
+ fi
+ fi
+ done
test:
runs-on: ubuntu-latest
container: ${{ matrix.container }}
+ name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest
makepot: "true"
+ name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest
+ name: test with OCB
services:
postgres:
image: postgres:9.6
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 77961333c4c1..68c189c4d066 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -56,7 +56,7 @@ repos:
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
- rev: 20.8b1
+ rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
@@ -130,7 +130,7 @@ repos:
name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/pylint
- rev: pylint-2.5.3
+ rev: v2.11.1
hooks:
- id: pylint
name: pylint with optional checks
@@ -140,7 +140,7 @@ repos:
- --ignore=l10n_it_fatturapa_in/tests/data/
verbose: true
additional_dependencies: &pylint_deps
- - pylint-odoo==3.5.0
+ - pylint-odoo==5.0.5
- id: pylint
name: pylint with mandatory checks
args:
diff --git a/.t2d.yml b/.t2d.yml
deleted file mode 100644
index 5e8e3a666b33..000000000000
--- a/.t2d.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-language: python
-cache:
- directories:
- - $HOME/.cache/pip
- - $HOME/.cache/pre-commit
-
-python:
- - "3.6"
-
-addons:
- postgresql: "9.6"
- apt:
- packages:
- - expect-dev # provides unbuffer utility
-
-stages:
- - test
-
-jobs:
- include:
- - stage: test
- env:
- - TESTS=1 ODOO_REPO="odoo/odoo" MAKEPOT="1"
- - stage: test
- env:
- - TESTS=1 ODOO_REPO="OCA/OCB"
-env:
- global:
- - VERSION="14.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
- - MQT_DEP=PIP
-
-install:
- - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git
- ${HOME}/maintainer-quality-tools
- - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- - travis_install_nightly
-
-script:
- - travis_run_tests
-
-after_success:
- - travis_after_tests_success
diff --git a/README.md b/README.md
index 6e5642e2f50b..1e787f19801f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
-[![Runbot Status](https://runbot.odoo-community.org/runbot/badge/flat/122/14.0.svg)](https://runbot.odoo-community.org/runbot/repo/github-com-oca-l10n-italy-122)
-[![Build Status](https://travis-ci.com/OCA/l10n-italy.svg?branch=14.0)](https://travis-ci.com/OCA/l10n-italy)
+
+[![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=14.0)
+[![Pre-commit Status](https://github.com/OCA/l10n-italy/actions/workflows/pre-commit.yml/badge.svg?branch=14.0)](https://github.com/OCA/l10n-italy/actions/workflows/pre-commit.yml?query=branch%3A14.0)
+[![Build Status](https://github.com/OCA/l10n-italy/actions/workflows/test.yml/badge.svg?branch=14.0)](https://github.com/OCA/l10n-italy/actions/workflows/test.yml?query=branch%3A14.0)
[![codecov](https://codecov.io/gh/OCA/l10n-italy/branch/14.0/graph/badge.svg)](https://codecov.io/gh/OCA/l10n-italy)
[![Translation Status](https://translation.odoo-community.org/widgets/l10n-italy-14-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/l10n-italy-14-0/?utm_source=widget)
@@ -81,12 +83,11 @@ addon | version | maintainers | summary
This repository is licensed under [AGPL-3.0](LICENSE).
-However, each module can have a totally different license, as long as they adhere to OCA
+However, each module can have a totally different license, as long as they adhere to Odoo Community Association (OCA)
policy. Consult each module's `__manifest__.py` file, which contains a `license` key
that explains its license.
----
-
OCA, or the [Odoo Community Association](http://odoo-community.org/), is a nonprofit
organization whose mission is to support the collaborative development of Odoo features
and promote its widespread use.
diff --git a/l10n_it_abicab/views/abicab_view.xml b/l10n_it_abicab/views/abicab_view.xml
index a41cbfa08053..0ebe8fc9520f 100644
--- a/l10n_it_abicab/views/abicab_view.xml
+++ b/l10n_it_abicab/views/abicab_view.xml
@@ -31,7 +31,10 @@
res.bank
-
+
+ 1
+
+
diff --git a/l10n_it_account/models/account_group.py b/l10n_it_account/models/account_group.py
index 4787c238501f..db6183a27731 100644
--- a/l10n_it_account/models/account_group.py
+++ b/l10n_it_account/models/account_group.py
@@ -73,7 +73,7 @@ def get_account_balance_sign(self):
return 1
def get_group_accounts(self):
- """ Retrieves every account from `self` and `self`'s subgroups. """
+ """Retrieves every account from `self` and `self`'s subgroups."""
return (self + self.get_group_subgroups()).mapped("account_ids")
def get_group_progenitor(self):
@@ -97,6 +97,6 @@ def get_group_parents(self):
return self.browse(parent_ids)
def get_group_subgroups(self):
- """ Retrieves every subgroup for groups `self`. """
+ """Retrieves every subgroup for groups `self`."""
subgroups_ids = self.search([("id", "child_of", self.ids)])
return subgroups_ids
diff --git a/l10n_it_account_tax_kind/tests/test_account_tax_kind.py b/l10n_it_account_tax_kind/tests/test_account_tax_kind.py
index 19beb4638cd9..14a81bc2447b 100644
--- a/l10n_it_account_tax_kind/tests/test_account_tax_kind.py
+++ b/l10n_it_account_tax_kind/tests/test_account_tax_kind.py
@@ -12,7 +12,7 @@ def test_compute_display_name(self):
self.tax_kind_n1._compute_display_name()
self.assertEqual(
self.tax_kind_n1.display_name,
- u"[{}] {}".format(self.tax_kind_n1.code, self.tax_kind_n1.name),
+ "[{}] {}".format(self.tax_kind_n1.code, self.tax_kind_n1.name),
)
def test_name_search(self):
diff --git a/l10n_it_fatturapa/models/account.py b/l10n_it_fatturapa/models/account.py
index 1d3ee68513e6..8ba3bcf2ec2f 100644
--- a/l10n_it_fatturapa/models/account.py
+++ b/l10n_it_fatturapa/models/account.py
@@ -88,7 +88,7 @@ class WelfareFundType(models.Model):
def name_get(self):
res = []
for record in self:
- res.append((record.id, u"[{}] {}".format(record.name, record.description)))
+ res.append((record.id, "[{}] {}".format(record.name, record.description)))
return res
diff --git a/l10n_it_fatturapa/models/ir_attachment.py b/l10n_it_fatturapa/models/ir_attachment.py
index d71f4c851c37..b1ee8959d1c5 100644
--- a/l10n_it_fatturapa/models/ir_attachment.py
+++ b/l10n_it_fatturapa/models/ir_attachment.py
@@ -19,7 +19,7 @@
_logger.debug(err)
-re_base64 = re.compile(br"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$")
+re_base64 = re.compile(rb"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$")
def is_base64(s):
diff --git a/l10n_it_fatturapa/views/partner_view.xml b/l10n_it_fatturapa/views/partner_view.xml
index c2b8079bed8e..1a0bd8a10d13 100644
--- a/l10n_it_fatturapa/views/partner_view.xml
+++ b/l10n_it_fatturapa/views/partner_view.xml
@@ -53,7 +53,9 @@
res.partner
-
+
+ 1
+
diff --git a/l10n_it_fatturapa_in/models/attachment.py b/l10n_it_fatturapa_in/models/attachment.py
index 30600b6e297c..2dffd990c174 100644
--- a/l10n_it_fatturapa_in/models/attachment.py
+++ b/l10n_it_fatturapa_in/models/attachment.py
@@ -74,7 +74,7 @@ def _compute_e_invoice_validation_error(self):
if not bills_with_error:
continue
att.e_invoice_validation_error = True
- errors_message_template = u"{bill}:\n{errors}"
+ errors_message_template = "{bill}:\n{errors}"
error_messages = list()
for bill in bills_with_error:
error_messages.append(
diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
index eace8167f1b1..9764c28ec502 100644
--- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
+++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
@@ -144,8 +144,8 @@ def test_04_xml_import(self):
self.assertEqual(e_line.cod_article_ids[0].code_val, "12345")
self.assertEqual(
invoice.inconsistencies,
- u"Company Name field contains 'Societa' "
- u"Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
+ "Company Name field contains 'Societa' "
+ "Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
)
# allow following test to reuse the same XML file
invoice.ref = invoice.payment_reference = "14041"
@@ -344,13 +344,13 @@ def test_13_xml_import(self):
invoice2 = self.invoice_model.browse(invoice2_id)
self.assertEqual(
invoice1.inconsistencies,
- u"Company Name field contains 'Societa' "
- u"Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
+ "Company Name field contains 'Societa' "
+ "Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
)
self.assertEqual(
invoice2.inconsistencies,
- u"Company Name field contains 'Societa' "
- u"Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
+ "Company Name field contains 'Societa' "
+ "Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n",
)
def test_14_xml_import(self):
@@ -366,9 +366,9 @@ def test_14_xml_import(self):
self.assertEqual(invoice.amount_tax, 0.0)
self.assertEqual(
invoice.inconsistencies,
- u"Company Name field contains 'Societa' "
+ "Company Name field contains 'Societa' "
"Alpha SRL'. Your System contains 'SOCIETA' ALPHA SRL'\n\n"
- u"XML contains tax with percentage '15.55'"
+ "XML contains tax with percentage '15.55'"
" but it does not exist in your system\n"
"XML contains tax with percentage '15.55'"
" but it does not exist in your system",
diff --git a/l10n_it_fatturapa_out_rc/wizard/efattura.py b/l10n_it_fatturapa_out_rc/wizard/efattura.py
index abce603bd7c5..f4d24d56a9dd 100644
--- a/l10n_it_fatturapa_out_rc/wizard/efattura.py
+++ b/l10n_it_fatturapa_out_rc/wizard/efattura.py
@@ -10,14 +10,10 @@ class EFatturaOut(_EFatturaOut):
def get_template_values(self):
def get_sign(invoice):
sign = 1
- if (
- invoice.move_type
- in [
- "out_refund",
- "in_refund",
- ]
- and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]
- ):
+ if invoice.move_type in [
+ "out_refund",
+ "in_refund",
+ ] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]:
sign = -1
return sign
diff --git a/l10n_it_intrastat_statement/i18n/l10n_it_intrastat_statement.pot b/l10n_it_intrastat_statement/i18n/l10n_it_intrastat_statement.pot
index 836598b7f344..c0257544a168 100644
--- a/l10n_it_intrastat_statement/i18n/l10n_it_intrastat_statement.pot
+++ b/l10n_it_intrastat_statement/i18n/l10n_it_intrastat_statement.pot
@@ -599,109 +599,109 @@ msgid "Missing State for Partner %s"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py:0
#, python-format
msgid "Missing adjustment sign on 'Purchases - Section 2'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py:0
#, python-format
msgid "Missing adjustment sign on 'Sales - Section 2'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Missing customs section on 'Purchases - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#, python-format
msgid "Missing customs section on 'Sales - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Missing payment country on 'Purchases - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#, python-format
msgid "Missing payment country on 'Sales - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Missing progressive to adjust on 'Purchases - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#, python-format
msgid "Missing progressive to adjust on 'Sales - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Missing protocol number on 'Purchases - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#, python-format
msgid "Missing protocol number on 'Sales - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py:0
#, python-format
msgid "Missing reference month on 'Purchases - Section 2' adjustment"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py:0
#, python-format
msgid "Missing reference month on 'Sales - Section 2' adjustment"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py:0
#, python-format
msgid "Missing reference quarter on 'Purchases - Section 2' adjustment"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py:0
#, python-format
msgid "Missing reference quarter on 'Sales - Section 2' adjustment"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py:0
#, python-format
msgid "Missing reference year on 'Purchases - Section 2'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Missing reference year on 'Purchases - Section 4'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py:0
#, python-format
msgid "Missing reference year on 'Sales - Section 2'"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#, python-format
msgid "Missing reference year on 'Sales - Section 4'"
msgstr ""
@@ -953,10 +953,10 @@ msgid "Provenance Country"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py:0
#, python-format
msgid "Purchase"
msgstr ""
@@ -1035,10 +1035,10 @@ msgid "Repeated"
msgstr ""
#. module: l10n_it_intrastat_statement
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
-#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py:0
+#: code:addons/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py:0
#: model:ir.model.fields,field_description:l10n_it_intrastat_statement.field_account_intrastat_statement__sale
#: model_terms:ir.ui.view,arch_db:l10n_it_intrastat_statement.account_intrastat_statement_form_view
#, python-format
diff --git a/l10n_it_intrastat_statement/models/__init__.py b/l10n_it_intrastat_statement/models/__init__.py
index 35ccc4a21966..9c8f50f97354 100644
--- a/l10n_it_intrastat_statement/models/__init__.py
+++ b/l10n_it_intrastat_statement/models/__init__.py
@@ -4,4 +4,12 @@
from . import intrastat_statement_section
from . import intrastat_statement
from . import intrastat_statement_purchase_section
+from . import intrastat_statement_purchase_section1
+from . import intrastat_statement_purchase_section2
+from . import intrastat_statement_purchase_section3
+from . import intrastat_statement_purchase_section4
from . import intrastat_statement_sale_section
+from . import intrastat_statement_sale_section1
+from . import intrastat_statement_sale_section2
+from . import intrastat_statement_sale_section3
+from . import intrastat_statement_sale_section4
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py
index bc6068e4bb73..7a46f83dd690 100644
--- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py
@@ -1,10 +1,7 @@
# Copyright 2019 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import _, api, fields, models
-from odoo.exceptions import ValidationError
-
-from .intrastat_statement import format_9, format_x
+from odoo import api, fields, models
class IntrastatStatementPurchaseSection(models.AbstractModel):
@@ -52,504 +49,3 @@ def get_section_type(self):
def _default_transaction_nature_id(self):
company_id = self.env.context.get("company_id", self.env.company)
return company_id.intrastat_purchase_transaction_nature_id
-
-
-class IntrastatStatementPurchaseSection1(models.Model):
- _inherit = "account.intrastat.statement.purchase.section"
- _name = "account.intrastat.statement.purchase.section1"
- _description = "Intrastat Statement - Purchases Section 1"
-
- transaction_nature_id = fields.Many2one(
- comodel_name="account.intrastat.transaction.nature",
- string="Transaction Nature",
- default=lambda m: m._default_transaction_nature_id(),
- )
- weight_kg = fields.Integer(string="Net Mass (kg)")
- additional_units = fields.Integer(string="Additional Units")
- additional_units_required = fields.Boolean(
- string="Additional Unit Required",
- store=True,
- related="intrastat_code_id.additional_unit_required",
- )
- additional_units_uom = fields.Char(
- string="Additional Unit of Measure",
- readonly=True,
- related="intrastat_code_id.additional_unit_uom_id.name",
- )
- statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
- delivery_code_id = fields.Many2one(
- comodel_name="account.incoterms", string="Delivery Terms"
- )
- transport_code_id = fields.Many2one(
- comodel_name="account.intrastat.transport", string="Transport Mode"
- )
- country_origin_id = fields.Many2one(
- comodel_name="res.country", string="Provenance Country"
- )
- country_good_origin_id = fields.Many2one(
- comodel_name="res.country", string="Goods Origin Country"
- )
- province_destination_id = fields.Many2one(
- comodel_name="res.country.state", string="Destination Province"
- )
-
- @api.model
- def get_section_number(self):
- return 1
-
- @api.onchange("weight_kg")
- def change_weight_kg(self):
- if self.statement_id.company_id.intrastat_additional_unit_from == "weight":
- self.additional_units = self.weight_kg
-
- def apply_partner_data(self, partner_data):
- res = super(IntrastatStatementPurchaseSection1, self).apply_partner_data(
- partner_data
- )
- if "country_origin_id" in partner_data:
- self.country_origin_id = partner_data["country_origin_id"]
- if "country_good_origin_id" in partner_data:
- self.country_good_origin_id = partner_data["country_good_origin_id"]
- return res
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementPurchaseSection1, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- company_id = self.env.context.get("company_id", self.env.company)
-
- # Company defaults
- delivery_code_id = (
- inv_intra_line.delivery_code_id
- or company_id.intrastat_purchase_delivery_code_id
- )
- province_destination_id = (
- inv_intra_line.province_destination_id
- or company_id.intrastat_purchase_province_destination_id
- )
- statistic_amount = (
- inv_intra_line.statistic_amount_euro
- or company_id.intrastat_purchase_statistic_amount
- )
- transaction_nature_id = (
- inv_intra_line.transaction_nature_id
- or company_id.intrastat_purchase_transaction_nature_id
- )
- transport_code_id = (
- inv_intra_line.transport_code_id
- or company_id.intrastat_purchase_transport_code_id
- )
-
- # Amounts
- dp_model = self.env["decimal.precision"]
- statistic_amount = statement_id.round_min_amount(
- statistic_amount,
- statement_id.company_id or company_id,
- dp_model.precision_get("Account"),
- )
-
- # check if additional_units has a value
- has_additional_units = bool(inv_intra_line.additional_units)
- res.update(
- {
- "transaction_nature_id": transaction_nature_id.id,
- "weight_kg": round(inv_intra_line.weight_kg) or 1,
- "additional_units": round(inv_intra_line.additional_units)
- or (0 if not has_additional_units else 1),
- "statistic_amount_euro": statistic_amount,
- "delivery_code_id": delivery_code_id.id,
- "transport_code_id": transport_code_id.id,
- "country_origin_id": inv_intra_line.country_origin_id.id,
- "country_good_origin_id": inv_intra_line.country_good_origin_id.id,
- "province_destination_id": province_destination_id.id,
- }
- )
- return res
-
- def _prepare_export_line(self):
- self.ensure_one()
- self._export_line_checks(_("Purchase"), self.get_section_number())
-
- rcd = ""
- # Codice dello Stato membro del fornitore
- country_id = self.country_partner_id or self.partner_id.country_id
- rcd += format_x(country_id.code, 2)
- # Codice IVA del fornitore
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Ammontare delle operazioni in valuta
- rcd += format_9(self.amount_currency, 13)
- # Codice della natura della transazione
- rcd += format_x(self.transaction_nature_id.code, 1)
- # Codice della nomenclatura combinata della merce
- rcd += format_9(self.intrastat_code_id.name, 8)
- if self.statement_id.period_type == "M":
- # Massa netta in chilogrammi
- rcd += format_9(self.weight_kg, 10)
- # Quantità espressa nell'unità di misura supplementare
- rcd += format_9(self.additional_units, 10)
- # Valore statistico in euro
- rcd += format_9(self.statistic_amount_euro, 13)
- # Codice delle condizioni di consegna
- delivery_code = self.delivery_code_id.code or ""
- rcd += format_x(delivery_code[:1], 1)
- # Codice del modo di trasporto
- rcd += format_9(self.transport_code_id.code, 1)
- # Codice del paese di provenienza
- rcd += format_x(self.country_origin_id.code, 2)
- # Codice del paese di origine della merce
- rcd += format_x(self.country_good_origin_id.code, 2)
- # Codice della provincia di destinazione della merce
- rcd += format_x(self.province_destination_id.code, 2)
-
- rcd += "\r\n"
- return rcd
-
-
-class IntrastatStatementPurchaseSection2(models.Model):
- _inherit = "account.intrastat.statement.purchase.section"
- _name = "account.intrastat.statement.purchase.section2"
- _description = "Intrastat Statement - Purchases Section 2"
-
- month = fields.Integer(string="Ref. Month")
- quarterly = fields.Integer(string="Ref. Quarter")
- year_id = fields.Integer(string="Ref. Year")
- sign_variation = fields.Selection(
- selection=[("+", "+"), ("-", "-")], string="Adjustment Sign"
- )
- transaction_nature_id = fields.Many2one(
- comodel_name="account.intrastat.transaction.nature",
- string="Transaction Nature",
- default=lambda m: m._default_transaction_nature_id(),
- )
- statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
-
- @api.model
- def get_section_number(self):
- return 2
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementPurchaseSection2, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- company_id = self._context.get("company_id", self.env.company)
-
- # Company defaults
- statistic_amount = (
- inv_intra_line.statistic_amount_euro
- or company_id.intrastat_purchase_statistic_amount
- )
- transaction_nature_id = (
- inv_intra_line.transaction_nature_id
- or company_id.intrastat_purchase_transaction_nature_id
- )
-
- # Amounts
- dp_model = self.env["decimal.precision"]
- statistic_amount = statement_id.round_min_amount(
- statistic_amount,
- statement_id.company_id or company_id,
- dp_model.precision_get("Account"),
- )
-
- # Period Ref
- ref_period = statement_id._get_period_ref()
-
- # Sign variation
- sign_variation = False
- if inv_intra_line.invoice_id.move_type == "in_refund":
- sign_variation = "-"
-
- res.update(
- {
- "month": ref_period.get("month"),
- "quarterly": ref_period.get("quarterly"),
- "year_id": ref_period.get("year_id"),
- "sign_variation": sign_variation,
- "transaction_nature_id": transaction_nature_id.id,
- "statistic_amount_euro": statistic_amount,
- }
- )
- return res
-
- def _export_line_checks(self, section_label, section_number):
- super(IntrastatStatementPurchaseSection2, self)._export_line_checks(
- section_label, section_number
- )
- if not self.year_id:
- raise ValidationError(
- _("Missing reference year on 'Purchases - Section 2'")
- )
- if not self.sign_variation:
- raise ValidationError(
- _("Missing adjustment sign on 'Purchases - Section 2'")
- )
- if self.statement_id.period_type == "M":
- if not self.month:
- raise ValidationError(
- _(
- "Missing reference month "
- "on 'Purchases - Section 2' adjustment"
- )
- )
- elif self.statement_id.period_type == "T":
- if not self.quarterly:
- raise ValidationError(
- _(
- "Missing reference quarter "
- "on 'Purchases - Section 2' adjustment"
- )
- )
-
- def _prepare_export_line(self):
- self._export_line_checks(_("Purchase"), self.get_section_number())
-
- rcd = ""
- # Mese di riferimento del riepilogo da rettificare
- rcd += format_9(self.month, 2)
- # Trimestre di riferimento del riepilogo da rettificare
- rcd += format_9(self.quarterly, 1)
- # Anno periodo di ref da modificare
- year = (self.year_id or 0) % 100
- rcd += format_9(year, 2)
- # Codice dello Stato membro del fornitore
- country_id = self.country_partner_id or self.partner_id.country_id
- rcd += format_x(country_id.code, 2)
- # Codice IVA del fornitore
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Segno da attribuire alle variazioni da X(1) apportare
- rcd += format_x(self.sign_variation, 1)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Ammontare delle operazioni in valuta
- # >> da valorizzare solo per operazione Paesi non Euro
- amount_currency = 0
- if not (
- self.invoice_id.company_id.currency_id.id == self.invoice_id.currency_id.id
- ):
- amount_currency = self.amount_currency
- rcd += format_9(amount_currency, 13)
- # Codice della natura della transazione
- rcd += format_x(self.transaction_nature_id.code, 1)
- # Codice della nomenclatura combinata della merce
- rcd += format_9(self.intrastat_code_id.name, 8)
- if self.statement_id.period_type == "M":
- # Valore statistico in euro
- rcd += format_9(self.statistic_amount_euro, 13)
-
- rcd += "\r\n"
- return rcd
-
- def get_amount_euro(self):
- amount = 0
- for section in self:
- if section.sign_variation == "-":
- amount -= section.amount_euro
- else:
- amount += section.amount_euro
- return amount
-
-
-class IntrastatStatementPurchaseSection3(models.Model):
- _inherit = "account.intrastat.statement.purchase.section"
- _name = "account.intrastat.statement.purchase.section3"
- _description = "Intrastat Statement - Purchases Section 3"
-
- invoice_number = fields.Char(string="Invoice Number")
- invoice_date = fields.Date(string="Invoice Date")
- supply_method = fields.Selection(
- selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
- )
- payment_method = fields.Selection(
- selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
- string="Payment Method",
- )
- country_payment_id = fields.Many2one(
- comodel_name="res.country", string="Payment Country"
- )
-
- @api.model
- def get_section_number(self):
- return 3
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementPurchaseSection3, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- res.update(
- {
- "invoice_number": inv_intra_line.invoice_number,
- "invoice_date": inv_intra_line.invoice_date,
- "supply_method": inv_intra_line.supply_method,
- "payment_method": inv_intra_line.payment_method,
- "country_payment_id": inv_intra_line.country_payment_id.id,
- }
- )
- return res
-
- def _prepare_export_line(self):
- self._export_line_checks(_("Purchase"), self.get_section_number())
-
- rcd = ""
- # Codice dello Stato membro del fornitore
- country_id = self.country_partner_id or self.partner_id.country_id
- rcd += format_x(country_id.code, 2)
- # Codice IVA del fornitore
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Ammontare delle operazioni in valuta
- rcd += format_9(self.amount_currency, 13)
- # Numero Fattura
- rcd += format_x(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)
- # Codice del servizio
- rcd += format_9(self.intrastat_code_id.name, 6)
- # Modalità di erogazione
- rcd += format_x(self.supply_method, 1)
- # Modalità di incasso
- rcd += format_x(self.payment_method, 1)
- # Codice del paese di pagamento
- rcd += format_x(self.country_payment_id.code, 2)
-
- rcd += "\r\n"
- return rcd
-
-
-class IntrastatStatementPurchaseSection4(models.Model):
- _inherit = "account.intrastat.statement.purchase.section"
- _name = "account.intrastat.statement.purchase.section4"
- _description = "Intrastat Statement - Purchases Section 4"
-
- intrastat_custom_id = fields.Many2one(
- comodel_name="account.intrastat.custom", string="Customs Section"
- )
- month = fields.Integer(string="Ref. Month")
- quarterly = fields.Integer(string="Ref. Quarter")
- year_id = fields.Integer(string="Ref. Year")
- protocol = fields.Integer(string="Protocol Number")
- progressive_to_modify_id = fields.Many2one(
- comodel_name="account.intrastat.statement.purchase.section1",
- string="Progressive to Adjust ID",
- )
- progressive_to_modify = fields.Integer(string="Progressive to Adjust")
- invoice_number = fields.Char(string="Invoice Number")
- invoice_date = fields.Date(string="Invoice Date")
- supply_method = fields.Selection(
- selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
- )
- payment_method = fields.Selection(
- selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
- string="Payment Method",
- )
- country_payment_id = fields.Many2one(
- comodel_name="res.country", string="Payment Country"
- )
-
- @api.model
- def get_section_number(self):
- return 4
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementPurchaseSection4, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- # Period Ref
- ref_period = statement_id._get_period_ref()
-
- res.update(
- {
- "month": ref_period.get("month"),
- "quarterly": ref_period.get("quarterly"),
- "year_id": ref_period.get("year_id"),
- "invoice_number": inv_intra_line.invoice_number,
- "invoice_date": inv_intra_line.invoice_date,
- "supply_method": inv_intra_line.supply_method,
- "payment_method": inv_intra_line.payment_method,
- "country_payment_id": inv_intra_line.country_payment_id.id,
- "intrastat_custom_id": statement_id.intrastat_custom_id.id,
- }
- )
- return res
-
- def _export_line_checks(self, section_label, section_number):
- super(IntrastatStatementPurchaseSection4, self)._export_line_checks(
- section_label, section_number
- )
- if not self.year_id:
- raise ValidationError(
- _("Missing reference year on 'Purchases - Section 4'")
- )
- if not self.intrastat_custom_id:
- raise ValidationError(
- _("Missing customs section on 'Purchases - Section 4'")
- )
- if not self.protocol:
- raise ValidationError(
- _("Missing protocol number on 'Purchases - Section 4'")
- )
- if not self.progressive_to_modify:
- raise ValidationError(
- _("Missing progressive to adjust on 'Purchases - Section 4'")
- )
- if not self.country_payment_id:
- raise ValidationError(
- _("Missing payment country on 'Purchases - Section 4'")
- )
-
- def _prepare_export_line(self):
- self._export_line_checks(_("Purchase"), 4)
-
- rcd = ""
- # Codice della sezione doganale in cui è stato registrata la
- # dichiarazione da rettificare
- rcd += format_9(self.intrastat_custom_id.code, 6)
- # Anno di registrazione della dichiarazione da rettificare
- year = (self.year_id or 0) % 100
- rcd += format_9(year, 2)
- # Protocollo della dichiarazione da rettificare
- rcd += format_9(self.protocol, 6)
- # Progressivo della sezione 3 da rettificare
- rcd += format_9(self.progressive_to_modify_id.sequence, 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)
- # Codice IVA dell’acquirente
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Ammontare delle operazioni in valuta
- # >> da valorizzare solo per operazione Paesi non Euro
- amount_currency = 0
- if not (
- self.invoice_id.company_id.currency_id.id == self.invoice_id.currency_id.id
- ):
- amount_currency = self.amount_currency
- rcd += format_9(amount_currency, 13)
- # Numero Fattura
- rcd += format_x(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)
- # Codice del servizio
- rcd += format_9(self.intrastat_code_id.name, 6)
- # Modalità di erogazione
- rcd += format_x(self.supply_method, 1)
- # Modalità di incasso
- rcd += format_x(self.payment_method, 1)
- # Codice del paese di pagamento
- rcd += format_x(self.country_payment_id.code, 2)
-
- rcd += "\r\n"
- return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py
new file mode 100644
index 000000000000..b3c2f3feca8d
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py
@@ -0,0 +1,160 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementPurchaseSection1(models.Model):
+ _inherit = "account.intrastat.statement.purchase.section"
+ _name = "account.intrastat.statement.purchase.section1"
+ _description = "Intrastat Statement - Purchases Section 1"
+
+ transaction_nature_id = fields.Many2one(
+ comodel_name="account.intrastat.transaction.nature",
+ string="Transaction Nature",
+ default=lambda m: m._default_transaction_nature_id(),
+ )
+ weight_kg = fields.Integer(string="Net Mass (kg)")
+ additional_units = fields.Integer(string="Additional Units")
+ additional_units_required = fields.Boolean(
+ string="Additional Unit Required",
+ store=True,
+ related="intrastat_code_id.additional_unit_required",
+ )
+ additional_units_uom = fields.Char(
+ string="Additional Unit of Measure",
+ readonly=True,
+ related="intrastat_code_id.additional_unit_uom_id.name",
+ )
+ statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
+ delivery_code_id = fields.Many2one(
+ comodel_name="account.incoterms", string="Delivery Terms"
+ )
+ transport_code_id = fields.Many2one(
+ comodel_name="account.intrastat.transport", string="Transport Mode"
+ )
+ country_origin_id = fields.Many2one(
+ comodel_name="res.country", string="Provenance Country"
+ )
+ country_good_origin_id = fields.Many2one(
+ comodel_name="res.country", string="Goods Origin Country"
+ )
+ province_destination_id = fields.Many2one(
+ comodel_name="res.country.state", string="Destination Province"
+ )
+
+ @api.model
+ def get_section_number(self):
+ return 1
+
+ @api.onchange("weight_kg")
+ def change_weight_kg(self):
+ if self.statement_id.company_id.intrastat_additional_unit_from == "weight":
+ self.additional_units = self.weight_kg
+
+ def apply_partner_data(self, partner_data):
+ res = super(IntrastatStatementPurchaseSection1, self).apply_partner_data(
+ partner_data
+ )
+ if "country_origin_id" in partner_data:
+ self.country_origin_id = partner_data["country_origin_id"]
+ if "country_good_origin_id" in partner_data:
+ self.country_good_origin_id = partner_data["country_good_origin_id"]
+ return res
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementPurchaseSection1, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ company_id = self.env.context.get("company_id", self.env.company)
+
+ # Company defaults
+ delivery_code_id = (
+ inv_intra_line.delivery_code_id
+ or company_id.intrastat_purchase_delivery_code_id
+ )
+ province_destination_id = (
+ inv_intra_line.province_destination_id
+ or company_id.intrastat_purchase_province_destination_id
+ )
+ statistic_amount = (
+ inv_intra_line.statistic_amount_euro
+ or company_id.intrastat_purchase_statistic_amount
+ )
+ transaction_nature_id = (
+ inv_intra_line.transaction_nature_id
+ or company_id.intrastat_purchase_transaction_nature_id
+ )
+ transport_code_id = (
+ inv_intra_line.transport_code_id
+ or company_id.intrastat_purchase_transport_code_id
+ )
+
+ # Amounts
+ dp_model = self.env["decimal.precision"]
+ statistic_amount = statement_id.round_min_amount(
+ statistic_amount,
+ statement_id.company_id or company_id,
+ dp_model.precision_get("Account"),
+ )
+
+ # check if additional_units has a value
+ has_additional_units = bool(inv_intra_line.additional_units)
+ res.update(
+ {
+ "transaction_nature_id": transaction_nature_id.id,
+ "weight_kg": round(inv_intra_line.weight_kg) or 1,
+ "additional_units": round(inv_intra_line.additional_units)
+ or (0 if not has_additional_units else 1),
+ "statistic_amount_euro": statistic_amount,
+ "delivery_code_id": delivery_code_id.id,
+ "transport_code_id": transport_code_id.id,
+ "country_origin_id": inv_intra_line.country_origin_id.id,
+ "country_good_origin_id": inv_intra_line.country_good_origin_id.id,
+ "province_destination_id": province_destination_id.id,
+ }
+ )
+ return res
+
+ def _prepare_export_line(self):
+ self.ensure_one()
+ self._export_line_checks(_("Purchase"), self.get_section_number())
+
+ rcd = ""
+ # Codice dello Stato membro del fornitore
+ country_id = self.country_partner_id or self.partner_id.country_id
+ rcd += format_x(country_id.code, 2)
+ # Codice IVA del fornitore
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Ammontare delle operazioni in valuta
+ rcd += format_9(self.amount_currency, 13)
+ # Codice della natura della transazione
+ rcd += format_x(self.transaction_nature_id.code, 1)
+ # Codice della nomenclatura combinata della merce
+ rcd += format_9(self.intrastat_code_id.name, 8)
+ if self.statement_id.period_type == "M":
+ # Massa netta in chilogrammi
+ rcd += format_9(self.weight_kg, 10)
+ # Quantità espressa nell'unità di misura supplementare
+ rcd += format_9(self.additional_units, 10)
+ # Valore statistico in euro
+ rcd += format_9(self.statistic_amount_euro, 13)
+ # Codice delle condizioni di consegna
+ delivery_code = self.delivery_code_id.code or ""
+ rcd += format_x(delivery_code[:1], 1)
+ # Codice del modo di trasporto
+ rcd += format_9(self.transport_code_id.code, 1)
+ # Codice del paese di provenienza
+ rcd += format_x(self.country_origin_id.code, 2)
+ # Codice del paese di origine della merce
+ rcd += format_x(self.country_good_origin_id.code, 2)
+ # Codice della provincia di destinazione della merce
+ rcd += format_x(self.province_destination_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py
new file mode 100644
index 000000000000..d85b9c9767d9
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py
@@ -0,0 +1,152 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+from odoo.exceptions import ValidationError
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementPurchaseSection2(models.Model):
+ _inherit = "account.intrastat.statement.purchase.section"
+ _name = "account.intrastat.statement.purchase.section2"
+ _description = "Intrastat Statement - Purchases Section 2"
+
+ month = fields.Integer(string="Ref. Month")
+ quarterly = fields.Integer(string="Ref. Quarter")
+ year_id = fields.Integer(string="Ref. Year")
+ sign_variation = fields.Selection(
+ selection=[("+", "+"), ("-", "-")], string="Adjustment Sign"
+ )
+ transaction_nature_id = fields.Many2one(
+ comodel_name="account.intrastat.transaction.nature",
+ string="Transaction Nature",
+ default=lambda m: m._default_transaction_nature_id(),
+ )
+ statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
+
+ @api.model
+ def get_section_number(self):
+ return 2
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementPurchaseSection2, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ company_id = self._context.get("company_id", self.env.company)
+
+ # Company defaults
+ statistic_amount = (
+ inv_intra_line.statistic_amount_euro
+ or company_id.intrastat_purchase_statistic_amount
+ )
+ transaction_nature_id = (
+ inv_intra_line.transaction_nature_id
+ or company_id.intrastat_purchase_transaction_nature_id
+ )
+
+ # Amounts
+ dp_model = self.env["decimal.precision"]
+ statistic_amount = statement_id.round_min_amount(
+ statistic_amount,
+ statement_id.company_id or company_id,
+ dp_model.precision_get("Account"),
+ )
+
+ # Period Ref
+ ref_period = statement_id._get_period_ref()
+
+ # Sign variation
+ sign_variation = False
+ if inv_intra_line.invoice_id.move_type == "in_refund":
+ sign_variation = "-"
+
+ res.update(
+ {
+ "month": ref_period.get("month"),
+ "quarterly": ref_period.get("quarterly"),
+ "year_id": ref_period.get("year_id"),
+ "sign_variation": sign_variation,
+ "transaction_nature_id": transaction_nature_id.id,
+ "statistic_amount_euro": statistic_amount,
+ }
+ )
+ return res
+
+ def _export_line_checks(self, section_label, section_number):
+ super(IntrastatStatementPurchaseSection2, self)._export_line_checks(
+ section_label, section_number
+ )
+ if not self.year_id:
+ raise ValidationError(
+ _("Missing reference year on 'Purchases - Section 2'")
+ )
+ if not self.sign_variation:
+ raise ValidationError(
+ _("Missing adjustment sign on 'Purchases - Section 2'")
+ )
+ if self.statement_id.period_type == "M":
+ if not self.month:
+ raise ValidationError(
+ _(
+ "Missing reference month "
+ "on 'Purchases - Section 2' adjustment"
+ )
+ )
+ elif self.statement_id.period_type == "T":
+ if not self.quarterly:
+ raise ValidationError(
+ _(
+ "Missing reference quarter "
+ "on 'Purchases - Section 2' adjustment"
+ )
+ )
+
+ def _prepare_export_line(self):
+ self._export_line_checks(_("Purchase"), self.get_section_number())
+
+ rcd = ""
+ # Mese di riferimento del riepilogo da rettificare
+ rcd += format_9(self.month, 2)
+ # Trimestre di riferimento del riepilogo da rettificare
+ rcd += format_9(self.quarterly, 1)
+ # Anno periodo di ref da modificare
+ year = (self.year_id or 0) % 100
+ rcd += format_9(year, 2)
+ # Codice dello Stato membro del fornitore
+ country_id = self.country_partner_id or self.partner_id.country_id
+ rcd += format_x(country_id.code, 2)
+ # Codice IVA del fornitore
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Segno da attribuire alle variazioni da X(1) apportare
+ rcd += format_x(self.sign_variation, 1)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Ammontare delle operazioni in valuta
+ # >> da valorizzare solo per operazione Paesi non Euro
+ amount_currency = 0
+ if not (
+ self.invoice_id.company_id.currency_id.id == self.invoice_id.currency_id.id
+ ):
+ amount_currency = self.amount_currency
+ rcd += format_9(amount_currency, 13)
+ # Codice della natura della transazione
+ rcd += format_x(self.transaction_nature_id.code, 1)
+ # Codice della nomenclatura combinata della merce
+ rcd += format_9(self.intrastat_code_id.name, 8)
+ if self.statement_id.period_type == "M":
+ # Valore statistico in euro
+ rcd += format_9(self.statistic_amount_euro, 13)
+
+ rcd += "\r\n"
+ return rcd
+
+ def get_amount_euro(self):
+ amount = 0
+ for section in self:
+ if section.sign_variation == "-":
+ amount -= section.amount_euro
+ else:
+ amount += section.amount_euro
+ return amount
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py
new file mode 100644
index 000000000000..28870a41ea29
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py
@@ -0,0 +1,77 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementPurchaseSection3(models.Model):
+ _inherit = "account.intrastat.statement.purchase.section"
+ _name = "account.intrastat.statement.purchase.section3"
+ _description = "Intrastat Statement - Purchases Section 3"
+
+ invoice_number = fields.Char(string="Invoice Number")
+ invoice_date = fields.Date(string="Invoice Date")
+ supply_method = fields.Selection(
+ selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
+ )
+ payment_method = fields.Selection(
+ selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
+ string="Payment Method",
+ )
+ country_payment_id = fields.Many2one(
+ comodel_name="res.country", string="Payment Country"
+ )
+
+ @api.model
+ def get_section_number(self):
+ return 3
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementPurchaseSection3, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ res.update(
+ {
+ "invoice_number": inv_intra_line.invoice_number,
+ "invoice_date": inv_intra_line.invoice_date,
+ "supply_method": inv_intra_line.supply_method,
+ "payment_method": inv_intra_line.payment_method,
+ "country_payment_id": inv_intra_line.country_payment_id.id,
+ }
+ )
+ return res
+
+ def _prepare_export_line(self):
+ self._export_line_checks(_("Purchase"), self.get_section_number())
+
+ rcd = ""
+ # Codice dello Stato membro del fornitore
+ country_id = self.country_partner_id or self.partner_id.country_id
+ rcd += format_x(country_id.code, 2)
+ # Codice IVA del fornitore
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Ammontare delle operazioni in valuta
+ rcd += format_9(self.amount_currency, 13)
+ # Numero Fattura
+ rcd += format_x(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)
+ # Codice del servizio
+ rcd += format_9(self.intrastat_code_id.name, 6)
+ # Modalità di erogazione
+ rcd += format_x(self.supply_method, 1)
+ # Modalità di incasso
+ rcd += format_x(self.payment_method, 1)
+ # Codice del paese di pagamento
+ rcd += format_x(self.country_payment_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py
new file mode 100644
index 000000000000..e4a5742d1015
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py
@@ -0,0 +1,138 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+from odoo.exceptions import ValidationError
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementPurchaseSection4(models.Model):
+ _inherit = "account.intrastat.statement.purchase.section"
+ _name = "account.intrastat.statement.purchase.section4"
+ _description = "Intrastat Statement - Purchases Section 4"
+
+ intrastat_custom_id = fields.Many2one(
+ comodel_name="account.intrastat.custom", string="Customs Section"
+ )
+ month = fields.Integer(string="Ref. Month")
+ quarterly = fields.Integer(string="Ref. Quarter")
+ year_id = fields.Integer(string="Ref. Year")
+ protocol = fields.Integer(string="Protocol Number")
+ progressive_to_modify_id = fields.Many2one(
+ comodel_name="account.intrastat.statement.purchase.section1",
+ string="Progressive to Adjust ID",
+ )
+ progressive_to_modify = fields.Integer(string="Progressive to Adjust")
+ invoice_number = fields.Char(string="Invoice Number")
+ invoice_date = fields.Date(string="Invoice Date")
+ supply_method = fields.Selection(
+ selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
+ )
+ payment_method = fields.Selection(
+ selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
+ string="Payment Method",
+ )
+ country_payment_id = fields.Many2one(
+ comodel_name="res.country", string="Payment Country"
+ )
+
+ @api.model
+ def get_section_number(self):
+ return 4
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementPurchaseSection4, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ # Period Ref
+ ref_period = statement_id._get_period_ref()
+
+ res.update(
+ {
+ "month": ref_period.get("month"),
+ "quarterly": ref_period.get("quarterly"),
+ "year_id": ref_period.get("year_id"),
+ "invoice_number": inv_intra_line.invoice_number,
+ "invoice_date": inv_intra_line.invoice_date,
+ "supply_method": inv_intra_line.supply_method,
+ "payment_method": inv_intra_line.payment_method,
+ "country_payment_id": inv_intra_line.country_payment_id.id,
+ "intrastat_custom_id": statement_id.intrastat_custom_id.id,
+ }
+ )
+ return res
+
+ def _export_line_checks(self, section_label, section_number):
+ super(IntrastatStatementPurchaseSection4, self)._export_line_checks(
+ section_label, section_number
+ )
+ if not self.year_id:
+ raise ValidationError(
+ _("Missing reference year on 'Purchases - Section 4'")
+ )
+ if not self.intrastat_custom_id:
+ raise ValidationError(
+ _("Missing customs section on 'Purchases - Section 4'")
+ )
+ if not self.protocol:
+ raise ValidationError(
+ _("Missing protocol number on 'Purchases - Section 4'")
+ )
+ if not self.progressive_to_modify:
+ raise ValidationError(
+ _("Missing progressive to adjust on 'Purchases - Section 4'")
+ )
+ if not self.country_payment_id:
+ raise ValidationError(
+ _("Missing payment country on 'Purchases - Section 4'")
+ )
+
+ def _prepare_export_line(self):
+ self._export_line_checks(_("Purchase"), 4)
+
+ rcd = ""
+ # Codice della sezione doganale in cui è stato registrata la
+ # dichiarazione da rettificare
+ rcd += format_9(self.intrastat_custom_id.code, 6)
+ # Anno di registrazione della dichiarazione da rettificare
+ year = (self.year_id or 0) % 100
+ rcd += format_9(year, 2)
+ # Protocollo della dichiarazione da rettificare
+ rcd += format_9(self.protocol, 6)
+ # Progressivo della sezione 3 da rettificare
+ rcd += format_9(self.progressive_to_modify_id.sequence, 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)
+ # Codice IVA dell’acquirente
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Ammontare delle operazioni in valuta
+ # >> da valorizzare solo per operazione Paesi non Euro
+ amount_currency = 0
+ if not (
+ self.invoice_id.company_id.currency_id.id == self.invoice_id.currency_id.id
+ ):
+ amount_currency = self.amount_currency
+ rcd += format_9(amount_currency, 13)
+ # Numero Fattura
+ rcd += format_x(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)
+ # Codice del servizio
+ rcd += format_9(self.intrastat_code_id.name, 6)
+ # Modalità di erogazione
+ rcd += format_x(self.supply_method, 1)
+ # Modalità di incasso
+ rcd += format_x(self.payment_method, 1)
+ # Codice del paese di pagamento
+ rcd += format_x(self.country_payment_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py
index 79c0a519f0a9..2e8a367ccf45 100644
--- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py
@@ -1,10 +1,7 @@
# Copyright 2019 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import _, api, fields, models
-from odoo.exceptions import ValidationError
-
-from .intrastat_statement import format_9, format_x
+from odoo import api, models
class IntrastatStatementSaleSection(models.AbstractModel):
@@ -20,466 +17,3 @@ def get_section_type(self):
def _default_transaction_nature_id(self):
company_id = self.env.context.get("company_id", self.env.company)
return company_id.intrastat_sale_transaction_nature_id
-
-
-class IntrastatStatementSaleSection1(models.Model):
- _inherit = "account.intrastat.statement.sale.section"
- _name = "account.intrastat.statement.sale.section1"
- _description = "Intrastat Statement - Sales Section 1"
-
- transaction_nature_id = fields.Many2one(
- comodel_name="account.intrastat.transaction.nature",
- string="Transaction Nature",
- default=lambda m: m._default_transaction_nature_id(),
- )
- weight_kg = fields.Integer(string="Net Mass (kg)")
- additional_units = fields.Integer(string="Additional Units")
- additional_units_required = fields.Boolean(
- string="Additional Unit Required",
- store=True,
- related="intrastat_code_id.additional_unit_required",
- )
- additional_units_uom = fields.Char(
- string="Additional Unit of Measure",
- readonly=True,
- related="intrastat_code_id.additional_unit_uom_id.name",
- )
- statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
- delivery_code_id = fields.Many2one(
- comodel_name="account.incoterms", string="Delivery Terms"
- )
- transport_code_id = fields.Many2one(
- comodel_name="account.intrastat.transport", string="Transport Mode"
- )
- country_destination_id = fields.Many2one(
- comodel_name="res.country", string="Destination Country"
- )
- province_origin_id = fields.Many2one(
- comodel_name="res.country.state", string="Origin Province"
- )
-
- @api.model
- def get_section_number(self):
- return 1
-
- def apply_partner_data(self, partner_data):
- res = super(IntrastatStatementSaleSection1, self).apply_partner_data(
- partner_data
- )
- if "country_destination_id" in partner_data:
- self.country_destination_id = partner_data["country_destination_id"]
- return res
-
- @api.onchange("weight_kg")
- def change_weight_kg(self):
- if self.statement_id.company_id.intrastat_additional_unit_from == "weight":
- self.additional_units = self.weight_kg
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementSaleSection1, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- company_id = self.env.company
-
- # Company defaults
- delivery_code_id = (
- inv_intra_line.delivery_code_id
- or company_id.intrastat_sale_delivery_code_id
- )
- province_origin_id = (
- inv_intra_line.province_origin_id
- or company_id.intrastat_sale_province_origin_id
- )
- statistic_amount = (
- inv_intra_line.statistic_amount_euro
- or company_id.intrastat_sale_statistic_amount
- )
- transaction_nature_id = (
- inv_intra_line.transaction_nature_id
- or company_id.intrastat_sale_transaction_nature_id
- )
- transport_code_id = (
- inv_intra_line.transport_code_id
- or company_id.intrastat_sale_transport_code_id
- )
-
- # Amounts
- dp_model = self.env["decimal.precision"]
- statistic_amount = statement_id.round_min_amount(
- statistic_amount,
- statement_id.company_id or company_id,
- dp_model.precision_get("Account"),
- )
-
- # check if additional_units has a value
- has_additional_units = bool(inv_intra_line.additional_units)
- res.update(
- {
- "transaction_nature_id": transaction_nature_id.id,
- "weight_kg": round(inv_intra_line.weight_kg) or 1,
- "additional_units": round(inv_intra_line.additional_units)
- or (0 if not has_additional_units else 1),
- "statistic_amount_euro": statistic_amount,
- "delivery_code_id": delivery_code_id.id,
- "transport_code_id": transport_code_id.id,
- "country_destination_id": inv_intra_line.country_destination_id.id,
- "province_origin_id": province_origin_id.id,
- }
- )
- return res
-
- @api.model
- def _prepare_export_line(self):
- self.ensure_one()
- self._export_line_checks(_("Sales"), self.get_section_number())
-
- rcd = ""
- # 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)
- # Codice IVA dell’acquirente
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Codice della natura della transazione
- rcd += format_x(self.transaction_nature_id.code, 1)
- # Codice della nomenclatura combinata della merce
- rcd += format_9(self.intrastat_code_id.name, 8)
- if self.statement_id.period_type == "M":
- # Massa netta in chilogrammi
- rcd += format_9(self.weight_kg, 10)
- # Quantità espressa nell'unità di misura supplementare
- rcd += format_9(self.additional_units, 10)
- # Valore statistico in euro
- rcd += format_9(self.statistic_amount_euro, 13)
- # Codice delle condizioni di consegna
- delivery_code = self.delivery_code_id.code or ""
- rcd += format_x(delivery_code[:1], 1)
- # Codice del modo di trasporto
- transport_code = self.transport_code_id.code
- rcd += format_9(transport_code, 1)
- # Codice del paese di destinazione
- rcd += format_x(self.country_destination_id.code, 2)
- # Codice del paese di origine della merce
- rcd += format_x(self.province_origin_id.code, 2)
-
- rcd += "\r\n"
- return rcd
-
-
-class IntrastatStatementSaleSection2(models.Model):
- _inherit = "account.intrastat.statement.sale.section"
- _name = "account.intrastat.statement.sale.section2"
- _description = "Intrastat Statement - Sales Section 2"
-
- month = fields.Integer(string="Ref. Month")
- quarterly = fields.Integer(string="Ref. Quarter")
- year_id = fields.Integer(string="Ref. Year")
- sign_variation = fields.Selection(
- selection=[("+", "+"), ("-", "-")], string="Adjustment Sign"
- )
- transaction_nature_id = fields.Many2one(
- comodel_name="account.intrastat.transaction.nature",
- string="Transaction Nature",
- default=lambda m: m._default_transaction_nature_id(),
- )
- statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
-
- @api.model
- def get_section_number(self):
- return 2
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementSaleSection2, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- company_id = self._context.get("company_id", self.env.company)
-
- # Company defaults
- transaction_nature_id = (
- inv_intra_line.transaction_nature_id
- or company_id.intrastat_sale_transaction_nature_id
- )
- statistic_amount = (
- inv_intra_line.statistic_amount_euro
- or company_id.intrastat_sale_statistic_amount
- )
-
- # Amounts
- dp_model = self.env["decimal.precision"]
- statistic_amount = statement_id.round_min_amount(
- statistic_amount,
- statement_id.company_id or company_id,
- dp_model.precision_get("Account"),
- )
-
- # Period Ref
- ref_period = statement_id._get_period_ref()
-
- # Sign variation
- sign_variation = False
- if inv_intra_line.invoice_id.move_type == "out_refund":
- sign_variation = "-"
- res.update(
- {
- "month": ref_period.get("month"),
- "quarterly": ref_period.get("quarterly"),
- "year_id": ref_period.get("year_id"),
- "sign_variation": sign_variation,
- "transaction_nature_id": transaction_nature_id.id,
- "statistic_amount_euro": statistic_amount,
- }
- )
- return res
-
- def _export_line_checks(self, section_label, section_number):
- super(IntrastatStatementSaleSection2, self)._export_line_checks(
- section_label, section_number
- )
- if not self.year_id:
- raise ValidationError(_("Missing reference year on 'Sales - Section 2'"))
- if not self.sign_variation:
- raise ValidationError(_("Missing adjustment sign on 'Sales - Section 2'"))
- if self.statement_id.period_type == "M":
- if not self.month:
- raise ValidationError(
- _("Missing reference month on 'Sales - Section 2' adjustment")
- )
- elif self.statement_id.period_type == "T":
- if not self.quarterly:
- raise ValidationError(
- _("Missing reference quarter on 'Sales - Section 2' adjustment")
- )
-
- @api.model
- def _prepare_export_line(self):
- self.ensure_one()
- self._export_line_checks(_("Sales"), self.get_section_number())
-
- rcd = ""
- # Mese di riferimento del riepilogo da rettificare
- rcd += format_9(self.month, 2)
- # Trimestre di riferimento del riepilogo da rettificare
- rcd += format_9(self.quarterly, 1)
- # Anno periodo di ref da modificare
- year = (self.year_id or 0) % 100
- rcd += format_9(year, 2)
- # 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)
- # Codice IVA dell’acquirente
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Segno da attribuire alle variazioni da X(1) apportare
- rcd += format_x(self.sign_variation, 1)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Codice della natura della transazione
- rcd += format_x(self.transaction_nature_id.code, 1)
- # Codice della nomenclatura combinata della merce
- rcd += format_9(self.intrastat_code_id.name, 8)
- if self.statement_id.period_type == "M":
- # Valore statistico in euro
- rcd += format_9(self.statistic_amount_euro, 13)
-
- rcd += "\r\n"
- return rcd
-
- def get_amount_euro(self):
- amount = 0
- for section in self:
- if section.sign_variation == "-":
- amount -= section.amount_euro
- else:
- amount += section.amount_euro
- return amount
-
-
-class IntrastatStatementSaleSection3(models.Model):
- _inherit = "account.intrastat.statement.sale.section"
- _name = "account.intrastat.statement.sale.section3"
- _description = "Intrastat Statement - Sales Section 3"
-
- invoice_number = fields.Char(string="Invoice Number")
- invoice_date = fields.Date(string="Invoice Date")
- supply_method = fields.Selection(
- selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
- )
- payment_method = fields.Selection(
- selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
- string="Payment Method",
- )
- country_payment_id = fields.Many2one(
- comodel_name="res.country", string="Payment Country"
- )
-
- @api.model
- def get_section_number(self):
- return 3
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementSaleSection3, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
- res.update(
- {
- "invoice_number": inv_intra_line.invoice_number,
- "invoice_date": inv_intra_line.invoice_date,
- "supply_method": inv_intra_line.supply_method,
- "payment_method": inv_intra_line.payment_method,
- "country_payment_id": inv_intra_line.country_payment_id.id,
- }
- )
- return res
-
- @api.model
- def _prepare_export_line(self):
- self.ensure_one()
- self._export_line_checks(_("Sales"), self.get_section_number())
-
- rcd = ""
- # 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)
- # Codice IVA del fornitore
- rcd += format_x(self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(self.amount_euro, 13)
- # Numero Fattura
- rcd += format_x(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)
- # Codice del servizio
- rcd += format_9(self.intrastat_code_id.name, 6)
- # Modalità di erogazione
- rcd += format_x(self.supply_method, 1)
- # Modalità di incasso
- rcd += format_x(self.payment_method, 1)
- # Codice del paese di pagamento
- rcd += format_x(self.country_payment_id.code, 2)
-
- rcd += "\r\n"
- return rcd
-
-
-class IntrastatStatementSaleSection4(models.Model):
- _inherit = "account.intrastat.statement.sale.section"
- _name = "account.intrastat.statement.sale.section4"
- _description = "Intrastat Statement - Sales Section 4"
-
- intrastat_custom_id = fields.Many2one(
- comodel_name="account.intrastat.custom", string="Customs Section"
- )
- month = fields.Integer(string="Ref. Month")
- quarterly = fields.Integer(string="Ref. Quarter")
- year_id = fields.Integer(string="Ref. Year")
- protocol = fields.Integer(string="Protocol Number")
- progressive_to_modify = fields.Integer(string="Progressive to Adjust")
- invoice_number = fields.Char(string="Invoice Number")
- invoice_date = fields.Date(string="Invoice Date")
- supply_method = fields.Selection(
- selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
- )
- payment_method = fields.Selection(
- selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
- string="Payment Method",
- )
- 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):
- return 4
-
- @api.model
- def _prepare_statement_line(self, inv_intra_line, statement_id=None):
- res = super(IntrastatStatementSaleSection4, self)._prepare_statement_line(
- inv_intra_line, statement_id
- )
-
- # Period Ref
- ref_period = statement_id._get_period_ref()
-
- res.update(
- {
- "month": ref_period.get("month"),
- "quarterly": ref_period.get("quarterly"),
- "year_id": ref_period.get("year_id"),
- "invoice_number": inv_intra_line.invoice_number,
- "invoice_date": inv_intra_line.invoice_date,
- "supply_method": inv_intra_line.supply_method,
- "payment_method": inv_intra_line.payment_method,
- "country_payment_id": inv_intra_line.country_payment_id.id,
- "intrastat_custom_id": statement_id.intrastat_custom_id.id,
- }
- )
- return res
-
- def _export_line_checks(self, section_label, section_number):
- super(IntrastatStatementSaleSection4, self)._export_line_checks(
- section_label, section_number
- )
- if not self.year_id:
- raise ValidationError(_("Missing reference year on 'Sales - Section 4'"))
- if not self.intrastat_custom_id:
- raise ValidationError(_("Missing customs section on 'Sales - Section 4'"))
- if not self.protocol:
- raise ValidationError(_("Missing protocol number on 'Sales - Section 4'"))
- if not self.progressive_to_modify:
- raise ValidationError(
- _("Missing progressive to adjust on 'Sales - Section 4'")
- )
- 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
- # dichiarazione da rettificare
- rcd += format_9(self.intrastat_custom_id.code, 6)
- # Anno di registrazione della dichiarazione da rettificare
- year = (self.year_id or 0) % 100
- rcd += format_9(year, 2)
- # Protocollo della dichiarazione da rettificare
- rcd += format_9(self.protocol, 6)
- # Progressivo della sezione 3 da rettificare
- 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(modifying and country_id.code, 2)
- # Codice IVA dell’acquirente
- rcd += format_x(modifying and self.vat_code.replace(" ", ""), 12)
- # Ammontare delle operazioni in euro
- rcd += format_9(modifying and self.amount_euro, 13)
- # Numero Fattura
- 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(modifying and invoice_date_ddmmyy, 6)
- # Codice del servizio
- rcd += format_9(modifying and self.intrastat_code_id.name, 6)
- # Modalità di erogazione
- rcd += format_x(modifying and self.supply_method, 1)
- # Modalità di incasso
- rcd += format_x(modifying and self.payment_method, 1)
- # Codice del paese di pagamento
- rcd += format_x(modifying and self.country_payment_id.code, 2)
-
- rcd += "\r\n"
- return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py
new file mode 100644
index 000000000000..909886444337
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py
@@ -0,0 +1,152 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementSaleSection1(models.Model):
+ _inherit = "account.intrastat.statement.sale.section"
+ _name = "account.intrastat.statement.sale.section1"
+ _description = "Intrastat Statement - Sales Section 1"
+
+ transaction_nature_id = fields.Many2one(
+ comodel_name="account.intrastat.transaction.nature",
+ string="Transaction Nature",
+ default=lambda m: m._default_transaction_nature_id(),
+ )
+ weight_kg = fields.Integer(string="Net Mass (kg)")
+ additional_units = fields.Integer(string="Additional Units")
+ additional_units_required = fields.Boolean(
+ string="Additional Unit Required",
+ store=True,
+ related="intrastat_code_id.additional_unit_required",
+ )
+ additional_units_uom = fields.Char(
+ string="Additional Unit of Measure",
+ readonly=True,
+ related="intrastat_code_id.additional_unit_uom_id.name",
+ )
+ statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
+ delivery_code_id = fields.Many2one(
+ comodel_name="account.incoterms", string="Delivery Terms"
+ )
+ transport_code_id = fields.Many2one(
+ comodel_name="account.intrastat.transport", string="Transport Mode"
+ )
+ country_destination_id = fields.Many2one(
+ comodel_name="res.country", string="Destination Country"
+ )
+ province_origin_id = fields.Many2one(
+ comodel_name="res.country.state", string="Origin Province"
+ )
+
+ @api.model
+ def get_section_number(self):
+ return 1
+
+ def apply_partner_data(self, partner_data):
+ res = super(IntrastatStatementSaleSection1, self).apply_partner_data(
+ partner_data
+ )
+ if "country_destination_id" in partner_data:
+ self.country_destination_id = partner_data["country_destination_id"]
+ return res
+
+ @api.onchange("weight_kg")
+ def change_weight_kg(self):
+ if self.statement_id.company_id.intrastat_additional_unit_from == "weight":
+ self.additional_units = self.weight_kg
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementSaleSection1, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ company_id = self.env.company
+
+ # Company defaults
+ delivery_code_id = (
+ inv_intra_line.delivery_code_id
+ or company_id.intrastat_sale_delivery_code_id
+ )
+ province_origin_id = (
+ inv_intra_line.province_origin_id
+ or company_id.intrastat_sale_province_origin_id
+ )
+ statistic_amount = (
+ inv_intra_line.statistic_amount_euro
+ or company_id.intrastat_sale_statistic_amount
+ )
+ transaction_nature_id = (
+ inv_intra_line.transaction_nature_id
+ or company_id.intrastat_sale_transaction_nature_id
+ )
+ transport_code_id = (
+ inv_intra_line.transport_code_id
+ or company_id.intrastat_sale_transport_code_id
+ )
+
+ # Amounts
+ dp_model = self.env["decimal.precision"]
+ statistic_amount = statement_id.round_min_amount(
+ statistic_amount,
+ statement_id.company_id or company_id,
+ dp_model.precision_get("Account"),
+ )
+
+ # check if additional_units has a value
+ has_additional_units = bool(inv_intra_line.additional_units)
+ res.update(
+ {
+ "transaction_nature_id": transaction_nature_id.id,
+ "weight_kg": round(inv_intra_line.weight_kg) or 1,
+ "additional_units": round(inv_intra_line.additional_units)
+ or (0 if not has_additional_units else 1),
+ "statistic_amount_euro": statistic_amount,
+ "delivery_code_id": delivery_code_id.id,
+ "transport_code_id": transport_code_id.id,
+ "country_destination_id": inv_intra_line.country_destination_id.id,
+ "province_origin_id": province_origin_id.id,
+ }
+ )
+ return res
+
+ @api.model
+ def _prepare_export_line(self):
+ self.ensure_one()
+ self._export_line_checks(_("Sales"), self.get_section_number())
+
+ rcd = ""
+ # 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)
+ # Codice IVA dell’acquirente
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Codice della natura della transazione
+ rcd += format_x(self.transaction_nature_id.code, 1)
+ # Codice della nomenclatura combinata della merce
+ rcd += format_9(self.intrastat_code_id.name, 8)
+ if self.statement_id.period_type == "M":
+ # Massa netta in chilogrammi
+ rcd += format_9(self.weight_kg, 10)
+ # Quantità espressa nell'unità di misura supplementare
+ rcd += format_9(self.additional_units, 10)
+ # Valore statistico in euro
+ rcd += format_9(self.statistic_amount_euro, 13)
+ # Codice delle condizioni di consegna
+ delivery_code = self.delivery_code_id.code or ""
+ rcd += format_x(delivery_code[:1], 1)
+ # Codice del modo di trasporto
+ transport_code = self.transport_code_id.code
+ rcd += format_9(transport_code, 1)
+ # Codice del paese di destinazione
+ rcd += format_x(self.country_destination_id.code, 2)
+ # Codice del paese di origine della merce
+ rcd += format_x(self.province_origin_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py
new file mode 100644
index 000000000000..458bf3246235
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py
@@ -0,0 +1,135 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+from odoo.exceptions import ValidationError
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementSaleSection2(models.Model):
+ _inherit = "account.intrastat.statement.sale.section"
+ _name = "account.intrastat.statement.sale.section2"
+ _description = "Intrastat Statement - Sales Section 2"
+
+ month = fields.Integer(string="Ref. Month")
+ quarterly = fields.Integer(string="Ref. Quarter")
+ year_id = fields.Integer(string="Ref. Year")
+ sign_variation = fields.Selection(
+ selection=[("+", "+"), ("-", "-")], string="Adjustment Sign"
+ )
+ transaction_nature_id = fields.Many2one(
+ comodel_name="account.intrastat.transaction.nature",
+ string="Transaction Nature",
+ default=lambda m: m._default_transaction_nature_id(),
+ )
+ statistic_amount_euro = fields.Integer(string="Statistic Value in Euro")
+
+ @api.model
+ def get_section_number(self):
+ return 2
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementSaleSection2, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ company_id = self._context.get("company_id", self.env.company)
+
+ # Company defaults
+ transaction_nature_id = (
+ inv_intra_line.transaction_nature_id
+ or company_id.intrastat_sale_transaction_nature_id
+ )
+ statistic_amount = (
+ inv_intra_line.statistic_amount_euro
+ or company_id.intrastat_sale_statistic_amount
+ )
+
+ # Amounts
+ dp_model = self.env["decimal.precision"]
+ statistic_amount = statement_id.round_min_amount(
+ statistic_amount,
+ statement_id.company_id or company_id,
+ dp_model.precision_get("Account"),
+ )
+
+ # Period Ref
+ ref_period = statement_id._get_period_ref()
+
+ # Sign variation
+ sign_variation = False
+ if inv_intra_line.invoice_id.move_type == "out_refund":
+ sign_variation = "-"
+ res.update(
+ {
+ "month": ref_period.get("month"),
+ "quarterly": ref_period.get("quarterly"),
+ "year_id": ref_period.get("year_id"),
+ "sign_variation": sign_variation,
+ "transaction_nature_id": transaction_nature_id.id,
+ "statistic_amount_euro": statistic_amount,
+ }
+ )
+ return res
+
+ def _export_line_checks(self, section_label, section_number):
+ super(IntrastatStatementSaleSection2, self)._export_line_checks(
+ section_label, section_number
+ )
+ if not self.year_id:
+ raise ValidationError(_("Missing reference year on 'Sales - Section 2'"))
+ if not self.sign_variation:
+ raise ValidationError(_("Missing adjustment sign on 'Sales - Section 2'"))
+ if self.statement_id.period_type == "M":
+ if not self.month:
+ raise ValidationError(
+ _("Missing reference month on 'Sales - Section 2' adjustment")
+ )
+ elif self.statement_id.period_type == "T":
+ if not self.quarterly:
+ raise ValidationError(
+ _("Missing reference quarter on 'Sales - Section 2' adjustment")
+ )
+
+ @api.model
+ def _prepare_export_line(self):
+ self.ensure_one()
+ self._export_line_checks(_("Sales"), self.get_section_number())
+
+ rcd = ""
+ # Mese di riferimento del riepilogo da rettificare
+ rcd += format_9(self.month, 2)
+ # Trimestre di riferimento del riepilogo da rettificare
+ rcd += format_9(self.quarterly, 1)
+ # Anno periodo di ref da modificare
+ year = (self.year_id or 0) % 100
+ rcd += format_9(year, 2)
+ # 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)
+ # Codice IVA dell’acquirente
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Segno da attribuire alle variazioni da X(1) apportare
+ rcd += format_x(self.sign_variation, 1)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Codice della natura della transazione
+ rcd += format_x(self.transaction_nature_id.code, 1)
+ # Codice della nomenclatura combinata della merce
+ rcd += format_9(self.intrastat_code_id.name, 8)
+ if self.statement_id.period_type == "M":
+ # Valore statistico in euro
+ rcd += format_9(self.statistic_amount_euro, 13)
+
+ rcd += "\r\n"
+ return rcd
+
+ def get_amount_euro(self):
+ amount = 0
+ for section in self:
+ if section.sign_variation == "-":
+ amount -= section.amount_euro
+ else:
+ amount += section.amount_euro
+ return amount
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py
new file mode 100644
index 000000000000..a6515abb5462
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py
@@ -0,0 +1,77 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementSaleSection3(models.Model):
+ _inherit = "account.intrastat.statement.sale.section"
+ _name = "account.intrastat.statement.sale.section3"
+ _description = "Intrastat Statement - Sales Section 3"
+
+ invoice_number = fields.Char(string="Invoice Number")
+ invoice_date = fields.Date(string="Invoice Date")
+ supply_method = fields.Selection(
+ selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
+ )
+ payment_method = fields.Selection(
+ selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
+ string="Payment Method",
+ )
+ country_payment_id = fields.Many2one(
+ comodel_name="res.country", string="Payment Country"
+ )
+
+ @api.model
+ def get_section_number(self):
+ return 3
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementSaleSection3, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+ res.update(
+ {
+ "invoice_number": inv_intra_line.invoice_number,
+ "invoice_date": inv_intra_line.invoice_date,
+ "supply_method": inv_intra_line.supply_method,
+ "payment_method": inv_intra_line.payment_method,
+ "country_payment_id": inv_intra_line.country_payment_id.id,
+ }
+ )
+ return res
+
+ @api.model
+ def _prepare_export_line(self):
+ self.ensure_one()
+ self._export_line_checks(_("Sales"), self.get_section_number())
+
+ rcd = ""
+ # 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)
+ # Codice IVA del fornitore
+ rcd += format_x(self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(self.amount_euro, 13)
+ # Numero Fattura
+ rcd += format_x(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)
+ # Codice del servizio
+ rcd += format_9(self.intrastat_code_id.name, 6)
+ # Modalità di erogazione
+ rcd += format_x(self.supply_method, 1)
+ # Modalità di incasso
+ rcd += format_x(self.payment_method, 1)
+ # Codice del paese di pagamento
+ rcd += format_x(self.country_payment_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py
new file mode 100644
index 000000000000..9b03aaafd03a
--- /dev/null
+++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py
@@ -0,0 +1,125 @@
+# Copyright 2019 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+from odoo.exceptions import ValidationError
+
+from .intrastat_statement import format_9, format_x
+
+
+class IntrastatStatementSaleSection4(models.Model):
+ _inherit = "account.intrastat.statement.sale.section"
+ _name = "account.intrastat.statement.sale.section4"
+ _description = "Intrastat Statement - Sales Section 4"
+
+ intrastat_custom_id = fields.Many2one(
+ comodel_name="account.intrastat.custom", string="Customs Section"
+ )
+ month = fields.Integer(string="Ref. Month")
+ quarterly = fields.Integer(string="Ref. Quarter")
+ year_id = fields.Integer(string="Ref. Year")
+ protocol = fields.Integer(string="Protocol Number")
+ progressive_to_modify = fields.Integer(string="Progressive to Adjust")
+ invoice_number = fields.Char(string="Invoice Number")
+ invoice_date = fields.Date(string="Invoice Date")
+ supply_method = fields.Selection(
+ selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method"
+ )
+ payment_method = fields.Selection(
+ selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")],
+ string="Payment Method",
+ )
+ 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):
+ return 4
+
+ @api.model
+ def _prepare_statement_line(self, inv_intra_line, statement_id=None):
+ res = super(IntrastatStatementSaleSection4, self)._prepare_statement_line(
+ inv_intra_line, statement_id
+ )
+
+ # Period Ref
+ ref_period = statement_id._get_period_ref()
+
+ res.update(
+ {
+ "month": ref_period.get("month"),
+ "quarterly": ref_period.get("quarterly"),
+ "year_id": ref_period.get("year_id"),
+ "invoice_number": inv_intra_line.invoice_number,
+ "invoice_date": inv_intra_line.invoice_date,
+ "supply_method": inv_intra_line.supply_method,
+ "payment_method": inv_intra_line.payment_method,
+ "country_payment_id": inv_intra_line.country_payment_id.id,
+ "intrastat_custom_id": statement_id.intrastat_custom_id.id,
+ }
+ )
+ return res
+
+ def _export_line_checks(self, section_label, section_number):
+ super(IntrastatStatementSaleSection4, self)._export_line_checks(
+ section_label, section_number
+ )
+ if not self.year_id:
+ raise ValidationError(_("Missing reference year on 'Sales - Section 4'"))
+ if not self.intrastat_custom_id:
+ raise ValidationError(_("Missing customs section on 'Sales - Section 4'"))
+ if not self.protocol:
+ raise ValidationError(_("Missing protocol number on 'Sales - Section 4'"))
+ if not self.progressive_to_modify:
+ raise ValidationError(
+ _("Missing progressive to adjust on 'Sales - Section 4'")
+ )
+ 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
+ # dichiarazione da rettificare
+ rcd += format_9(self.intrastat_custom_id.code, 6)
+ # Anno di registrazione della dichiarazione da rettificare
+ year = (self.year_id or 0) % 100
+ rcd += format_9(year, 2)
+ # Protocollo della dichiarazione da rettificare
+ rcd += format_9(self.protocol, 6)
+ # Progressivo della sezione 3 da rettificare
+ 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(modifying and country_id.code, 2)
+ # Codice IVA dell’acquirente
+ rcd += format_x(modifying and self.vat_code.replace(" ", ""), 12)
+ # Ammontare delle operazioni in euro
+ rcd += format_9(modifying and self.amount_euro, 13)
+ # Numero Fattura
+ 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(modifying and invoice_date_ddmmyy, 6)
+ # Codice del servizio
+ rcd += format_9(modifying and self.intrastat_code_id.name, 6)
+ # Modalità di erogazione
+ rcd += format_x(modifying and self.supply_method, 1)
+ # Modalità di incasso
+ rcd += format_x(modifying and self.payment_method, 1)
+ # Codice del paese di pagamento
+ rcd += format_x(modifying and self.country_payment_id.code, 2)
+
+ rcd += "\r\n"
+ return rcd
diff --git a/l10n_it_invoices_data_communication/models/communication.py b/l10n_it_invoices_data_communication/models/communication.py
index 79c0e9677fc3..f91a2da79e57 100644
--- a/l10n_it_invoices_data_communication/models/communication.py
+++ b/l10n_it_invoices_data_communication/models/communication.py
@@ -803,85 +803,82 @@ def _check_errors_dte(self): # noqa
# ----- Normalizzazione delle stringhe
if not check_normalized_string(partner.cessionario_Denominazione):
errors.append(
- _(u"Remove empty characters around denomination of assignee " u"%s")
+ _("Remove empty characters around denomination of assignee " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_Nome):
errors.append(
- _(u"Remove empty characters around name of assignee " u"%s")
+ _("Remove empty characters around name of assignee " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_Cognome):
errors.append(
- _(u"Remove empty characters around surname of assignee " u"%s")
+ _("Remove empty characters around surname of assignee " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_sede_Indirizzo):
errors.append(
_(
- u"Remove empty characters around headquarters address of "
- u"assignee %s"
+ "Remove empty characters around headquarters address of "
+ "assignee %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_sede_NumeroCivico):
errors.append(
- _(
- u"Remove empty characters around street number of assignee"
- u" %s"
- )
+ _("Remove empty characters around street number of assignee" " %s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_sede_Comune):
errors.append(
- _(u"Remove empty characters around city of assignee " u"%s")
+ _("Remove empty characters around city of assignee " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_so_Indirizzo):
errors.append(
_(
- u"Remove empty characters around address of permanent "
- u"establishment %s"
+ "Remove empty characters around address of permanent "
+ "establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_so_NumeroCivico):
errors.append(
_(
- u"Remove empty characters around street number of "
- u"permanent establishment %s"
+ "Remove empty characters around street number of "
+ "permanent establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_so_Comune):
errors.append(
_(
- u"Remove empty characters around city of permanent "
- u"establishment %s"
+ "Remove empty characters around city of permanent "
+ "establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_rf_Denominazione):
errors.append(
_(
- u"Remove empty characters around denomination of fiscal "
- u"representative %s"
+ "Remove empty characters around denomination of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_rf_Nome):
errors.append(
_(
- u"Remove empty characters around name of fiscal "
- u"representative %s"
+ "Remove empty characters around name of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cessionario_rf_Cognome):
errors.append(
_(
- u"Remove empty characters around surname of fiscal "
- u"representative %s"
+ "Remove empty characters around surname of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
@@ -891,7 +888,7 @@ def _check_errors_dte(self): # noqa
and partner.cessionario_IdFiscaleIVA_IdCodice
):
errors.append(
- _(u"Define a country ID for assignee %s")
+ _("Define a country ID for assignee %s")
% partner.partner_id.display_name
)
# ----- Dati Sede
@@ -903,7 +900,7 @@ def _check_errors_dte(self): # noqa
]
):
errors.append(
- _(u"Address, city, country of %s are mandatory")
+ _("Address, city, country of %s are mandatory")
% partner.partner_id.display_name
)
# ----- Dati Stabile Organizzazione
@@ -926,9 +923,9 @@ def _check_errors_dte(self): # noqa
):
errors.append(
_(
- u"Address, city, ZIP and country of permanent "
- u"establishment %s are mandatory, when at least one value "
- u"is defined"
+ "Address, city, ZIP and country of permanent "
+ "establishment %s are mandatory, when at least one value "
+ "is defined"
)
% partner.partner_id.display_name
)
@@ -949,9 +946,9 @@ def _check_errors_dte(self): # noqa
):
errors.append(
_(
- u"Country ID and fiscal identifier of fiscal "
- u"representative %s are mandatory, when at least one "
- u"value is defined"
+ "Country ID and fiscal identifier of fiscal "
+ "representative %s are mandatory, when at least one "
+ "value is defined"
)
% partner.partner_id.display_name
)
@@ -960,14 +957,14 @@ def _check_errors_dte(self): # noqa
"[0-9]{5}", partner.cessionario_sede_Cap
):
errors.append(
- _(u"ZIP %s of assignee %s is not 5 numeric characters")
+ _("ZIP %s of assignee %s is not 5 numeric characters")
% (partner.cessionario_sede_Cap, partner.partner_id.display_name)
)
# ----- Dettagli IVA
for invoice in partner.fatture_emesse_body_ids:
if not invoice.dati_fattura_iva_ids:
errors.append(
- _(u"No VAT data defined for invoice %s of partner %s")
+ _("No VAT data defined for invoice %s of partner %s")
% (invoice.invoice_id.name, partner.partner_id.display_name)
)
return errors
@@ -1042,82 +1039,82 @@ def _check_errors_dtr(self): # noqa
# ----- Normalizzazione delle stringhe
if not check_normalized_string(partner.cedente_Denominazione):
errors.append(
- _(u"Remove empty characters around denomination of seller " u"%s")
+ _("Remove empty characters around denomination of seller " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_Nome):
errors.append(
- _(u"Remove empty characters around name of seller " u"%s")
+ _("Remove empty characters around name of seller " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_Cognome):
errors.append(
- _(u"Remove empty characters around surname of seller " u"%s")
+ _("Remove empty characters around surname of seller " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_sede_Indirizzo):
errors.append(
_(
- u"Remove empty characters around headquarters address of "
- u"seller %s"
+ "Remove empty characters around headquarters address of "
+ "seller %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_sede_NumeroCivico):
errors.append(
- _(u"Remove empty characters around street number of seller " u"%s")
+ _("Remove empty characters around street number of seller " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_sede_Comune):
errors.append(
- _(u"Remove empty characters around city of seller " u"%s")
+ _("Remove empty characters around city of seller " "%s")
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_so_Indirizzo):
errors.append(
_(
- u"Remove empty characters around address of permanent "
- u"establishment %s"
+ "Remove empty characters around address of permanent "
+ "establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_so_NumeroCivico):
errors.append(
_(
- u"Remove empty characters around street number of "
- u"permanent establishment %s"
+ "Remove empty characters around street number of "
+ "permanent establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_so_Comune):
errors.append(
_(
- u"Remove empty characters around city of permanent "
- u"establishment %s"
+ "Remove empty characters around city of permanent "
+ "establishment %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_rf_Denominazione):
errors.append(
_(
- u"Remove empty characters around denomination of fiscal "
- u"representative %s"
+ "Remove empty characters around denomination of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_rf_Nome):
errors.append(
_(
- u"Remove empty characters around name of fiscal "
- u"representative %s"
+ "Remove empty characters around name of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
if not check_normalized_string(partner.cedente_rf_Cognome):
errors.append(
_(
- u"Remove empty characters around surname of fiscal "
- u"representative %s"
+ "Remove empty characters around surname of fiscal "
+ "representative %s"
)
% partner.partner_id.display_name
)
@@ -1127,7 +1124,7 @@ def _check_errors_dtr(self): # noqa
and partner.cedente_IdFiscaleIVA_IdCodice
):
errors.append(
- _(u"Define a country ID for seller %s")
+ _("Define a country ID for seller %s")
% partner.partner_id.display_name
)
# ----- Dati Sede
@@ -1139,7 +1136,7 @@ def _check_errors_dtr(self): # noqa
]
):
errors.append(
- _(u"Address, city, country of %s are mandatory")
+ _("Address, city, country of %s are mandatory")
% partner.partner_id.display_name
)
# ----- Dati Stabile Organizzazione
@@ -1162,9 +1159,9 @@ def _check_errors_dtr(self): # noqa
):
errors.append(
_(
- u"Address, city, ZIP and country of permanent "
- u"establishment %s are mandatory, when at least one value "
- u"is defined"
+ "Address, city, ZIP and country of permanent "
+ "establishment %s are mandatory, when at least one value "
+ "is defined"
)
% partner.partner_id.display_name
)
@@ -1185,9 +1182,9 @@ def _check_errors_dtr(self): # noqa
):
errors.append(
_(
- u"Country ID and fiscal identifier of fiscal "
- u"representative %s are mandatory, when at least one "
- u"value is defined"
+ "Country ID and fiscal identifier of fiscal "
+ "representative %s are mandatory, when at least one "
+ "value is defined"
)
% partner.partner_id.display_name
)
@@ -1196,24 +1193,24 @@ def _check_errors_dtr(self): # noqa
"[0-9]{5}", partner.cedente_sede_Cap
):
errors.append(
- _(u"ZIP %s of seller %s is not 5 characters")
+ _("ZIP %s of seller %s is not 5 characters")
% (partner.cedente_sede_Cap, partner.partner_id.display_name)
)
# ----- Dettagli IVA
for invoice in partner.fatture_ricevute_body_ids:
if not invoice.dati_fattura_iva_ids:
errors.append(
- _(u"No VAT data defined for invoice %s of partner %s")
+ _("No VAT data defined for invoice %s of partner %s")
% (invoice.invoice_id.name, partner.partner_id.display_name)
)
if not invoice.dati_fattura_Numero:
errors.append(
- _(u"No invoice number for supplier bill %s")
+ _("No invoice number for supplier bill %s")
% (invoice.invoice_id.name)
)
if not invoice.dati_fattura_DataRegistrazione:
errors.append(
- _(u"No registration date for supplier bill %s")
+ _("No registration date for supplier bill %s")
% (invoice.invoice_id.name)
)
return errors
@@ -1227,11 +1224,11 @@ def check_errors(self):
errors += comunicazione._check_errors_dtr()
if not errors:
errors = [
- _(u"All data are correct.\nIt's possible to export " u"XML file")
+ _("All data are correct.\nIt's possible to export " "XML file")
]
else:
errors = [_("Errors:")] + errors
- comunicazione.errors = u"\n - ".join(errors)
+ comunicazione.errors = "\n - ".join(errors)
def _validate(self):
"""
diff --git a/l10n_it_rea/views/company_view.xml b/l10n_it_rea/views/company_view.xml
index be5c8cfce559..abad894af1db 100644
--- a/l10n_it_rea/views/company_view.xml
+++ b/l10n_it_rea/views/company_view.xml
@@ -17,7 +17,9 @@
-
+
+ 1
+
diff --git a/test-requirements.txt b/test-requirements.txt
index f2d48c11a915..a27bbd35bc0b 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,2 +1 @@
-openupgradelib @ git+https://github.com/OCA/openupgradelib.git@master
pdfminer.six # needed by attachment_indexation module