From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/l10n_ar_website_sale/__init__.py | 2 + addons/l10n_ar_website_sale/__manifest__.py | 24 +++++++ .../l10n_ar_website_sale/controllers/__init__.py | 2 + addons/l10n_ar_website_sale/controllers/main.py | 57 +++++++++++++++++ .../l10n_ar_website_sale/data/ir_model_fields.xml | 11 ++++ addons/l10n_ar_website_sale/demo/website_demo.xml | 23 +++++++ addons/l10n_ar_website_sale/i18n/es.po | 71 +++++++++++++++++++++ .../i18n/l10n_ar_website_sale.pot | 63 ++++++++++++++++++ .../static/description/icon.png | Bin 0 -> 1564 bytes addons/l10n_ar_website_sale/views/templates.xml | 63 ++++++++++++++++++ 10 files changed, 316 insertions(+) create mode 100644 addons/l10n_ar_website_sale/__init__.py create mode 100644 addons/l10n_ar_website_sale/__manifest__.py create mode 100644 addons/l10n_ar_website_sale/controllers/__init__.py create mode 100644 addons/l10n_ar_website_sale/controllers/main.py create mode 100644 addons/l10n_ar_website_sale/data/ir_model_fields.xml create mode 100644 addons/l10n_ar_website_sale/demo/website_demo.xml create mode 100644 addons/l10n_ar_website_sale/i18n/es.po create mode 100644 addons/l10n_ar_website_sale/i18n/l10n_ar_website_sale.pot create mode 100644 addons/l10n_ar_website_sale/static/description/icon.png create mode 100644 addons/l10n_ar_website_sale/views/templates.xml (limited to 'addons/l10n_ar_website_sale') diff --git a/addons/l10n_ar_website_sale/__init__.py b/addons/l10n_ar_website_sale/__init__.py new file mode 100644 index 00000000..2e55169e --- /dev/null +++ b/addons/l10n_ar_website_sale/__init__.py @@ -0,0 +1,2 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import controllers diff --git a/addons/l10n_ar_website_sale/__manifest__.py b/addons/l10n_ar_website_sale/__manifest__.py new file mode 100644 index 00000000..d4b8485b --- /dev/null +++ b/addons/l10n_ar_website_sale/__manifest__.py @@ -0,0 +1,24 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': 'Argentinean eCommerce', + 'version': '1.0', + 'category': 'Accounting/Localizations/Website', + 'sequence': 14, + 'author': 'Odoo, ADHOC SA', + 'description': """Be able to see Identification Type and AFIP Responsibility in ecommerce checkout form.""", + 'depends': [ + 'website_sale', + 'l10n_ar', + ], + 'data': [ + 'data/ir_model_fields.xml', + 'views/templates.xml', + ], + 'demo': [ + 'demo/website_demo.xml', + ], + 'installable': True, + 'auto_install': True, + 'application': False, + 'license': 'LGPL-3', +} diff --git a/addons/l10n_ar_website_sale/controllers/__init__.py b/addons/l10n_ar_website_sale/controllers/__init__.py new file mode 100644 index 00000000..9a57ed53 --- /dev/null +++ b/addons/l10n_ar_website_sale/controllers/__init__.py @@ -0,0 +1,2 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import main diff --git a/addons/l10n_ar_website_sale/controllers/main.py b/addons/l10n_ar_website_sale/controllers/main.py new file mode 100644 index 00000000..053a8a50 --- /dev/null +++ b/addons/l10n_ar_website_sale/controllers/main.py @@ -0,0 +1,57 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import _ +from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.http import request, route + + +class L10nARWebsiteSale(WebsiteSale): + + def _get_mandatory_fields_billing(self, country_id=False): + """Extend mandatory fields to add new identification and responsibility fields when company is argentina""" + res = super()._get_mandatory_fields_billing(country_id) + if request.website.sudo().company_id.country_id.code == "AR": + res += ["l10n_latam_identification_type_id", "l10n_ar_afip_responsibility_type_id", "vat"] + return res + + def _get_country_related_render_values(self, kw, render_values): + res = super()._get_country_related_render_values(kw, render_values) + if request.website.sudo().company_id.country_id.code == "AR": + res.update({'identification': kw.get('l10n_latam_identification_type_id'), + 'responsibility': kw.get('l10n_ar_afip_responsibility_type_id'), + 'responsibility_types': request.env['l10n_ar.afip.responsibility.type'].search([]), + 'identification_types': request.env['l10n_latam.identification.type'].search( + ['|', ('country_id', '=', False), ('country_id.code', '=', 'AR')])}) + return res + + def _get_vat_validation_fields(self, data): + res = super()._get_vat_validation_fields(data) + if request.website.sudo().company_id.country_id.code == "AR": + res.update({'l10n_latam_identification_type_id': int(data['l10n_latam_identification_type_id']) + if data.get('l10n_latam_identification_type_id') else False}) + res.update({'name': data['name'] if data.get('name') else False}) + return res + + def checkout_form_validate(self, mode, all_form_values, data): + """ We extend the method to add a new validation. If AFIP Resposibility is: + + * Final Consumer or Foreign Customer: then it can select any identification type. + * Any other (Monotributista, RI, etc): should select always "CUIT" identification type""" + error, error_message = super().checkout_form_validate(mode, all_form_values, data) + + # Identification type and AFIP Responsibility Combination + if request.website.sudo().company_id.country_id.code == "AR": + if mode[1] == 'billing': + id_type_id = data.get("l10n_latam_identification_type_id") + afip_resp_id = data.get("l10n_ar_afip_responsibility_type_id") + + id_type = request.env['l10n_latam.identification.type'].browse(id_type_id) if id_type_id else False + afip_resp = request.env['l10n_ar.afip.responsibility.type'].browse(afip_resp_id) if afip_resp_id else False + cuit_id_type = request.env.ref('l10n_ar.it_cuit') + + # Check if the AFIP responsibility is different from Final Consumer or Foreign Customer, + # and if the identification type is different from CUIT + if afip_resp.code not in ['5', '9'] and id_type != cuit_id_type: + error["l10n_latam_identification_type_id"] = 'error' + error_message.append(_('For the selected AFIP Responsibility you will need to set CUIT Identification Type')) + + return error, error_message diff --git a/addons/l10n_ar_website_sale/data/ir_model_fields.xml b/addons/l10n_ar_website_sale/data/ir_model_fields.xml new file mode 100644 index 00000000..fa73c004 --- /dev/null +++ b/addons/l10n_ar_website_sale/data/ir_model_fields.xml @@ -0,0 +1,11 @@ + + + + + res.partner + + + + diff --git a/addons/l10n_ar_website_sale/demo/website_demo.xml b/addons/l10n_ar_website_sale/demo/website_demo.xml new file mode 100644 index 00000000..6f3e42d9 --- /dev/null +++ b/addons/l10n_ar_website_sale/demo/website_demo.xml @@ -0,0 +1,23 @@ + + + + + (AR) Responsable Inscripto Website + + + + + + + + + + + + + + + + + + diff --git a/addons/l10n_ar_website_sale/i18n/es.po b/addons/l10n_ar_website_sale/i18n/es.po new file mode 100644 index 00000000..786d7be0 --- /dev/null +++ b/addons/l10n_ar_website_sale/i18n/es.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ar_website_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-07-24 21:56+0000\n" +"PO-Revision-Date: 2020-07-24 21:56+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "AFIP Responsibility" +msgstr "Responsabilidad AFIP" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "AFIP Responsibility..." +msgstr "Responsabilidad AFIP..." + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "" +"Changing AFIP Responsibility type is not allowed once document(s) have been " +"issued for your account. Please contact us directly for this operation." +msgstr "" +"Cambiar el tipo de Responsabilidad AFIP no esta permitido una vez que hayan " +"factura(s) emitadas a tu cuenta. Por favor contactenos directamente para " +"esta operación." + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "" +"Changing Identification type is not allowed once document(s) have been " +"issued for your account. Please contact us directly for this operation." +msgstr "" +"Cambiar el Tipo de Identificación no esta permitido una vez que hayan " +"factura(s) emitadas a tu cuenta. Por favor contactenos directamente para " +"esta operación." + +#. module: l10n_ar_website_sale +#: code:addons/l10n_ar_website_sale/controllers/main.py:0 +#, python-format +msgid "" +"For the selected AFIP Responsibility you will need to set CUIT " +"Identification Type" +msgstr "" +"Para la Responsabilidad AFIP seleccionada debes seleccionar el tipo de " +"identificación CUIT" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "Identification Type" +msgstr "Tipo de Identificación" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "Identification Type..." +msgstr "Tipo de Identificación" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.address_b2b +msgid "Number" +msgstr "Número" diff --git a/addons/l10n_ar_website_sale/i18n/l10n_ar_website_sale.pot b/addons/l10n_ar_website_sale/i18n/l10n_ar_website_sale.pot new file mode 100644 index 00000000..3f8fe1a1 --- /dev/null +++ b/addons/l10n_ar_website_sale/i18n/l10n_ar_website_sale.pot @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ar_website_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-07-24 21:55+0000\n" +"PO-Revision-Date: 2020-07-24 21:55+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "AFIP Responsibility" +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "AFIP Responsibility..." +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "" +"Changing AFIP Responsibility type is not allowed once document(s) have been " +"issued for your account. Please contact us directly for this operation." +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "" +"Changing Identification type is not allowed once document(s) have been " +"issued for your account. Please contact us directly for this operation." +msgstr "" + +#. module: l10n_ar_website_sale +#: code:addons/l10n_ar_website_sale/controllers/main.py:0 +#, python-format +msgid "" +"For the selected AFIP Responsibility you will need to set CUIT " +"Identification Type" +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "Identification Type" +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.partner_info +msgid "Identification Type..." +msgstr "" + +#. module: l10n_ar_website_sale +#: model_terms:ir.ui.view,arch_db:l10n_ar_website_sale.address_b2b +msgid "Number" +msgstr "" diff --git a/addons/l10n_ar_website_sale/static/description/icon.png b/addons/l10n_ar_website_sale/static/description/icon.png new file mode 100644 index 00000000..bc3bad4f Binary files /dev/null and b/addons/l10n_ar_website_sale/static/description/icon.png differ diff --git a/addons/l10n_ar_website_sale/views/templates.xml b/addons/l10n_ar_website_sale/views/templates.xml new file mode 100644 index 00000000..42aef89d --- /dev/null +++ b/addons/l10n_ar_website_sale/views/templates.xml @@ -0,0 +1,63 @@ + + + + + + + + -- cgit v1.2.3