erickabrego 9 kuukautta sitten
vanhempi
commit
ce5efaf373

+ 1 - 1
change_vat_in_partner/report/account_move_report.xml

@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='utf-8'?>
 <odoo>
-    <template id="custom_report_invoice_document" inherit_id="account.report_invoice_document">
+    <template id="custom_report_invoice_document" inherit_id="l10n_mx_edi.report_invoice_document">
         <xpath expr="//div[hasclass('row')]//div[@name='address_not_same_as_shipping']//t[@t-set='address']" position="replace">
         </xpath>
         <xpath expr="//div[hasclass('row')]//div[@name='address_same_as_shipping']//t[@t-set='address']" position="replace">

+ 11 - 12
custom_supplier_cfdi_data/models/account_edi_format.py

@@ -3,16 +3,15 @@
 from odoo import models, fields, api
 
 class AccountEdiFormat(models.Model):
-    _inherit = 'account.edi.format'
+    _inherit = 'l10n_mx_edi.document'
 
-    def _l10n_mx_edi_get_common_cfdi_values(self, move):
-        res = super(AccountEdiFormat, self)._l10n_mx_edi_get_common_cfdi_values(move)
-        if move.company_id.x_commercial_partner_id:
-            res["supplier"] = move.company_id.x_commercial_partner_id
-        return res
-
-    def _l10n_mx_edi_get_40_values(self, move):
-        res = super(AccountEdiFormat, self)._l10n_mx_edi_get_40_values(move)
-        if move.company_id.x_commercial_partner_id:
-            res["supplier_name"] = self._l10n_mx_edi_clean_to_legal_name(str(move.company_id.x_commercial_partner_id.name).strip())
-        return res
+    @api.model
+    def _add_certificate_cfdi_values(self, cfdi_values):
+        res = super(AccountEdiFormat, self)._add_certificate_cfdi_values(cfdi_values)
+        root_company = cfdi_values['root_company']
+        if root_company.x_commercial_partner_id:
+            supplier = root_company.x_commercial_partner_id.with_user(self.env.user)
+            cfdi_values["emisor"]["supplier"] = supplier
+            cfdi_values["emisor"]["rfc"] = supplier.vat
+            cfdi_values["emisor"]["nombre"] = self._cfdi_sanitize_to_legal_name(supplier.name)
+            cfdi_values["emisor"]["supplier"] = supplier.zip

+ 29 - 40
cutom_report_invoice/views/report_invoice_view.xml

@@ -6,7 +6,7 @@
                 <t t-call="web.external_layout">
                     <t t-set="forced_vat" t-value="o.fiscal_position_id.foreign_vat"/>
                     <div>
-                        <div class="page" >
+                        <div class="page">
                             <h2>
                                 <span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</span>
                                 <span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
@@ -17,15 +17,14 @@
                                 <span t-if="o.name != '/'" t-field="o.name"/>
                             </h2>
                             <!-- Global variables -->
-                            <t t-set="cfdi_vals" t-value="o._l10n_mx_edi_decode_cfdi()"/>
-                            <t t-set="is_cfdi_signed" t-value="bool(o._get_l10n_mx_edi_signed_edi_document())"/>
+                            <t t-set="cfdi_vals" t-value="o._l10n_mx_edi_get_extra_invoice_report_values()"/>
+                            <t t-set="is_cfdi_signed" t-value="bool(cfdi_vals.get('sello'))"/>
 
-                            <t t-if="o.l10n_mx_edi_cfdi_request in ('on_invoice', 'on_refund') and not is_cfdi_signed and o.edi_state != 'cancelled'">
-                                <!-- due to HTML preview for device responsive -->
+                            <t t-if="o.l10n_mx_edi_is_cfdi_needed and not is_cfdi_signed">
                                 <button t-attf-class="btn-danger #{'btn' if report_type != 'html' else ''}">
                                     <strong>A signature of this invoice is required, but it is not signed.</strong>
                                 </button>
-                            </t>
+                            </t> 
                             <div class="row">
                                 <div class="col-5">
                                     <div t-field="res_company.x_commercial_partner_id" t-options-widget="'contact'"/>
