Skip to content

Commit

Permalink
Merge pull request OCA#92 from TelmoSenseFly/BSSFL-83
Browse files Browse the repository at this point in the history
[BSSFL-83] Invoice report initial implementation
  • Loading branch information
jcoux committed Sep 21, 2017
2 parents 28024d3 + 6876aa3 commit 8540a29
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ latest (unreleased)

**Features and Improvements**

* Add sensefly invoice report

**Bugfixes**

**Build**
Expand Down
2 changes: 1 addition & 1 deletion odoo/data/install/res.company.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,parent_id/id,name,street,street2,city,zip,state_id/id,country_id/id,website,phone,fax,email,vat,company_registry,currency_id/id,rml_header1
base.main_company,,senseFly SA,Route de Genève 38,,Cheseaux-Lausanne,1033,,base.ch,www.sensefly.com,+41 (0)21 552 04 44,,info@sensefly.com,CHE-115.246.272 MWST,CHE?115.246.272,base.CHF,
base.main_company,,senseFly SA,Route de Genève 38,,Cheseaux-Lausanne,1033,,base.ch,www.sensefly.com,+41 (0)21 552 04 44,,info@sensefly.com,CHE-115.246.272 MWST,CHE-115.246.272,base.CHF,
__setup__.company_mte,,senseFly Inc,205 New York Avenue NW,,Washington DC,20001,base.state_us_9,base.us,www.sensefly.com,,,,,26--3264326,base.USD,
5 changes: 4 additions & 1 deletion odoo/local-src/sf_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
'data/invoice_action_data.xml',
'views/account_journal.xml',
'views/account_account.xml',
'views/account_invoice.xml'],
'views/account_invoice.xml',
'report/sf_report_invoice.xml',
'report/sf_account_report.xml'
],
'demo': [],
'images': ['static/description/icon.png'],
'installable': True,
Expand Down
13 changes: 13 additions & 0 deletions odoo/local-src/sf_account/report/sf_account_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report
id="account_invoices"
model="account.invoice"
string="Invoices"
report_type="qweb-pdf"
name="sf_account.sf_report_invoice"
file="sf_account.sf_report_invoice"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
</odoo>
205 changes: 205 additions & 0 deletions odoo/local-src/sf_account/report/sf_report_invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="sf_external_layout_invoice_header_right" inherit_id="sf_report.sf_external_layout" primary="True">
<xpath expr="//t[@t-call='sf_report.sf_external_layout_header']" position="attributes">
<attribute name="t-call">sf_account.sf_report_invoice_header_right</attribute>
</xpath>
</template>

<template id="sf_report_invoice_header_right" inherit_id="sf_report.sf_external_layout_header" primary="True">
<xpath expr="//div[@name='header_title']" position="inside">
<p style="font-size:16px; font-weight: bold;">
<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice:</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA:</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice:</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice:</span>
<span t-if="o.type == 'out_refund'">Refund:</span>
<span t-if="o.type == 'in_refund'">Vendor Refund:</span>
<span t-if="o.type == 'in_invoice'">Vendor Bill:</span>
<span t-field="o.number"/>
</p>
<span t-field="o.date_invoice" t-field-options='{"format": "d MMMM yyyy"}'/>
</xpath>
</template>

<template id="sf_report_invoice_document">
<t t-call="sf_account.sf_external_layout_invoice_header_right">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
</t>
</template>

<template id="sf_report_invoice">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="sf_account.sf_report_invoice_document" t-lang="o.partner_id.lang"/>
<div class="page">
<div class="row">
<div class="col-xs-6">
<span>Invoicing address:</span><br/>
<strong t-if="o.partner_id.commercial_company_name" t-field="o.partner_id.commercial_company_name"/>
<span t-if="not o.partner_id.commercial_company_name" t-field="o.partner_id.name"/>
<div t-field="o.partner_id"
t-options='{"widget": "contact", "fields": ["address"], "no_marker": True}'/>
<p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
</div>

<div class="col-xs-6">
<span>Shipping address:</span><br/>
<strong t-if="o.partner_id.commercial_company_name" t-field="o.partner_shipping_id.commercial_company_name"/>
<span t-if="o.partner_id.commercial_company_name"><br/></span>
<span t-if="o.partner_shipping_id.name" t-field="o.partner_shipping_id.name"/>
<div t-field="o.partner_shipping_id"
t-options='{"widget": "contact", "fields": ["address"], "no_marker": True}'/>
</div>
</div>

