Skip to content

Commit

Permalink
temp rebasing PR 129 (b758e20)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc committed Aug 31, 2023
2 parents 9905c5b + b758e20 commit 0fc4469
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion l10n_ar_sale/__manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Sale Total Fields',
'version': "16.0.1.3.0",
'version': "16.0.1.4.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
Expand Down
18 changes: 18 additions & 0 deletions l10n_ar_sale/models/sale_order.py
Expand Up @@ -64,6 +64,24 @@ def _compute_tax_totals(self):
for rec in self:
rec = rec.with_context(invoice_date=rec.date_order)
super(SaleOrder, rec)._compute_tax_totals()
# discriminamos o no impuestos solo en pdf y portal. En backend siempre los mostramos. Para esto evaluamos:
# commit_assetsbundle viene cuando sacamos pdf
# portal_view lo mandamos cuando mostramos campo en portal
report_or_portal_view = 'commit_assetsbundle' in self.env.context or 'from_portal_view' in self.env.context
if not report_or_portal_view:
return

for order in self.filtered(lambda x: not x.vat_discriminated):
tax_groups = order.order_line.mapped('tax_id.tax_group_id')
if not tax_groups:
continue
to_remove_ids = tax_groups.filtered(lambda x: x.l10n_ar_vat_afip_code).ids
tax_group_name = list(order.tax_totals['groups_by_subtotal'].keys())[0]
tax_group_vals = order.tax_totals['groups_by_subtotal'].get(tax_group_name)
updated_tax_group_vals = list(filter(lambda x: x.get('tax_group_id') not in to_remove_ids, tax_group_vals))
new_totals = order.tax_totals
new_totals['groups_by_subtotal'].update({tax_group_name: updated_tax_group_vals})
order.tax_totals = new_totals

def _get_name_sale_report(self, report_xml_id):
""" Method similar to the '_get_name_invoice_report' of l10n_latam_invoice_document
Expand Down
20 changes: 19 additions & 1 deletion l10n_ar_sale/views/sale_report_templates.xml
Expand Up @@ -139,6 +139,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 @@ -149,11 +152,26 @@

</template>

<!-- Solo mostramos el "amount untaxed"" si corresponde discriminar iva. Probamos hacer esto directamente editando el computo de tax_totals pero no fue tan directo porque luego en la vista odoo se fija en esa key para terminar agregando impuestos y otras complicaciones (vista document_tax_totals)-->
<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>

<template id="sale_order_portal_content_totals_table" inherit_id="sale.sale_order_portal_content_totals_table" priority="99">
<t t-set="tax_totals" position="attributes">
<!-- agregamos key para saber que estamos en la vista poral y queremos evaluar incluir o no los impuestos -->
<attribute name="t-value">sale_order.with_context(from_portal_view=True).tax_totals</attribute>
</t>
<!-- mandamos la variable doc para que nuestro custom "document_tax_totals" discrimine o no el subtotal. Tmb cambiamos para que la vista portal
llame a nuestro propio "l10n_ar_sale.document_tax_totals" (no importa filtrar por localizacion o pais porque vat_discriminated define el comportamiento) -->
<t t-set="tax_totals" position="after">
<t t-set="doc" t-value="sale_order"/>
</t>
<t t-call="account.document_tax_totals" position="attributes">
<attribute name="t-call">l10n_ar_sale.document_tax_totals</attribute>
</t>
</template>

</odoo>
4 changes: 2 additions & 2 deletions l10n_ar_sale/views/sale_view.xml
Expand Up @@ -5,9 +5,9 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="fiscal_position_id" position="after">
<group name="sale_info">
<field name="vat_discriminated"/>
</field>
</group>
<xpath expr="//field[@name='order_line']/tree//field[@name='tax_id']" position="after">
<field name="price_unit_with_tax" groups="l10n_ar_sale.sale_price_unit_with_tax" widget="monetary"/>
<!-- <field name="currency_id" invisible="1"/> -->
Expand Down

0 comments on commit 0fc4469

Please sign in to comment.