@@ -38,36 +37,36 @@
                                 </div>
                             </div>
                             <div id="informations" class="row mt-4 mb-4">
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_date" name="invoice_date">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.invoice_date" name="invoice_date">
                                     <t t-if="o.move_type == 'out_invoice'"><strong>Invoice Date:</strong></t>
                                     <t t-elif="o.move_type == 'out_refund'"><strong>Credit Note Date:</strong></t>
                                     <t t-elif="o.move_type == 'out_receipt'"><strong>Receipt Date:</strong></t>
                                     <t t-else=""><strong>Date:</strong></t>
                                     <p class="m-0" t-field="o.invoice_date"/>
                                 </div>
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date">
                                     <strong>Due Date:</strong>
                                     <p class="m-0" t-field="o.invoice_date_due"/>
                                 </div>
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_origin" name="origin">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.invoice_origin" name="origin">
                                     <strong>Source:</strong>
                                     <p class="m-0" t-field="o.invoice_origin"/>
                                 </div>
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.partner_id.ref" name="customer_code">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.partner_id.ref" name="customer_code">
                                     <strong>Customer Code:</strong>
                                     <p class="m-0" t-field="o.partner_id.ref"/>
                                 </div>
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.currency_id" name="currency">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.currency_id" name="currency">
                                     <strong>Currency:</strong>
                                     <p class="m-0" t-field="o.currency_id"/>
                                 </div>
-                                <div class="col-auto col-3 mw-100 mb-2" t-if="o.rate and o.currency_id.name == 'USD'" name="rate">
+                                <div class="col-auto col-2 mw-100 mb-2" t-if="o.rate and o.currency_id.name == 'USD'" name="rate">
                                     <strong>Exchange rate:</strong>
                                     <p class="m-0" t-field="o.rate"/>
                                 </div>
                                 <t t-if="is_cfdi_signed">
                                     <t t-set="original_o_grid_layout" t-value="o_grid_layout"/>
-                                    <t t-set="o_grid_layout" t-value="'col-auto col-3 mw-100 mb-2'"/>
+                                    <t t-set="o_grid_layout" t-value="'col-auto col-2 mw-100 mb-2'"/>
                                     <t t-if="cfdi_vals.get('usage')">
                                         <div name="cfdi_vals['usage']" t-att-class="o_grid_layout">
                                             <strong>Usage:</strong>
@@ -113,8 +112,7 @@
                                         </th>
                                         <th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
                                         <th name="th_subtotal" class="text-end">
-                                            <span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
-                                            <span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
+                                            <span>Importe</span>
                                         </th>
                                     </tr>
                                 </thead>
@@ -123,8 +121,7 @@
                                     <t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
 
                                     <t t-foreach="lines" t-as="line">
-                                        <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
-                                        <t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
+                                        <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
 
                                         <tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
                                             <t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
@@ -138,8 +135,7 @@
                                                     <span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))" id="line_tax_ids"/>
                                                 </td>
                                                 <td class="text-end o_price_total">
-                                                    <span class="text-nowrap" t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
-                                                    <span class="text-nowrap" t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
+                                                    <span class="text-nowrap" t-field="line.price_subtotal"/>
                                                 </td>
                                             </t>
                                             <t t-if="line.display_type == 'line_section'">
@@ -160,10 +156,7 @@
                                             <tr class="is-subtotal text-end">
                                                 <td colspan="99">
                                                     <strong class="mr16">Subtotal</strong>
-                                                    <span
-                                                        t-esc="current_subtotal"
-                                                        t-options='{"widget": "monetary", "display_currency": o.currency_id}'
-                                                    />
+                                                    <span t-esc="current_subtotal" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}"/>
                                                 </td>
                                             </tr>
                                         </t>
@@ -177,8 +170,10 @@
                                     <table class="table table-sm table-borderless" style="page-break-inside: avoid;">
 
                                         <!--Tax totals-->
-                                        <t t-set="tax_totals" t-value="o.tax_totals"/>
-                                        <t t-call="account.document_tax_totals"/>
+                                        <t t-if="o.tax_totals" t-call="account.document_tax_totals">
+                                                <t t-set="tax_totals" t-value="o.tax_totals"/>
+                                                <t t-set="currency" t-value="o.currency_id"/>
+                                        </t>
 
                                         <!--Payments-->
                                         <t t-if="print_with_payments">
@@ -187,14 +182,14 @@
                                                 <t t-foreach="payments_vals" t-as="payment_vals">
                                                     <tr t-if="payment_vals['is_exchange'] == 0">
                                                         <td>
-                                                            <i class="oe_form_field text-end oe_payment_label">Paid on <t t-esc="payment_vals['date']" t-options='{"widget": "date"}'/></i>
+                                                            <i class="oe_form_field text-end oe_payment_label">Paid on <t t-esc="payment_vals['date']" t-options="{&quot;widget&quot;: &quot;date&quot;}"/></i>
                                                         </td>
                                                         <td class="text-end">
