diff --git a/addons/l10n_it_edi_website_sale/__init__.py b/addons/l10n_it_edi_website_sale/__init__.py new file mode 100644 index 00000000000..dd15b5c32e5 --- /dev/null +++ b/addons/l10n_it_edi_website_sale/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import controllers diff --git a/addons/l10n_it_edi_website_sale/__manifest__.py b/addons/l10n_it_edi_website_sale/__manifest__.py new file mode 100644 index 00000000000..28ee139c5cb --- /dev/null +++ b/addons/l10n_it_edi_website_sale/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': "Italy eCommerce eInvoicing", + 'version': "1.0", + 'category': 'Accounting/Localizations/Website', + 'summary': "Features for Italian eCommerce eInvoicing", + 'description': """ +Contains features for Italian eCommerce eInvoicing + """, + 'depends': ['l10n_it_edi', 'website_sale'], + 'data': [ + 'views/templates.xml', + 'data/data.xml' + ], + 'installable': True, + 'auto_install': True, + 'license': 'OEEL-1', + 'assets': { + 'web.assets_tests': [ + 'l10n_it_edi_website_sale/static/tests/**/*', + ], + }, +} diff --git a/addons/l10n_it_edi_website_sale/controllers/__init__.py b/addons/l10n_it_edi_website_sale/controllers/__init__.py new file mode 100644 index 00000000000..5d4b25db9c0 --- /dev/null +++ b/addons/l10n_it_edi_website_sale/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import main diff --git a/addons/l10n_it_edi_website_sale/controllers/main.py b/addons/l10n_it_edi_website_sale/controllers/main.py new file mode 100644 index 00000000000..e801b3d7e1b --- /dev/null +++ b/addons/l10n_it_edi_website_sale/controllers/main.py @@ -0,0 +1,26 @@ +# -*- coding:utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.http import request +from odoo.exceptions import UserError +from odoo import _ + +class ItalyWebsiteSaleForm(WebsiteSale): + def checkout_form_validate(self, mode, all_form_values, data): + error, error_message = super().checkout_form_validate(mode, all_form_values, data) + Partner = request.env['res.partner'] + if data.get('l10n_it_codice_fiscale'): + partner_dummy = Partner.new({ + 'l10n_it_codice_fiscale': data.get('l10n_it_codice_fiscale') + }) + try: + partner_dummy.validate_codice_fiscale() + except UserError as e: + error['l10n_it_codice_fiscale'] = 'error' + error_message.append(e.name) + pa_index = data.get('l10n_it_pa_index') + if pa_index: + if len(pa_index) < 6 or len(pa_index) > 7: + error['l10n_it_pa_index'] = 'error' + error_message.append(_('PA index must have between 6 and 7 characters')) + return error, error_message diff --git a/addons/l10n_it_edi_website_sale/data/data.xml b/addons/l10n_it_edi_website_sale/data/data.xml new file mode 100644 index 00000000000..cbd6bb5f63c --- /dev/null +++ b/addons/l10n_it_edi_website_sale/data/data.xml @@ -0,0 +1,12 @@ + + + + + res.partner + + + + diff --git a/addons/l10n_it_edi_website_sale/static/tests/tours/website_sale_checkout_address.js b/addons/l10n_it_edi_website_sale/static/tests/tours/website_sale_checkout_address.js new file mode 100644 index 00000000000..6ac5b91c05a --- /dev/null +++ b/addons/l10n_it_edi_website_sale/static/tests/tours/website_sale_checkout_address.js @@ -0,0 +1,45 @@ +/** @odoo-module alias=l10n_it_edi_website_sale.tour **/ + +import { registry } from "@web/core/registry"; +import tourUtils from "@website_sale/js/tours/tour_utils"; + +registry.category("web_tour.tours").add('shop_checkout_address', { + test: true, + url: '/shop', + steps: () => [ + { + content: "search Storage Box", + trigger: 'form input[name="search"]', + run: "text Storage Box", + }, + { + content: "search Storage Box", + trigger: 'form:has(input[name="search"]) .oe_search_button', + }, + { + content: "select Storage Box", + trigger: '.oe_product_cart:first a:contains("Storage Box")', + }, + { + id: 'add_cart_step', + content: "click on add to cart", + trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', + }, + tourUtils.goToCart(), + { + content: "go to address form", + trigger: 'a[href="/shop/checkout?express=1"]', + }, + // check if the fields Codice Fiscale and PA index are present + { + content: "check if the fields Codice Destinatario is present", + trigger: 'input[name="l10n_it_pa_index"]', + run: "text 1234567890123456789012345", + }, + { + content: "check if the fields Codice Fiscale is present", + trigger: 'input[name="l10n_it_codice_fiscale"]', + run: "text 12345678901", + }, + ] +}); diff --git a/addons/l10n_it_edi_website_sale/tests/__init__.py b/addons/l10n_it_edi_website_sale/tests/__init__.py new file mode 100644 index 00000000000..1f14fd6893b --- /dev/null +++ b/addons/l10n_it_edi_website_sale/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_l10n_it_edi_website_sale diff --git a/addons/l10n_it_edi_website_sale/tests/test_l10n_it_edi_website_sale.py b/addons/l10n_it_edi_website_sale/tests/test_l10n_it_edi_website_sale.py new file mode 100644 index 00000000000..d508c93f9c8 --- /dev/null +++ b/addons/l10n_it_edi_website_sale/tests/test_l10n_it_edi_website_sale.py @@ -0,0 +1,19 @@ +from odoo.tests.common import HttpCase, tagged + + +@tagged('post_install_l10n', 'post_install', '-at_install') +class TestUi(HttpCase): + def setUp(self): + super(TestUi, self).setUp() + self.env['product.product'].create({ + 'name': 'Storage Box', + 'standard_price': 70.0, + 'list_price': 79.0, + 'website_published': True, + }) + + def test_checkout_address(self): + # set current company's fiscal country to italy + website = self.env['website'].get_current_website() + website.company_id.account_fiscal_country_id = website.company_id.country_id = self.env.ref('base.it') + self.start_tour("/", 'shop_checkout_address') diff --git a/addons/l10n_it_edi_website_sale/views/templates.xml b/addons/l10n_it_edi_website_sale/views/templates.xml new file mode 100644 index 00000000000..6c81e64b3e3 --- /dev/null +++ b/addons/l10n_it_edi_website_sale/views/templates.xml @@ -0,0 +1,20 @@ + + + + + +