<commit_before># Copyright 2019 <NAME>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _
from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.http import request

CustomerPortal.OPTIONAL_BILLING_FIELDS.extend(['fiscalcode'])


class WebsitePortalFiscalCode(CustomerPortal):

    def details_form_validate(self, data):
        error, error_message = \
            super(WebsitePortalFiscalCode, self).details_form_validate(data)
        # Check fiscalcode
        dummy_partner = request.env['res.partner'].new({
            'fiscalcode': data.get('fiscalcode'),
            'company_name': data.get('company_name'),
        })
        if not dummy_partner.check_fiscalcode():
            error['fiscalcode'] = 'error'
            error_message.append(_('Fiscal Code not valid'))
        return error, error_message<commit_msg>FIX l10n_it_website_portal_fiscalcode check after invoice issuing<commit_after># Copyright 2019 <NAME>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _
from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.http import request

CustomerPortal.OPTIONAL_BILLING_FIELDS.extend(['fiscalcode'])


class WebsitePortalFiscalCode(CustomerPortal):

    def details_form_validate(self, data):
        error, error_message = \
            super(WebsitePortalFiscalCode, self).details_form_validate(data)
        # Check fiscalcode
        partner = request.env.user.partner_id
        # company_type does not come from page form
        company_type = partner.company_type
        company_name = False
        if 'company_name' in data:
            company_name = data.get('company_name')
        else:
            # when company_name is not posted (readonly)
            if partner.company_name:
                company_name = partner.company_name
            elif partner.company_type == 'company':
                company_name = partner.name
        dummy_partner = request.env['res.partner'].new({
            'fiscalcode': data.get('fiscalcode'),
            'company_name': company_name,
            'company_type': company_type,
        })
        if not dummy_partner.check_fiscalcode():
            error['fiscalcode'] = 'error'
            error_message.append(_('Fiscal Code not valid'))
        return error, error_message
{'fraction_non_alphanumeric': 0.09652836579170194, 'fraction_numerical': 0.0059271803556308214, 'mean_word_length': 2.951505016722408, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7386988', 'n_tokens_mistral': 714, 'n_tokens_neox': 700, 'n_words': 141}