[ADD] l10n_ar_pos: new module

closes odoo/odoo#133881

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Katherine Zaoral
2023-09-12 22:12:54 +00:00
committed by Juan José Scarafia
parent c93a57ccab
commit 0a41d64d18
12 changed files with 249 additions and 3 deletions
+2
View File
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
+27
View File
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Argentinean - Point of Sale with AR Doc',
'version': '1.0',
'category': 'Accounting/Localizations/Point of Sale',
'description': """
This module brings the technical requirement for the Argentinean regulation.
Install this if you are using the Point of Sale app in Argentina.
""",
'depends': [
'l10n_ar',
'point_of_sale',
],
'countries': ['ar'],
'data': [
'views/templates.xml',
],
'assets': {
'point_of_sale._assets_pos': [
'l10n_ar_pos/static/src/**/*'
],
},
'installable': True,
'auto_install': True,
'license': 'LGPL-3',
}
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_session
from . import res_partner
+42
View File
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
from odoo import api, models
class PosSession(models.Model):
_inherit = 'pos.session'
@api.model
def _pos_ui_models_to_load(self):
res = super()._pos_ui_models_to_load()
if self.company_id.country_code == 'AR':
res += ['l10n_ar.afip.responsibility.type', 'l10n_latam.identification.type']
return res
def _loader_params_res_partner(self):
vals = super()._loader_params_res_partner()
if self.company_id.country_code == 'AR':
vals['search_params']['fields'] += ['l10n_ar_afip_responsibility_type_id', 'l10n_latam_identification_type_id']
return vals
def _pos_data_process(self, loaded_data):
super()._pos_data_process(loaded_data)
if self.company_id.country_code == 'AR':
loaded_data['consumidor_final_anonimo_id'] = self.env.ref('l10n_ar.par_cfa').id
def _get_pos_ui_l10n_ar_afip_responsibility_type(self, params):
return self.env['l10n_ar.afip.responsibility.type'].search_read(**params['search_params'])
def _loader_params_l10n_ar_afip_responsibility_type(self):
return {'search_params': {'domain': [], 'fields': ['name']}}
def _get_pos_ui_l10n_latam_identification_type(self, params):
return self.env['l10n_latam.identification.type'].search_read(**params['search_params'])
def _loader_params_l10n_latam_identification_type(self):
""" filter only identification types used in Argentina"""
return {
'search_params': {
'domain': [('l10n_ar_afip_code', '!=', False), ('active', '=', True)],
'fields': ['name']},
}
+15
View File
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from odoo import models, api, _
from odoo.exceptions import UserError
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.ondelete(at_uninstall=False)
def _ar_unlink_except_master_data(self):
consumidor_final_anonimo = self.env.ref('l10n_ar.par_cfa').id
for partner in self.ids:
if partner == consumidor_final_anonimo:
raise UserError(_('Deleting this partner is not allowed.'))
@@ -0,0 +1,20 @@
/** @odoo-module */
import { PartnerDetailsEdit } from "@point_of_sale/app/screens/partner_list/partner_editor/partner_editor";
import { patch } from "@web/core/utils/patch";
patch(PartnerDetailsEdit.prototype, {
setup(){
super.setup(...arguments);
if (this.pos.isArgentineanCompany()) {
this.intFields.push("l10n_ar_afip_responsibility_type_id");
this.intFields.push("l10n_latam_identification_type_id");
this.changes.l10n_ar_afip_responsibility_type_id =
this.props.partner.l10n_ar_afip_responsibility_type_id &&
this.props.partner.l10n_ar_afip_responsibility_type_id[0];
this.changes.l10n_latam_identification_type_id =
this.props.partner.l10n_latam_identification_type_id &&
this.props.partner.l10n_latam_identification_type_id[0];
}
},
});
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="PartnerDetailsEdit" t-inherit="point_of_sale.PartnerDetailsEdit" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('partner-details-box')]" position="inside">
<t t-if="pos.isArgentineanCompany()">
<div class="partner-detail col">
<label class="form-label" for="art">AFIP Responsibility</label>
<select class="detail form-select" name="l10n_ar_afip_responsibility_type_id" id="art"
t-model="changes.l10n_ar_afip_responsibility_type_id">
<t t-foreach="pos.l10n_ar_afip_responsibility_types" t-as="afip_responsibility" t-key="afip_responsibility.id">
<option t-att-value="afip_responsibility.id">
<t t-esc="afip_responsibility.name" />
</option>
</t>
</select>
</div>
<div class="partner-detail col">
<label class="form-label" for="id_type">Identification Type</label>
<select class="detail form-select" name="l10n_latam_identification_type_id" id="id_type"
t-model="changes.l10n_latam_identification_type_id">
<t t-foreach="pos.l10n_latam_identification_types" t-as="l10n_latam_identification_type" t-key="l10n_latam_identification_type.id">
<option t-att-value="l10n_latam_identification_type.id">
<t t-esc="l10n_latam_identification_type.name" />
</option>
</t>
</select>
</div>
</t>
</xpath>
</t>
</templates>
@@ -0,0 +1,20 @@
/** @odoo-module */
import { PartnerListScreen } from "@point_of_sale/app/screens/partner_list/partner_list";
import { patch } from "@web/core/utils/patch";
patch(PartnerListScreen.prototype, {
createPartner() {
super.createPartner(...arguments);
if (this.pos.isArgentineanCompany()) {
this.state.editModeProps.partner.l10n_latam_identification_type_id = [
this.pos.l10n_latam_identification_types[0].id,
this.pos.l10n_latam_identification_types[0].name,
];
this.state.editModeProps.partner.l10n_ar_afip_responsibility_type_id = [
this.pos.l10n_ar_afip_responsibility_types[0].id,
this.pos.l10n_ar_afip_responsibility_types[0].name,
];
}
},
});
@@ -0,0 +1,20 @@
/** @odoo-module */
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
import { patch } from "@web/core/utils/patch";
patch(TicketScreen.prototype, {
setPartnerToRefundOrder(partner, destinationOrder) {
if (this.pos.isArgentineanCompany()) {
if (
partner &&
(!destinationOrder.get_partner() ||
destinationOrder.get_partner().id === this.pos.consumidorFinalAnonimoId)
) {
destinationOrder.set_partner(partner);
}
} else {
super.setPartnerToRefundOrder(...arguments);
}
},
});
@@ -0,0 +1,31 @@
/** @odoo-module */
import { PosStore } from "@point_of_sale/app/store/pos_store";
import { Order } from "@point_of_sale/app/store/models";
import { patch } from "@web/core/utils/patch";
patch(PosStore.prototype, {
// @Override
async _processData(loadedData) {
await super._processData(...arguments);
if (this.isArgentineanCompany()) {
this.l10n_ar_afip_responsibility_types = loadedData["l10n_ar.afip.responsibility.type"];
this.l10n_latam_identification_types = loadedData["l10n_latam.identification.type"];
this.consumidorFinalAnonimoId = loadedData["consumidor_final_anonimo_id"];
}
},
isArgentineanCompany() {
return this.company.country?.code == "AR";
},
});
patch(Order.prototype, {
setup() {
super.setup(...arguments);
if (this.pos.isArgentineanCompany()) {
if (!this.partner) {
this.partner = this.pos.db.partner_by_id[this.pos.consumidorFinalAnonimoId];
}
}
},
});
+31
View File
@@ -0,0 +1,31 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<template id="ticket_validation_screen" inherit_id="point_of_sale.ticket_validation_screen">
<!-- We do not let the user create the invoice by then self. That is why we hide the "Get my Invoice" button -->
<xpath expr="//div[@id='get_my_invoice']" position="attributes">
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute>
</xpath>
<xpath expr="//div[@id='get_my_invoice']/.." position="after">
<h4 class="text-danger" t-if="pos_order.company_id.country_code == 'AR' and not pos_order.is_invoiced">Invoice not available. You can contact us for more info</h4>
</xpath>
<!-- If the user is NOT log in we should hide the partner form, this one lost functionality because the get my invoice button is not shown and then the partner info is never save. In they want they can sign up and fill data from there -->
<xpath expr="//div[hasclass('o_portal_details')]" position="attributes">
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute>
</xpath>
<xpath expr="//div[@id='get_info_div']" position="attributes">
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute>
</xpath>
<xpath expr="//div[@id='get_info_div']" position="after">
<t t-else="">
<h4> Please
<a role="button" t-att-href="'/web/login?redirect=/pos/ticket/validate?access_token=%s' % access_token" style="margin-top: -11px"> Sign in</a>
in order to save your contact info</h4>
</t>
</xpath>
</template>
</odoo>
@@ -58,7 +58,7 @@
<t t-if="partner.company_name">
, <t t-out="partner.company_name"/>
</t><br />
<t t-if="partner.vat">
<t id="partner_vat" t-if="partner.vat">
<t t-out="partner.vat" /><br />
</t>
<t t-out="partner_address"/> <a role="button" t-att-href="address_url" class="btn btn-sm btn-link"><i class="fa fa-pencil"/> Edit</a>
@@ -88,7 +88,7 @@
</t>
<t t-else="">
<div class="row mt-4">
<div class="col-12">
<div class="col-12" id="get_info_div">
<h4>Please enter your billing information <small class="text-muted">or</small> <a role="button" t-att-href="'/web/login?redirect=/pos/ticket/validate?access_token=%s' % access_token" style="margin-top: -11px"> Sign in</a>:</h4>
</div>
</div>
@@ -118,7 +118,7 @@
</t>
</t>
<div class="row mt-4">
<div class="col-12 col-md-4">
<div class="col-12 col-md-4" id="get_my_invoice">
<t t-if="user_is_connected and not partner_address">
<button class="btn btn-primary w-100" disabled="True">Get my invoice</button>
</t>