-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #845 Related: ingadhoc/sale#825 Signed-off-by: matiasperalta1 <[email protected]>
- Loading branch information
Showing
12 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- 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. | ||
""", | ||
'author': 'Odoo, ADHOC SA', | ||
|
||
'depends': [ | ||
'l10n_ar', | ||
'point_of_sale', | ||
], | ||
'data': [ | ||
'views/template.xml', | ||
], | ||
'assets': { | ||
'point_of_sale.assets': [ | ||
'l10n_ar_pos/static/src/**/*' | ||
], | ||
}, | ||
'installable': True, | ||
'auto_install': True, | ||
'license': 'LGPL-3', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import pos_session | ||
from . import pos_order | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from odoo import models, fields, api, _ | ||
from odoo.exceptions import UserError | ||
import base64 | ||
|
||
|
||
class PosOrder(models.Model): | ||
_inherit = "pos.order" | ||
|
||
@api.model | ||
def _process_order(self, order, draft, existing_order): | ||
return super(PosOrder, self.with_context(allow_no_partner=True))._process_order(order=order, draft=draft, existing_order=existing_order) | ||
|
||
def action_pos_order_invoice(self): | ||
""" | ||
Agrego este contexto para evitar el bloqueo en los modulos saas. | ||
""" | ||
return super(PosOrder, self.with_context(allow_no_partner=True)).action_pos_order_invoice() | ||
|
||
|
||
def _create_misc_reversal_move(self, payment_moves): | ||
""" | ||
Agrego este contexto para evitar el bloqueo en los modulos saas. | ||
""" | ||
return super(PosOrder, self.with_context(allow_no_partner=True))._create_misc_reversal_move(payment_moves=payment_moves) | ||
|
||
def _prepare_invoice_vals(self): | ||
vals = super()._prepare_invoice_vals() | ||
|
||
invoice_ids = self.refunded_order_ids.mapped("account_move").filtered( | ||
lambda x: x.company_id.country_id.code == "AR" | ||
and x.is_invoice() | ||
and x.move_type in ["out_invoice"] | ||
) | ||
if len(invoice_ids) > 1: | ||
raise UserError(_("Only can refund one invoice at a time")) | ||
|
||
elif len(invoice_ids) == 1: | ||
vals["reversed_entry_id"] = invoice_ids[0].id | ||
return vals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
from odoo import models, api | ||
|
||
|
||
class PosSession(models.Model): | ||
|
||
_inherit = 'pos.session' | ||
|
||
def _validate_session(self, balancing_account=False, amount_to_balance=0, bank_payment_method_diffs=None): | ||
""" | ||
Agrego este contexto para evitar el bloqueo en los modulos saas. | ||
""" | ||
return super(PosSession, self.with_context(allow_no_partner=True))._validate_session(balancing_account=balancing_account, amount_to_balance=amount_to_balance, bank_payment_method_diffs=bank_payment_method_diffs) | ||
|
||
def _loader_params_res_company(self): | ||
params = super()._loader_params_res_company() | ||
if self.company_id.country_code == 'AR': | ||
params['search_params']['fields'] += ['l10n_ar_gross_income_number', 'l10n_ar_gross_income_type','l10n_ar_afip_responsibility_type_id', | ||
'l10n_ar_company_requires_vat','l10n_ar_afip_start_date'] | ||
return params | ||
|
||
def _loader_params_res_partner(self): | ||
params = super()._loader_params_res_partner() | ||
if self.company_id.country_code == 'AR': | ||
params['search_params']['fields'] += ['l10n_ar_afip_responsibility_type_id', 'l10n_latam_identification_type_id'] | ||
return params | ||
|
||
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 | ||
|
||
@api.model | ||
def _pos_ui_models_to_load(self): | ||
models_to_load = super()._pos_ui_models_to_load() | ||
models_to_load += ['l10n_ar.afip.responsibility.type','l10n_latam.identification.type'] | ||
return models_to_load | ||
|
||
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', 'code'], | ||
}, | ||
} | ||
|
||
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): | ||
return { | ||
'search_params': { | ||
'domain': [('l10n_ar_afip_code', '!=', False), ('active', '=', True)], | ||
'fields': ['name'] | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
odoo.define("l10n_ar_pos.PartnerDetailsEdit", function (require) { | ||
"use strict"; | ||
const PartnerDetailsEdit = require("point_of_sale.PartnerDetailsEdit"); | ||
const { patch } = require("web.utils"); | ||
|
||
patch(PartnerDetailsEdit.prototype, "l10n_ar_pos", { | ||
setup() { | ||
this._super(...arguments); | ||
if (this.env.pos.isArgentineanCompany()) { | ||
const partner = this.props.partner; | ||
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 = partner.l10n_ar_afip_responsibility_type_id && partner.l10n_ar_afip_responsibility_type_id[0]; | ||
this.changes.l10n_latam_identification_type_id = partner.l10n_latam_identification_type_id && partner.l10n_latam_identification_type_id[0]; | ||
} | ||
}, | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
odoo.define('l10n_ar_pos.models', function (require) { | ||
"use strict"; | ||
|
||
var { PosGlobalState, Order } = require('point_of_sale.models'); | ||
const Registries = require('point_of_sale.Registries'); | ||
|
||
|
||
const PosL10nArPosGlobalState = (PosGlobalState) => class PosL10nArPosGlobalState extends PosGlobalState { | ||
async _processData(loadedData) { | ||
await super._processData(...arguments); | ||
this.consumidorFinalAnonimoId = loadedData['consumidor_final_anonimo_id']; | ||
this.l10n_ar_afip_responsibility_type = loadedData['l10n_ar.afip.responsibility.type']; | ||
this.l10n_latam_identification_type = loadedData['l10n_latam.identification.type']; | ||
} | ||
isArgentineanCompany(){ | ||
return this.company.country.code === 'AR'; | ||
} | ||
} | ||
Registries.Model.extend(PosGlobalState, PosL10nArPosGlobalState); | ||
|
||
const L10nARPosOrder = (Order) => class L10nARPosOrder extends Order { | ||
constructor(obj, options) { | ||
super(...arguments); | ||
if (this.pos.isArgentineanCompany()) { | ||
if (!this.partner) { | ||
this.partner = this.pos.db.partner_by_id[this.pos.consumidorFinalAnonimoId]; | ||
} | ||
} | ||
} | ||
} | ||
Registries.Model.extend(Order, L10nARPosOrder); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates id="template" xml:space="preserve"> | ||
<t t-name="PartnerDetailsEdit" t-inherit="point_of_sale.PartnerDetailsEdit" owl="1" t-inherit-mode="extension"> | ||
<xpath expr="//div[hasclass('partner-details-right')]" position="inside"> | ||
<t t-if="env.pos.isArgentineanCompany()"> | ||
<div class="partner-detail"> | ||
<label class="label" for="art">AFIP Responsibility</label> | ||
<select class="detail" t-model="changes.l10n_ar_afip_responsibility_type_id" name="l10n_ar_afip_responsibility_type_id" id="art" | ||
t-on-change="captureChange"> | ||
<t t-foreach="env.pos.l10n_ar_afip_responsibility_type" 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"> | ||
<label class="label" for="id_type">Identification Type</label> | ||
<select class="detail" t-model="changes.l10n_latam_identification_type_id" name="l10n_latam_identification_type_id" id="id_type" | ||
t-on-change="captureChange"> | ||
<t t-foreach="env.pos.l10n_latam_identification_type" 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates id="template" xml:space="preserve"> | ||
|
||
<t t-name="PartnerLine" t-inherit="point_of_sale.PartnerLine" owl="1"> | ||
<div class="company-field" position="after"> | ||
<t t-if="env.pos.isArgentineanCompany()"> | ||
<div class="afip-field"> | ||
<t t-esc="props.partner.l10n_ar_afip_responsibility_type_id[1] or ''" /> | ||
</div> | ||
<div class="vat-field"> | ||
<t t-esc="props.partner.l10n_latam_identification_type_id[1] or ''" /> | ||
<t t-esc="props.partner.vat or ''" /> | ||
</div> | ||
</t> | ||
</div> | ||
</t> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates id="template" xml:space="preserve"> | ||
<t t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1"> | ||
<xpath expr="//div[hasclass('pos-receipt-contact')]/t[@t-if='receipt.company.vat']" position="after"> | ||
<t t-if="receipt.company.l10n_ar_afip_responsibility_type_id"> | ||
<div> | ||
<t t-esc="receipt.company.l10n_ar_afip_responsibility_type_id[1]" /> | ||
</div> | ||
</t> | ||
<div>IBB: <t t-esc="receipt.company.l10n_ar_gross_income_number" /> | ||
<t t-esc="receipt.company.l10n_ar_gross_income_type" /> | ||
</div> | ||
<div>Inicio actividades: <t t-esc="receipt.company.l10n_ar_afip_start_date" /> | ||
</div> | ||
|
||
</xpath> | ||
</t> | ||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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="//form" position="attributes"> | ||
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute> | ||
</xpath> | ||
<xpath expr="//form/.." 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="//form" position="attributes"> | ||
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute> | ||
</xpath> | ||
<xpath expr="//form" position="after"> | ||
<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> | ||
</xpath> | ||
|
||
</template> | ||
</odoo> |