diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_ar_website_sale | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/l10n_ar_website_sale')
| -rw-r--r-- | addons/l10n_ar_website_sale/__init__.py | 2 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/__manifest__.py | 24 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/controllers/__init__.py | 2 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/controllers/main.py | 57 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/data/ir_model_fields.xml | 11 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/demo/website_demo.xml | 23 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/i18n/es.po | 71 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/i18n/l10n_ar_website_sale.pot | 63 | ||||
| -rw-r--r-- | addons/l10n_ar_website_sale/static/description/icon.png | bin | 0 -> 1564 bytes | |||
| -rw-r--r-- | addons/l10n_ar_website_sale/views/templates.xml | 63 |
10 files changed, 316 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <function model="ir.model.fields" name="formbuilder_whitelist"> + <value>res.partner</value> + <value eval="[ + 'l10n_ar_afip_responsibility_type_id', 'l10n_latam_identification_type_id', + ]"/> + </function> + +</odoo> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo noupdate="1"> + + <record id="default_website_ri" model="website"> + <field name="name">(AR) Responsable Inscripto Website</field> + <field name="company_id" ref="l10n_ar.company_ri"/> + <field name="logo" type="base64" file="l10n_ar_website_sale/static/description/icon.png"/> + <field name="domain" model="ir.config_parameter" eval="obj().env['ir.config_parameter'].sudo().get_param('web.base.url')"/> + </record> + <function model="payment.acquirer" name="copy"> + <value eval="[ref('payment.payment_acquirer_transfer')]"/> + <value eval="{'company_id': ref('l10n_ar.company_ri'), 'state': 'enabled'}"/> + </function> + <function model="product.pricelist" name="write"> + <value model="product.pricelist" eval="obj().search([('currency_id', '=', ref('base.ARS'))], limit=1).id"/> + <value model="website" eval="{'sequence': 1, 'website_id': ref('l10n_ar_website_sale.default_website_ri')}"/> + </function> + <function model="product.product" name="write"> + <value model="product.product" eval="obj().search([('taxes_id', '=', False)]).ids"/> + <value model="account.tax" eval="{'taxes_id': [(4, obj().search([('type_tax_use', '=', 'sale'), ('tax_group_id', '=', ref('l10n_ar.tax_group_iva_21')), ('company_id', '=', ref('l10n_ar.company_ri'))]).id)]}"/> + </function> + +</odoo> 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 Binary files differnew file mode 100644 index 00000000..bc3bad4f --- /dev/null +++ b/addons/l10n_ar_website_sale/static/description/icon.png 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <template id="partner_info" name="Argentinean partner"> + + <!-- show afip responsibility --> + <div t-attf-class="form-group #{error.get('l10n_ar_afip_responsibility_type_id') and 'o_has_error' or ''} col-xl-6"> + <label class="col-form-label" for="l10n_ar_afip_responsibility_type_id">AFIP Responsibility</label> + <t t-if="partner.can_edit_vat()"> + <select name="l10n_ar_afip_responsibility_type_id" t-attf-class="form-control #{error.get('l10n_ar_afip_responsibility_type_id') and 'is-invalid' or ''}"> + <option value="">AFIP Responsibility...</option> + <t t-foreach="responsibility_types or []" t-as="resp_type"> + <option t-att-value="resp_type.id" t-att-selected="resp_type.id == int(responsibility) if responsibility else resp_type.id == partner.l10n_ar_afip_responsibility_type_id.id"> + <t t-esc="resp_type.name"/> + </option> + </t> + </select> + </t> + <t t-else=""> + <p class="form-control" t-esc="partner.l10n_ar_afip_responsibility_type_id.name" readonly="1" title="Changing AFIP Responsibility type is not allowed once document(s) have been issued for your account. Please contact us directly for this operation."/> + <input name="l10n_ar_afip_responsibility_type_id" class="form-control" t-att-value="partner.l10n_ar_afip_responsibility_type_id.id" type='hidden'/> + </t> + </div> + + <!-- show identification type --> + <div t-attf-class="form-group #{error.get('l10n_latam_identification_type_id') and 'o_has_error' or ''} col-xl-6"> + <label class="col-form-label" for="l10n_latam_identification_type_id">Identification Type</label> + <t t-if="partner.can_edit_vat()"> + <select name="l10n_latam_identification_type_id" t-attf-class="form-control #{error.get('l10n_latam_identification_type_id') and 'is-invalid' or ''}"> + <option value="">Identification Type...</option> + <t t-foreach="identification_types or []" t-as="id_type"> + <option t-att-value="id_type.id" t-att-selected="id_type.id == int(identification) if identification else id_type.id == partner.l10n_latam_identification_type_id.id"> + <t t-esc="id_type.name"/> + </option> + </t> + </select> + </t> + <t t-else=""> + <p class="form-control" t-esc="partner.l10n_latam_identification_type_id.name" readonly="1" title="Changing Identification type is not allowed once document(s) have been issued for your account. Please contact us directly for this operation."/> + <input name="l10n_latam_identification_type_id" class="form-control" t-att-value="partner.l10n_latam_identification_type_id.id" type='hidden'/> + </t> + </div> + + </template> + + <template id="address_b2b" inherit_id="website_sale.address_b2b"> + <xpath expr="//input[@name='vat']/.." position="before"> + <t t-if="mode[1] == 'billing'" positon="inside"> + <t t-if="res_company.country_id.code == 'AR'"> + <t t-set="partner" t-value="website_sale_order.partner_id"/> + <t t-call="l10n_ar_website_sale.partner_info"/> + </t> + </t> + </xpath> + <label for="vat" position="attributes"> + <attribute name="t-if">res_company.country_id.code != 'AR'</attribute> + </label> + <label for="vat" position="after"> + <label t-if="res_company.country_id.code == 'AR'" class="col-form-label label-optional" for="vat">Number</label> + </label> + </template> + +</odoo> |
