Browse Source

[FIX] invoice format editor issue

pull/179/head
Ajmal Cybro 4 years ago
parent
commit
0900282a61
  1. 2
      invoice_format_editor/__manifest__.py
  2. 260
      invoice_format_editor/reports/default_invoice_template.xml

2
invoice_format_editor/__manifest__.py

@ -22,7 +22,7 @@
{ {
'name': 'Invoice Format Editor', 'name': 'Invoice Format Editor',
'version': '14.0.1.1.1', 'version': '14.0.2.1.',
'category': 'Accounting', 'category': 'Accounting',
'summary': 'Invoice Format Editor', 'summary': 'Invoice Format Editor',
'description': """Invoice Format Editor For Configuring the Invoice Templates""", 'description': """Invoice Format Editor For Configuring the Invoice Templates""",

260
invoice_format_editor/reports/default_invoice_template.xml

@ -1,188 +1,116 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<!--Default Template View-->
<template id="report_invoice_document"> <template id="report_invoice_document">
<t t-call="web.external_layout"> <t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context(lang=lang)"/> <t t-set="o" t-value="o.with_context(lang=lang)" />
<t t-set="address"> <t t-set="address">
<address t-field="o.partner_id" <address t-field="o.partner_id" t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'/>
<div t-if="o.partner_id.vat" class="mt16"> <div t-if="o.partner_id.vat" class="mt16">
<t t-if="o.company_id.country_id.vat_label" <t t-if="o.company_id.country_id.vat_label" t-esc="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
t-esc="o.company_id.country_id.vat_label" <t t-else="">Tax ID</t>: <span t-field="o.partner_id.vat"/></div>
id="inv_tax_id_label"/>
<t t-else="">Tax ID</t>:
<span t-field="o.partner_id.vat"/>
</div>
</t> </t>
<div class="page"> <div class="page">
<h2> <h2>
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'"> <span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</span>
Invoice <span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
</span> <span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'draft'"> <span t-if="o.move_type == 'out_refund'">Credit Note</span>
Draft Invoice <span t-if="o.move_type == 'in_refund'">Vendor Credit Note</span>
</span> <span t-if="o.move_type == 'in_invoice'">Vendor Bill</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">
Cancelled Invoice
</span>
<span t-if="o.move_type == 'out_refund'">Credit Note
</span>
<span t-if="o.move_type == 'in_refund'">Vendor Credit
Note
</span>
<span t-if="o.move_type == 'in_invoice'">Vendor Bill
</span>
<span t-if="o.name != '/'" t-field="o.name"/> <span t-if="o.name != '/'" t-field="o.name"/>
</h2> </h2>
<div id="informations" class="row mt32 mb32"> <div id="informations" class="row mt32 mb32">
<div class="col-auto col-3 mw-100 mb-2" <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_date" name="invoice_date">
t-if="o.invoice_date" name="invoice_date">
<strong>Invoice Date:</strong> <strong>Invoice Date:</strong>
<p class="m-0" t-field="o.invoice_date"/> <p class="m-0" t-field="o.invoice_date"/>
</div> </div>
<div class="col-auto col-3 mw-100 mb-2" <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">
t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'"
name="due_date">
<strong>Due Date:</strong> <strong>Due Date:</strong>
<p class="m-0" t-field="o.invoice_date_due"/> <p class="m-0" t-field="o.invoice_date_due"/>
</div> </div>
<div class="col-auto col-3 mw-100 mb-2" <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_origin" name="origin">
t-if="o.invoice_origin" name="origin">
<strong>Source:</strong> <strong>Source:</strong>
<p class="m-0" t-field="o.invoice_origin"/> <p class="m-0" t-field="o.invoice_origin"/>
</div> </div>
<div class="col-auto col-3 mw-100 mb-2" <div class="col-auto col-3 mw-100 mb-2" t-if="o.partner_id.ref" name="customer_code">
t-if="o.partner_id.ref" name="customer_code">
<strong>Customer Code:</strong> <strong>Customer Code:</strong>
<p class="m-0" t-field="o.partner_id.ref"/> <p class="m-0" t-field="o.partner_id.ref"/>
</div> </div>
<div t-if="o.theme_id.reference"> <div class="col-auto col-3 mw-100 mb-2" t-if="o.ref" name="reference">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.ref"
name="reference">
<strong>Reference:</strong> <strong>Reference:</strong>
<p class="m-0" t-field="o.ref"/> <p class="m-0" t-field="o.ref"/>
</div> </div>
</div> </div>
</div>
<t t-set="display_discount" <t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
t-value="any(l.discount for l in o.invoice_line_ids)"/>
<table class="table table-sm o_main_table" <table class="table table-sm o_main_table" name="invoice_line_table">
name="invoice_line_table">
<thead> <thead>
<tr> <tr>
<th name="th_product" class="text-left"> <th name="th_description" class="text-left"><span>Description</span></th>
<span>Product</span> <th name="th_quantity" class="text-right"><span>Quantity</span></th>
</th> <th name="th_priceunit" t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
<span t-if="o.theme_id.description"> <th name="th_price_unit" t-if="display_discount" t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<th name="th_description" class="text-left">
<span>Description</span>
</th>
</span>
<th name="th_quantity" class="text-right">
<span>Quantity</span>
</th>
<th name="th_priceunit"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Unit Price</span>
</th>
<th name="th_price_unit" t-if="display_discount"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Disc.%</span> <span>Disc.%</span>
</th> </th>
<span t-if="o.theme_id.tax_value"> <th name="th_taxes" t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
<th name="th_taxes"
t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Taxes</span>
</th>
</span>
<th name="th_subtotal" class="text-right"> <th name="th_subtotal" class="text-right">
<span groups="account.group_show_line_subtotals_tax_excluded"> <span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
Amount <span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
</span>
<span groups="account.group_show_line_subtotals_tax_included">
Total Price
</span>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody class="invoice_tbody"> <tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/> <t t-set="current_subtotal" t-value="0"/>
<t t-set="lines" <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-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-foreach="lines" t-as="line">
<t t-set="current_subtotal" <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
t-value="current_subtotal + line.price_subtotal" <t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
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"/>
<tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''"> <tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type" <t t-if="not line.display_type" name="account_invoice_line_accountable">
name="account_invoice_line_accountable"> <td name="account_invoice_line_name"><span t-field="line.name" t-options="{'widget': 'text'}"/></td>
<td name="account_invoice_line_name">
<span t-field="line.product_id.name"
t-options="{'widget': 'text'}"/>
</td>
<span t-if="o.theme_id.description">
<td name="account_invoice_line_name">
<span t-field="line.name"
t-options="{'widget': 'text'}"/>
</td>
</span>
<td class="text-right"> <td class="text-right">
<span t-field="line.quantity"/> <span t-field="line.quantity"/>
<span t-field="line.product_uom_id" <span t-field="line.product_uom_id" groups="uom.group_uom"/>
groups="uom.group_uom"/>
</td> </td>
<td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"> <td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" <span class="text-nowrap" t-field="line.price_unit"/>
t-field="line.price_unit"/>
</td> </td>
<td t-if="display_discount" <td t-if="display_discount" t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"> <span class="text-nowrap" t-field="line.discount"/>
<span class="text-nowrap"
t-field="line.discount"/>
</td> </td>
<span t-if="o.theme_id.tax_value">
<td t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"> <td t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))" <span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))" id="line_tax_ids"/>
id="line_tax_ids"/>
</td> </td>
</span>
<td class="text-right o_price_total"> <td class="text-right o_price_total">
<span class="text-nowrap" <span class="text-nowrap" t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
t-field="line.price_subtotal" <span class="text-nowrap" t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
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"/>
</td> </td>
</t> </t>
<t t-if="line.display_type == 'line_section'"> <t t-if="line.display_type == 'line_section'">
<td colspan="99"> <td colspan="99">
<span t-field="line.name" <span t-field="line.name" t-options="{'widget': 'text'}"/>
t-options="{'widget': 'text'}"/>
</td> </td>
<t t-set="current_section" <t t-set="current_section" t-value="line"/>
t-value="line"/> <t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal"
t-value="0"/>
</t> </t>
<t t-if="line.display_type == 'line_note'"> <t t-if="line.display_type == 'line_note'">
<td colspan="99"> <td colspan="99">
<span t-field="line.name" <span t-field="line.name" t-options="{'widget': 'text'}"/>
t-options="{'widget': 'text'}"/>
</td> </td>
</t> </t>
</tr> </tr>
<t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')"> <t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-right"> <tr class="is-subtotal text-right">
<td colspan="99"> <td colspan="99">
<strong class="mr16">Subtotal <strong class="mr16">Subtotal</strong>
</strong> <span
<span t-esc="current_subtotal" t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}' t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/> />
</td> </td>
@ -195,79 +123,56 @@
<div class="clearfix"> <div class="clearfix">
<div id="total" class="row"> <div id="total" class="row">
<div t-attf-class="#{'col-6' if report_type != 'html' else 'col-sm-7 col-md-6'} ml-auto"> <div t-attf-class="#{'col-6' if report_type != 'html' else 'col-sm-7 col-md-6'} ml-auto">
<table class="table table-sm" <table class="table table-sm" style="page-break-inside: avoid;">
style="page-break-inside: avoid;"> <tr class="border-black o_subtotal" style="">
<tr class="border-black o_subtotal" <td><strong>Subtotal</strong></td>
style="">
<td>
<strong>Subtotal</strong>
</td>
<td class="text-right"> <td class="text-right">
<span t-field="o.amount_untaxed"/> <span t-field="o.amount_untaxed"/>
</td> </td>
</tr> </tr>
<t t-foreach="o.amount_by_group" <t t-foreach="o.amount_by_group" t-as="amount_by_group">
t-as="amount_by_group">
<tr style=""> <tr style="">
<t t-if="len(o.line_ids.filtered(lambda line: line.tax_line_id)) in [0, 1] and o.amount_untaxed == amount_by_group[2]"> <t t-if="len(o.line_ids.filtered(lambda line: line.tax_line_id)) in [0, 1] and o.amount_untaxed == amount_by_group[2]">
<td> <td><span class="text-nowrap" t-esc="amount_by_group[0]"/></td>
<span class="text-nowrap"
t-esc="amount_by_group[0]"/>
</td>
<td class="text-right o_price_total"> <td class="text-right o_price_total">
<span class="text-nowrap" <span class="text-nowrap" t-esc="amount_by_group[3]" />
t-esc="amount_by_group[3]"/>
</td> </td>
</t> </t>
<t t-else=""> <t t-else="">
<td> <td>
<span t-esc="amount_by_group[0]"/> <span t-esc="amount_by_group[0]"/>
<span class="text-nowrap">on <span class="text-nowrap"> on
<t t-esc="amount_by_group[4]"/> <t t-esc="amount_by_group[4]"/>
</span> </span>
</td> </td>
<td class="text-right o_price_total"> <td class="text-right o_price_total">
<span class="text-nowrap" <span class="text-nowrap" t-esc="amount_by_group[3]"/>
t-esc="amount_by_group[3]"/>
</td> </td>
</t> </t>
</tr> </tr>
</t> </t>
<tr class="border-black o_total"> <tr class="border-black o_total">
<td> <td><strong>Total</strong></td>
<strong>Total</strong>
</td>
<td class="text-right"> <td class="text-right">
<span class="text-nowrap" <span class="text-nowrap" t-field="o.amount_total"/>
t-field="o.amount_total"/>
</td> </td>
</tr> </tr>
<t t-if="print_with_payments"> <t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'"> <t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals" <t t-set="payments_vals" t-value="o.sudo()._get_reconciled_info_JSON_values()"/>
t-value="o.sudo()._get_reconciled_info_JSON_values()"/> <t t-foreach="payments_vals" t-as="payment_vals">
<t t-foreach="payments_vals"
t-as="payment_vals">
<tr> <tr>
<td> <td>
<i class="oe_form_field text-right oe_payment_label"> <i class="oe_form_field text-right oe_payment_label">Paid on <t t-esc="payment_vals['date']" t-options='{"widget": "date"}'/></i>
Paid on
<t t-esc="payment_vals['date']"
t-options='{"widget": "date"}'/>
</i>
</td> </td>
<td class="text-right"> <td class="text-right">
<span t-esc="payment_vals['amount']" <span t-esc="payment_vals['amount']" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td> </td>
</tr> </tr>
</t> </t>
<t t-if="len(payments_vals) > 0"> <t t-if="len(payments_vals) > 0">
<tr class="border-black"> <tr class="border-black">
<td> <td><strong>Amount Due</strong></td>
<strong>Amount Due
</strong>
</td>
<td class="text-right"> <td class="text-right">
<span t-field="o.amount_residual"/> <span t-field="o.amount_residual"/>
</td> </td>
@ -279,13 +184,8 @@
</div> </div>
</div> </div>
</div> </div>
<p t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference" <p t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference" name="payment_communication">
name="payment_communication"> Please use the following communication for your payment : <b><span t-field="o.payment_reference"/></b>
Please use the following communication for your payment
:
<b>
<span t-field="o.payment_reference"/>
</b>
</p> </p>
<p t-if="o.invoice_payment_term_id" name="payment_term"> <p t-if="o.invoice_payment_term_id" name="payment_term">
<span t-field="o.invoice_payment_term_id.note"/> <span t-field="o.invoice_payment_term_id.note"/>
@ -297,20 +197,12 @@
<span t-field="o.fiscal_position_id.note"/> <span t-field="o.fiscal_position_id.note"/>
</p> </p>
<p t-if="o.invoice_incoterm_id" name="incoterm"> <p t-if="o.invoice_incoterm_id" name="incoterm">
<strong>Incoterm:</strong> <strong>Incoterm: </strong><span t-field="o.invoice_incoterm_id.code"/> - <span t-field="o.invoice_incoterm_id.name"/>
<span t-field="o.invoice_incoterm_id.code"/>
-
<span t-field="o.invoice_incoterm_id.name"/>
</p> </p>
<div id="qrcode" t-if="o.display_qr_code"> <div id="qrcode" t-if="o.display_qr_code">
<p t-if="qr_code_urls.get(o.id)"> <p t-if="qr_code_urls.get(o.id)">
<strong class="text-center">Scan me with your <strong class="text-center">Scan me with your banking app.</strong><br/><br/>
banking app. <img class="border border-dark rounded" t-att-src="qr_code_urls[o.id]"/>
</strong>
<br/>
<br/>
<img class="border border-dark rounded"
t-att-src="qr_code_urls[o.id]"/>
</p> </p>
</div> </div>
</div> </div>
@ -320,8 +212,7 @@
<template id="report_invoice"> <template id="report_invoice">
<t t-call="web.html_container"> <t t-call="web.html_container">
<t t-foreach="docs" t-as="o"> <t t-foreach="docs" t-as="o">
<t t-set="lang" <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
<t t-if="o._get_name_invoice_report() == 'account.report_invoice_document'" <t t-if="o._get_name_invoice_report() == 'account.report_invoice_document'"
t-call="account.report_invoice_document" t-lang="lang"/> t-call="account.report_invoice_document" t-lang="lang"/>
</t> </t>
@ -331,8 +222,7 @@
<template id="report_invoice_with_payments"> <template id="report_invoice_with_payments">
<t t-call="web.html_container"> <t t-call="web.html_container">
<t t-foreach="docs" t-as="o"> <t t-foreach="docs" t-as="o">
<t t-set="lang" <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
<t t-set="print_with_payments" t-value="True"/> <t t-set="print_with_payments" t-value="True"/>
<t t-if="o._get_name_invoice_report() == 'account.report_invoice_document'" <t t-if="o._get_name_invoice_report() == 'account.report_invoice_document'"
t-call="account.report_invoice_document" t-lang="lang"/> t-call="account.report_invoice_document" t-lang="lang"/>
@ -340,14 +230,16 @@
</t> </t>
</template> </template>
<!--We need to create the following empty report template for the action report
"action_account_original_vendor_bill" to work. The action is merging the
original vendor bill(s) that were used to create the vendor bill(s) into one PDF. -->
<template id="report_original_vendor_bill"> <template id="report_original_vendor_bill">
<t t-call="web.html_container"> <t t-call="web.html_container">
<t t-foreach="docs" t-as="o"> <t t-foreach="docs" t-as="o">
<div class="article" t-att-data-oe-model="o and o._name" <div class="article" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')"></div>
t-att-data-oe-id="o and o.id"
t-att-data-oe-lang="o and o.env.context.get('lang')"/>
</t> </t>
</t> </t>
</template> </template>
</data> </data>
</odoo> </odoo>

Loading…
Cancel
Save