Skip to content

Commit

Permalink
[IMP] l10n_it_website_portal_fiscalcode: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso authored and TheMule71 committed Jul 20, 2021
1 parent 2c68b71 commit dfebb3f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 33 deletions.
13 changes: 4 additions & 9 deletions l10n_it_website_portal_fiscalcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
"version": "12.0.1.0.2",
"author": "Odoo Community Association (OCA)",
"category": "Localization/Italy",
"website": "https://github.com/OCA/l10n-italy/tree/"
"12.0/l10n_it_website_portal_fiscalcode",
"website": "https://github.com/OCA/l10n-italy"
"12.0/l10n_it_website_portal_fiscalcode",
"license": "AGPL-3",
"depends": [
"l10n_it_fiscalcode",
"portal"
],
"data": [
"views/l10n_it_website_portal_fiscalcode_templates.xml"
],
"depends": ["l10n_it_fiscalcode", "portal"],
"data": ["views/l10n_it_website_portal_fiscalcode_templates.xml"],
"auto_install": True,
}
33 changes: 18 additions & 15 deletions l10n_it_website_portal_fiscalcode/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
# 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'])
from odoo.addons.portal.controllers.portal import CustomerPortal

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)
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')
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':
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,
})
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'))
error["fiscalcode"] = "error"
error_message.append(_("Fiscal Code not valid"))
return error, error_message
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<template id="fiscalcode_details" name="Add fiscalcode" inherit_id="portal.portal_my_details">
<xpath expr="//div[hasclass('o_portal_details')]/div[1]/div[1]/div[7]" position="after">
<template
id="fiscalcode_details"
name="Add fiscalcode"
inherit_id="portal.portal_my_details"
>
<xpath
expr="//div[hasclass('o_portal_details')]/div[1]/div[1]/div[7]"
position="after"
>
<!-- After VAT -->
<div t-attf-class="form-group #{error.get('fiscalcode') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label label-optional" for="vat">Fiscal Code</label>
<input type="text" name="fiscalcode"
t-attf-class="form-control #{error.get('fiscalcode') and 'is-invalid' or ''}"
t-att-value="fiscalcode or partner.fiscalcode"
t-att-readonly="None if partner.can_edit_vat() else '1'"
t-att-title="None if partner.can_edit_vat() else 'Changing Fiscal Code is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.'" />
<div
t-attf-class="form-group #{error.get('fiscalcode') and 'o_has_error' or ''} col-xl-6"
>
<label
class="col-form-label label-optional"
for="vat"
>Fiscal Code</label>
<input
type="text"
name="fiscalcode"
t-attf-class="form-control #{error.get('fiscalcode') and 'is-invalid' or ''}"
t-att-value="fiscalcode or partner.fiscalcode"
t-att-readonly="None if partner.can_edit_vat() else '1'"
t-att-title="None if partner.can_edit_vat() else 'Changing Fiscal Code is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.'"
/>
</div>
</xpath>
</template>
Expand Down
6 changes: 6 additions & 0 deletions setup/l10n_it_website_portal_fiscalcode/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit dfebb3f

Please sign in to comment.