Skip to content

Commit 29fa43a

Browse files
committed
[IMP]l10n_it_edi_extension: flag for create partner
1 parent e34195b commit 29fa43a

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

l10n_it_edi_extension/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"data/res.city.it.code.csv",
2727
"views/l10n_it_view.xml",
2828
"views/res_partner_view.xml",
29+
"views/company_view.xml",
2930
"wizards/compute_fc_view.xml",
3031
"wizards/l10n_it_edi_import_file_wizard.xml",
3132
],

l10n_it_edi_extension/models/account_move.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,11 @@ def _l10n_it_edi_extension_create_partner(self, invoice_data):
771771

772772
def _l10n_it_edi_import_invoice(self, invoice, data, is_new):
773773
invoice = super()._l10n_it_edi_import_invoice(invoice, data, is_new)
774-
if invoice and not invoice.partner_id:
774+
if (
775+
invoice
776+
and not invoice.partner_id
777+
and self.env.company.l10n_edi_it_create_partner
778+
):
775779
partner = self._l10n_it_edi_extension_create_partner(data)
776780
invoice.partner_id = partner
777781
return invoice

l10n_it_edi_extension/models/res_company.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,20 @@ class ResCompanyInherit(models.Model):
2828
help="The fields must be entered only when the seller/provider is "
2929
"non-resident, with a stable organization in Italy",
3030
)
31+
l10n_edi_it_create_partner = fields.Boolean(
32+
string="Create Partner on Eletronic Invoice import",
33+
help="Automatically create the partner if it does not "
34+
"exist during the import of Electronic Invoices.",
35+
)
36+
37+
38+
class AccountConfigSettings(models.TransientModel):
39+
_inherit = "res.config.settings"
40+
41+
l10n_edi_it_create_partner = fields.Boolean(
42+
related="company_id.l10n_edi_it_create_partner",
43+
string="Create Partner on Eletronic Invoice import",
44+
help="Automatically create the partner if it does not "
45+
"exist during the import of Electronic Invoices.",
46+
readonly=False,
47+
)

l10n_it_edi_extension/static/description/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
1716
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -589,9 +588,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
589588
<div class="section" id="maintainers">
590589
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
591590
<p>This module is maintained by the OCA.</p>
592-
<a class="reference external image-reference" href="https://odoo-community.org">
593-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
594-
</a>
591+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
595592
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
596593
mission is to support the collaborative development of Odoo features and
597594
promote its widespread use.</p>

l10n_it_edi_extension/tests/test_import_edi_extension_xml.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class TestFatturaPAXMLValidation(TestItEdi):
1515
def setUpClass(cls):
1616
super().setUpClass()
1717
cls.module = "l10n_it_edi_extension"
18+
cls.env.company.l10n_edi_it_create_partner = True
1819

1920
def _edi_import_invoice(self, filename):
2021
moves = self.env["account.move"]
@@ -239,3 +240,23 @@ def test_create_partner(self):
239240
# Assert
240241
partner = invoice.partner_id
241242
self.assertEqual(partner.name, partner_name)
243+
244+
def test_avoid_create_partner(self):
245+
"""Partner is not created during import if the setting is disabled."""
246+
self.env.company.l10n_edi_it_create_partner = False
247+
partner_name = "SOCIETA' BETA SRL"
248+
# pre-condition
249+
partner = self.env["res.partner"].search(
250+
[
251+
("name", "=", partner_name),
252+
],
253+
limit=1,
254+
)
255+
self.assertFalse(partner)
256+
257+
# Act
258+
invoice = self._assert_import_invoice("IT02780790107_11004.xml", [{}])
259+
260+
# Assert
261+
partner = invoice.partner_id
262+
self.assertFalse(partner)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record model="ir.ui.view" id="view_account_config_settings_create_partner">
4+
<field name="name">view_account_config_settings_create_partner</field>
5+
<field name="model">res.config.settings</field>
6+
<field name="inherit_id" ref="l10n_it_edi.res_config_settings_view_form" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//setting[@id='italian_edi']" position="inside">
9+
<field name="l10n_edi_it_create_partner" />
10+
</xpath>
11+
</field>
12+
</record>
13+
</odoo>

0 commit comments

Comments
 (0)