-                                                            <span t-esc="payment_vals['amount']" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
+                                                            <span t-esc="payment_vals['amount']" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}"/>
                                                         </td>
                                                     </tr>
                                                 </t>
-                                                <t t-if="len(payments_vals) > 0">
+                                                <t t-if="len(payments_vals) &gt; 0">
                                                     <tr class="border-black fw-bold">
                                                         <td>Amount Due</td>
                                                         <td class="text-end">
@@ -215,7 +210,7 @@
                         <t t-set="payment_term_details" t-value="o.payment_term_details"/>
                         <div t-field="o.invoice_payment_term_id.note" name="payment_term"/>
                         <t t-if="o.invoice_payment_term_id.display_on_invoice and payment_term_details">
-                            <div t-if='o.show_payment_term_details' id="total_payment_term_details_table" class="row">
+                            <div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
                                 <div t-attf-class="#{'col-7' if report_type != 'html' else 'col-sm-7 col-md-6'} mt-2 mb-2">
                                     <table class="table table-sm" style="page-break-inside: avoid;">
                                         <th class="border-black text-start">
@@ -230,10 +225,9 @@
                                         <t t-foreach="payment_term_details" t-as="term">
                                             <tr>
                                                 <td t-esc="term.get('date')" class="text-start"/>
-                                                <td t-options='{"widget": "monetary", "display_currency": o.currency_id}' t-esc="term.get('amount')" class="text-end"/>
+                                                <td t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}" t-esc="term.get('amount')" class="text-end"/>
                                                 <td t-if="term.get('discount_date')" class="text-end">
-                                                    <span t-options='{"widget": "monetary", "display_currency": o.currency_id}'
-                                                        t-esc="term.get('discount_amount_currency')"/> if paid before
+                                                    <span t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}" t-esc="term.get('discount_amount_currency')"/> if paid before
                                                     <span t-esc="term.get('discount_date')"/>
                                                 </td>
                                             </tr>
@@ -254,14 +248,9 @@
                             <span t-field="o.fiscal_position_id.note"/>
                         </p>
                         <t t-if="is_cfdi_signed">
-                            <div class="row" id='complement'>
+                            <div class="row" id="complement">
                                 <div t-if="cfdi_vals.get('sello')" class="barcode col-3">
-                                    <img alt="Barcode" t-att-src="'/report/barcode/?barcode_type=QR&amp;value=%s&amp;width=180&amp;height=180' % quote_plus(
-                                        'https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?' + keep_query(
-                                            re=o.l10n_mx_edi_cfdi_supplier_rfc, rr=o.l10n_mx_edi_cfdi_customer_rfc,
-                                            tt='%.*f' % (o.currency_id.decimal_places, o.l10n_mx_edi_cfdi_amount), id=o.l10n_mx_edi_cfdi_uuid)
-                                            + '&amp;fe=%s' % quote_plus(
-                                                cfdi_vals['sello'][-8:], 'utf-8', 'strict', '=/').replace('%2B', '+'))"/>
+                                    <img alt="Barcode" t-att-src="'/report/barcode/?barcode_type=QR&amp;value=%s&amp;width=180&amp;height=180' % quote_plus(                                         'https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?' + keep_query(                                             re=o.l10n_mx_edi_cfdi_supplier_rfc, rr=o.l10n_mx_edi_cfdi_customer_rfc,                                             tt='%.*f' % (o.currency_id.decimal_places, o.l10n_mx_edi_cfdi_amount), id=o.l10n_mx_edi_cfdi_uuid)                                             + '&amp;fe=%s' % quote_plus(                                                 cfdi_vals['sello'][-8:], 'utf-8', 'strict', '=/').replace('%2B', '+'))"/>
                                 </div>
                                 <div class="complement-details col-9">
                                     <div class="digital-stamp">
@@ -303,7 +292,7 @@
                         <p t-if="o.invoice_incoterm_id" name="incoterm">
                             <strong>Incoterm: </strong><span t-field="o.invoice_incoterm_id.code"/> - <span t-field="o.invoice_incoterm_id.name"/>
                         </p>
-                        <div id="qrcode" t-if="o.display_qr_code and o.amount_residual > 0">
+                        <div id="qrcode" t-if="o.display_qr_code and o.amount_residual &gt; 0">
                             <t t-set="qr_code_url" t-value="o._generate_qr_code(silent_errors=True)"/>
                             <p t-if="qr_code_url">
                                 <strong class="text-center">Scan me with your banking app.</strong><br/><br/>