<hr style="border-top: 1px solid #ccc"/>

<div class="row mt32 mb32" id="informations">
<div t-if="o.origin" class="col-xs-3">
<strong>Quote Reference</strong>
<p t-field="o.origin"/>
</div>
<div t-if="o.user_id.name" class="col-xs-3">
<strong>Salesperson</strong>
<p t-field="o.user_id"/>
</div>
<div t-if="o.order_ids and o.order_ids.client_order_ref" class="col-xs-3">
<strong>P.O. Reference</strong>
<p t-field="o.order_ids.client_order_ref"/>
</div>
<div name="payment_term" t-if="o.payment_term_id and o.order_ids and not o.order_ids.client_order_ref" class="col-xs-3">
<strong>Payment Terms</strong>
<p t-field="o.payment_term_id"/>
</div>
<div name="address" t-if="o.partner_id" class="col-xs-3">
<strong>Contact</strong>
<p style="line-height:1px;padding-top:8px;">
<span t-field="o.partner_id.name"/>
<span t-field="o.partner_id" t-options='{"widget": "contact", "fields": ["phone", "mobile", "email"], "no_marker": False, "phone_icons": True}'/>
</p>
</div>
<div class="col-xs-3" t-if="o.incoterms_id">
<strong>Incoterms</strong>
<p t-field="o.incoterms_id.code"/>
</div>
<div name="payment_term" t-if="o.payment_term_id and o.order_ids and o.order_ids.client_order_ref" class="col-xs-3">
<strong>Payment Terms</strong>
<p t-field="o.payment_term_id"/>
</div>
</div>

<!-- Is there a discount on at least one line? -->
<t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>

<table class="table table-condensed">
<thead>
<tr style="background: #ccc;">
<th>Description</th>
<th class="text-right">Origin</th>
<th class="hidden">Source Document</th>
<th class="text-right">Quantity</th>
<th class="text-right">Unit Price</th>
<th t-if="display_discount" class="text-right">Disc.(%)</th>
<th class="text-right">Taxes</th>
<th class="text-right">Tax Excluded Price</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line_ids" t-as="l">
<td><span t-field="l.name"/></td>
<td class="text-right">
<span t-field="l.product_id.origin_id.code"/>
</td>
<td class="hidden"><span t-field="l.origin"/></td>
<td class="text-right">
<span t-field="l.quantity"/>
<span t-field="l.uom_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
</table>

<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black" >
<td><strong>Subtotal</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
<t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
<tr>
<td><span t-esc="amount_by_group[0] if len(o.tax_line_ids) > 1 else (o.tax_line_ids.tax_id.description or o.tax_line_ids.tax_id.name)"/></td>
<td class="text-right">
<span t-esc="amount_by_group[1]" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
<tr class="border-black">
<td><strong>TOTAL DUE</strong></td>
<td class="text-right">
<strong t-field="o.amount_total" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</table>
</div>
</div>

<div class="row" t-if="len(o.tax_line_ids) > 1">
<div class="col-xs-6">
<table class="table table-condensed">
<thead>
<tr>
<th>Tax</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.tax_line_ids" t-as="t">
<td><span t-field="t.tax_id.description"/></td>
<td class="text-right">
<span t-field="t.amount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<!-- Bank details -->
<div class="row" t-foreach="o.company_id.partner_id.bank_ids" t-as="b">
<div class="col-xs-8 pull-left" t-if="b.currency_id == o.currency_id">
<span>Payment for: </span><span t-field="o.company_id.name"/> <span t-field="o.company_id.partner_id.city"/>
<br />
<span>Bank: </span><span t-field="b.bank_id.name"/>, <span t-field="b.bank_id.country.code"/>-<span t-field="b.bank_id.zip"/>
<span t-field="b.bank_id.city"/>, <span t-field="b.bank_id.country"/>
<br />
<span>BIC/SWIFT: </span><span t-field="b.bank_id.bic"/><span> / IBAN: </span><span t-field="b.acc_number"/>
</div>
</div>

<div class="row">
<div class="col-xs-8 pull-left">
<p style="font-weight: bold;">All bank fees are the responsibility of the customer</p>
</div>
</div>
</div>
</t>
</t>
</template>
</odoo>

0 comments on commit 8540a29

Please sign in to comment.