Skip to content

Commit

Permalink
[FIX] l10n_ar_sale: re add fix for printing report
Browse files Browse the repository at this point in the history
  • Loading branch information
jjscarafia committed Aug 31, 2023
1 parent 47c3c2d commit a235740
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion l10n_ar_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions l10n_ar_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ def _compute_tax_totals(self):
for rec in self:
rec = rec.with_context(invoice_date=rec.date_order)
super(SaleOrder, rec)._compute_tax_totals()
# 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
10 changes: 10 additions & 0 deletions l10n_ar_sale/views/sale_report_templates.xml
Original file line number Diff line number Diff line change
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 @@ -156,4 +159,11 @@
</xpath>
</template>

<template id="sale_order_portal_content_totals_table" inherit_id="sale.sale_order_portal_content_totals_table" primary="True">
<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>
</xpath>
</template>

</odoo>
4 changes: 2 additions & 2 deletions l10n_ar_sale/views/sale_view.xml
Original file line number Diff line number Diff line change
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 a235740

Please sign in to comment.