Skip to content

Commit

Permalink
[IMP] l10n_it_website_sale_fiscalcode: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
baba75 committed May 30, 2023
1 parent c9dab08 commit 11cd4ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 38 deletions.
28 changes: 12 additions & 16 deletions l10n_it_website_sale_fiscalcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
'name': 'Website Sale FiscalCode',
'category': 'e-commerce',
'author': "Agile Business Group,"
"Odoo Community Association (OCA)",
'version': '12.0.1.1.3',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/l10n-italy'
'/tree/12.0/l10n_it_website_sale_fiscalcode',
'depends': [
'website_sale',
'l10n_it_fiscalcode'
"name": "Website Sale FiscalCode",
"category": "e-commerce",
"author": "Agile Business Group," "Odoo Community Association (OCA)",
"version": "12.0.1.1.3",
"license": "AGPL-3",
"website": "https://github.com/OCA/l10n-italy"
"/tree/12.0/l10n_it_website_sale_fiscalcode",
"depends": ["website_sale", "l10n_it_fiscalcode"],
"data": [
"views/templates.xml",
],
'data': [
'views/templates.xml',
],
'installable': True,
'auto_install': True,
"installable": True,
"auto_install": True,
}
30 changes: 17 additions & 13 deletions l10n_it_website_sale_fiscalcode/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# Copyright 2017 Nicola Malcontenti - Agile Business Group

from odoo import _
from odoo.http import request

from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo import _


class WebsiteSaleFiscalCode(WebsiteSale):

def _checkout_form_save(self, mode, checkout, all_values):
res = super(WebsiteSaleFiscalCode, self)._checkout_form_save(
mode, checkout, all_values)
mode, checkout, all_values
)
partner_values = dict()
if 'fiscalcode' not in checkout and 'fiscalcode' in all_values:
partner_values['fiscalcode'] = all_values['fiscalcode']
if "fiscalcode" not in checkout and "fiscalcode" in all_values:
partner_values["fiscalcode"] = all_values["fiscalcode"]
if partner_values:
request.env['res.partner'].browse(res).sudo().write(partner_values)
request.env["res.partner"].browse(res).sudo().write(partner_values)
return res

def checkout_form_validate(self, mode, all_form_values, data):
error, error_message = super().checkout_form_validate(
mode, all_form_values, data)
mode, all_form_values, data
)
partner_sudo = request.env.user.partner_id.sudo()
dummy_partner = request.env['res.partner'].new({
'fiscalcode': data.get('fiscalcode'),
'is_company': partner_sudo.is_company
})
dummy_partner = request.env["res.partner"].new(
{
"fiscalcode": data.get("fiscalcode"),
"is_company": partner_sudo.is_company,
}
)
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
25 changes: 16 additions & 9 deletions l10n_it_website_sale_fiscalcode/views/templates.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Nicola Malcontenti - Agile Business Group
Copyright 2019 Simone Rubino -->

<odoo>
<template id="l10n_it_website_sale_fiscalcode" inherit_id="website_sale.address">
<xpath expr="//div[@id='div_phone']" position="after">
<t t-if="mode[1] == 'billing'">
<div class="clearfix"/>
<div t-attf-class="form-group #{error.get('fiscalcode') and 'o_has_error' or ''} col-lg-6"
id="div_fiscalcode">
<label class="col-form-label label-optional" for="fiscalcode">Fiscal Code</label>
<input type="text" name="fiscalcode"
t-attf-class="form-control #{error.get('fiscalcode') and 'is-invalid' or ''}"
t-att-value="'fiscalcode' in checkout and checkout['fiscalcode']"/>
<div class="clearfix" />
<div
t-attf-class="form-group #{error.get('fiscalcode') and 'o_has_error' or ''} col-lg-6"
id="div_fiscalcode"
>
<label
class="col-form-label label-optional"
for="fiscalcode"
>Fiscal Code</label>
<input
type="text"
name="fiscalcode"
t-attf-class="form-control #{error.get('fiscalcode') and 'is-invalid' or ''}"
t-att-value="'fiscalcode' in checkout and checkout['fiscalcode']"
/>
</div>
</t>
</xpath>
Expand Down
6 changes: 6 additions & 0 deletions setup/l10n_it_website_sale_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 11cd4ca

Please sign in to comment.