summaryrefslogtreecommitdiff
path: root/addons/hr_expense/report
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2016-03-03 13:34:38 +0100
committerYannick Tivisse <yti@odoo.com>2016-06-17 12:14:57 +0200
commit717f9217bb323fa03c03bfc188a7f2cdb797eaa6 (patch)
treefa93065def62217b4bf28ebf7e4a6f6f750f210f /addons/hr_expense/report
parent5aa9bde34a1fac3e437d92e6daaf72029730a2f1 (diff)
[IMP] hr_expense: bring back the sheets + other new features
NB: - The option no_delete is not working, a fix will come from chm - The many2many widget on a sheet creation is not working correctly as the called command is a (1, id, values) without a (4, id, _) before. A fix will also come from chm, but a disgusting hack has been provided for this particular case (to remove after chm fix)
Diffstat (limited to 'addons/hr_expense/report')
-rw-r--r--addons/hr_expense/report/__init__.py4
-rw-r--r--addons/hr_expense/report/hr_expense_report.py60
-rw-r--r--addons/hr_expense/report/report_expense_sheet.xml103
3 files changed, 103 insertions, 64 deletions
diff --git a/addons/hr_expense/report/__init__.py b/addons/hr_expense/report/__init__.py
deleted file mode 100644
index 7f74fc905a4..00000000000
--- a/addons/hr_expense/report/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-import hr_expense_report \ No newline at end of file
diff --git a/addons/hr_expense/report/hr_expense_report.py b/addons/hr_expense/report/hr_expense_report.py
deleted file mode 100644
index 1422abf9aa5..00000000000
--- a/addons/hr_expense/report/hr_expense_report.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-import time
-from openerp.osv import osv
-from openerp.tools.misc import formatLang
-from openerp.tools.translate import _
-from openerp.report import report_sxw
-from openerp.exceptions import UserError
-
-
-class report_expense(report_sxw.rml_parse):
-
- def set_context(self, objects, data, ids, report_type=None):
- res = super(report_expense, self).set_context(objects, data, ids, report_type=report_type)
-
- hr_expense_obj = self.pool.get('hr.expense')
-
- context = {'lang': self.pool.get('res.users').browse(self.cr, self.uid, self.uid).lang}
- state_field = hr_expense_obj.fields_get(self.cr, self.uid, 'state', context=context)['state']['selection']
- state_dict = {}
- for state_tuple in state_field:
- state_dict[state_tuple[0]] = state_tuple[1]
-
- expenses_info = {}
- expenses = hr_expense_obj.search(self.cr, self.uid, [('id', 'in', ids)], order="employee_id, currency_id, state, date")
- for expense in hr_expense_obj.browse(self.cr, self.uid, expenses):
- key = expense.employee_id.name + '-' + expense.currency_id.name + '-' + expense.state
- if expenses_info.get(key):
- expenses_info[key]['lines'] += expense
- expenses_info[key]['total_amount'] += expense.total_amount
- else:
- expenses_info[key] = {
- 'employee_name': expense.employee_id.name,
- 'total_amount': expense.total_amount,
- 'lines': expense,
- 'currency': expense.currency_id,
- 'validator_name': expense.employee_id.parent_id.name,
- 'notes': [],
- 'notes_index': {},
- 'state': state_dict[expense.state],
- }
- if expense.description:
- index = len(expenses_info[key]['notes']) + 1
- expenses_info[key]['notes'].append({'description': expense.description, 'index':index})
- expenses_info[key]['notes_index'][expense.id] = index
-
- # Qweb for-each do not work on dict, so we send a list and we sort it by the name of the employee
- # that way if we have two sheet for the same employee they will follow in the report
- self.localcontext.update({
- 'get_expenses': lambda : [v for k,v in sorted(expenses_info.items())],
- })
- return res
-
-
-class report_hr_expense(osv.AbstractModel):
- _name = 'report.hr_expense.report_expense'
- _inherit = 'report.abstract_report'
- _template = 'hr_expense.report_expense'
- _wrapped_report_class = report_expense
diff --git a/addons/hr_expense/report/report_expense_sheet.xml b/addons/hr_expense/report/report_expense_sheet.xml
new file mode 100644
index 00000000000..52d26268668
--- /dev/null
+++ b/addons/hr_expense/report/report_expense_sheet.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <template id="report_expense_sheet">
+ <t t-call="report.html_container">
+ <t t-foreach="docs" t-as="o">
+ <t t-call="report.external_layout">
+ <div class="page">
+ <h2>Expenses Report</h2>
+
+ <div class="row mt32 mb32">
+ <div class="col-xs-2">
+ <strong>Employee:</strong>
+ <p t-field="o.employee_id.name"/>
+ </div>
+ <div class="col-xs-2">
+ <strong>Date:</strong>
+ <p t-field="o.accounting_date"/>
+ </div>
+ <div class="col-xs-3">
+ <strong>Description:</strong>
+ <p t-field="o.name"/>
+ </div>
+ <div class="col-xs-2">
+ <strong>Validated By:</strong>
+ <p t-field="o.responsible_id"/>
+ </div>
+ <div class="col-xs-3">
+ <strong>Payment By:</strong>
+ <p t-field="o.payment_mode"/>
+ </div>
+ </div>
+
+ <table class="table table-condensed">
+ <thead>
+ <tr>
+ <th>Date</th>
+ <th>Name</th>
+ <th class="text-center">Ref.</th>
+ <th>Unit Price</th>
+ <th>Taxes</th>
+ <th class="text-center">Qty</th>
+ <th class="text-right">Price</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t-foreach="o.expense_line_ids" t-as="line">
+ <td><span t-field="line.date"/></td>
+ <td>
+ <span t-field="line.name"/>
+ <span t-field="line.description"/><br/>
+ <span t-field="line.analytic_account_id.name"/>
+ </td>
+ <td style="text-center">
+ <span t-field="line.reference"/>
+ </td>
+ <td>
+ <span t-field="line.unit_amount"/>
+ </td>
+ <td>
+ <span t-field="line.tax_ids"/>
+ </td>
+ <td class="text-center">
+ <span t-field="line.quantity"/>
+ </td>
+ <td class="text-right">
+ <span t-field="line.total_amount"
+ t-field-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>Total</strong></td>
+ <td class="text-right">
+ <span t-field="o.total_amount"
+ t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <p>Certified honest and conform,<br/>(Date and signature).<br/><br/></p>
+ </div>
+ </t>
+ </t>
+ </t>
+ </template>
+
+ <report
+ id="action_report_hr_expense_sheet"
+ string="Expenses Report"
+ model="hr.expense.sheet"
+ report_type="qweb-pdf"
+ name="hr_expense.report_expense_sheet"
+ file="hr_expense.report_expense_sheet"
+ />
+
+</odoo> \ No newline at end of file