Skip to content

Commit

Permalink
[IMP] l10n_ar_sale: arreglar impresión de presupuesto
Browse files Browse the repository at this point in the history
Task: 28700
Lo que hace este pr es que la impresión del presupuesto discrimine o no el iva de acuerdo a la condición fiscal del cliente.
  • Loading branch information
pablohmontenegro committed Feb 8, 2023
1 parent 14f5aab commit bfe3209
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
3 changes: 2 additions & 1 deletion l10n_ar_sale/__manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Sale Total Fields',
'version': "16.0.1.0.0",
'version': "16.0.2.0.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
Expand All @@ -10,6 +10,7 @@
'depends': [
'sale',
'l10n_ar',
'account'
],
'external_dependencies': {
},
Expand Down
40 changes: 36 additions & 4 deletions l10n_ar_sale/models/sale_order.py
Expand Up @@ -91,10 +91,42 @@ def create(self, vals):

def _compute_tax_totals(self):
""" Mandamos en contexto el invoice_date para calculo de impuesto con partner aliquot
ver módulo l10n_ar_account_withholding"""
for rec in self:
rec = rec.with_context(invoice_date=rec.date_order)
super(SaleOrder, rec)._compute_tax_totals()
ver módulo l10n_ar_account_withholding. Además acá reemplazamos el método _compute_tax_totals del módulo sale original de odoo"""
for order in self:
order = order.with_context(invoice_date=order.date_order)
order_lines = order.order_line.filtered(lambda x: not x.display_type)
order.tax_totals = self.env['account.tax']._prepare_tax_totals(
[x._convert_to_tax_base_line_dict() for x in order_lines],
order.currency_id or order.company_id.currency_id,
)

# Lo que sigue de acá hasta el final del método es medio feo y sirve por si algún presupuesto
# cuyo cliente no corresponda discriminar el
# iva pero tiene alguna percepción o impuesto diferente a iva entonces tenemos que mostrar esa
# percepción o impuesto diferente y ocultar el iva

# Esto es para saber todas los impuestos que se están cargando en todas las líneas de la orden de venta
order_line_taxes = order.order_line.mapped('tax_id.tax_group_id.l10n_ar_vat_afip_code')

# Acá lo que hacemos es ocultar del presupuesto impreso todos aquellos impuestos que no sean iva cuando
# el cliente no discrimina iva
if not order.vat_discriminated:
taxes = order.tax_totals['groups_by_subtotal']
for tax in taxes:
contador = 0
listado_a_borrar = []
for rec1 in taxes[tax]:
tax_group_id = rec1['tax_group_id']
l10n_ar_vat_afip_code = self.env['account.tax.group'].browse(tax_group_id).l10n_ar_vat_afip_code

if l10n_ar_vat_afip_code in order_line_taxes and l10n_ar_vat_afip_code != False:
listado_a_borrar.append(contador)
contador += 1
if len(listado_a_borrar)>1:
listado_a_borrar.reverse()
for index in listado_a_borrar:
taxes[tax].pop(index)


def _get_name_sale_report(self, report_xml_id):
""" Method similar to the '_get_name_invoice_report' of l10n_latam_invoice_document
Expand Down
11 changes: 11 additions & 0 deletions l10n_ar_sale/views/sale_report_templates.xml
Expand Up @@ -140,6 +140,9 @@
</div>
</div>

<t t-call="account.document_tax_totals" position="attributes">
<attribute name="t-call">l10n_ar_sale.document_tax_totals</attribute>
</t>
</template>
<template id="sale_order_portal_content_discount" inherit_id="sale.sale_order_portal_content">

Expand All @@ -148,4 +151,12 @@
</xpath>

</template>

<template id="document_tax_totals" inherit_id="account.document_tax_totals" primary="True">
<xpath expr="//t[@t-foreach]/tr" position="attributes">
<!-- Solo mostramos el importe sin impuestos si corresponde discriminar iva -->
<attribute name="t-if">doc.vat_discriminated</attribute>
</xpath>
</template>

</odoo>

0 comments on commit bfe3209

Please sign in to comment.