Browse Source
Merge pull request #424 from Eficent/10.0-account_financial_report_qweb-open_items-foreign_currency
Merge pull request #424 from Eficent/10.0-account_financial_report_qweb-open_items-foreign_currency
[10.0] [IMP] account_financial_report_qweb - foreign currencies + dynamic reportingpull/425/head
Pedro M. Baeza
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 2909 additions and 798 deletions
-
8account_financial_report_qweb/__manifest__.py
-
84account_financial_report_qweb/report/abstract_report_xlsx.py
-
23account_financial_report_qweb/report/aged_partner_balance.py
-
123account_financial_report_qweb/report/general_ledger.py
-
71account_financial_report_qweb/report/general_ledger_xlsx.py
-
73account_financial_report_qweb/report/journal_report.py
-
2account_financial_report_qweb/report/journal_report_xlsx.py
-
255account_financial_report_qweb/report/open_items.py
-
39account_financial_report_qweb/report/open_items_xlsx.py
-
463account_financial_report_qweb/report/templates/aged_partner_balance.xml
-
449account_financial_report_qweb/report/templates/general_ledger.xml
-
14account_financial_report_qweb/report/templates/journal.xml
-
165account_financial_report_qweb/report/templates/open_items.xml
-
418account_financial_report_qweb/report/templates/trial_balance.xml
-
88account_financial_report_qweb/report/trial_balance.py
-
67account_financial_report_qweb/report/trial_balance_xlsx.py
-
47account_financial_report_qweb/reports.xml
-
14account_financial_report_qweb/static/src/css/report.css
-
95account_financial_report_qweb/static/src/js/account_financial_report_qweb_backend.js
-
69account_financial_report_qweb/static/src/js/account_financial_report_qweb_widgets.js
-
1account_financial_report_qweb/tests/__init__.py
-
281account_financial_report_qweb/tests/abstract_test.py
-
79account_financial_report_qweb/tests/abstract_test_foreign_currency.py
-
2account_financial_report_qweb/tests/test_aged_partner_balance.py
-
14account_financial_report_qweb/tests/test_general_ledger.py
-
45account_financial_report_qweb/tests/test_journal.py
-
7account_financial_report_qweb/tests/test_open_items.py
-
7account_financial_report_qweb/tests/test_trial_balance.py
-
9account_financial_report_qweb/view/report_aged_partner_balance.xml
-
9account_financial_report_qweb/view/report_general_ledger.xml
-
9account_financial_report_qweb/view/report_journal_ledger.xml
-
9account_financial_report_qweb/view/report_open_items.xml
-
57account_financial_report_qweb/view/report_template.xml
-
11account_financial_report_qweb/view/report_trial_balance.xml
-
29account_financial_report_qweb/wizard/aged_partner_balance_wizard.py
-
3account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml
-
36account_financial_report_qweb/wizard/general_ledger_wizard.py
-
4account_financial_report_qweb/wizard/general_ledger_wizard_view.xml
-
38account_financial_report_qweb/wizard/journal_report_wizard.py
-
19account_financial_report_qweb/wizard/journal_report_wizard.xml
-
36account_financial_report_qweb/wizard/open_items_wizard.py
-
4account_financial_report_qweb/wizard/open_items_wizard_view.xml
-
39account_financial_report_qweb/wizard/trial_balance_wizard.py
-
4account_financial_report_qweb/wizard/trial_balance_wizard_view.xml
@ -0,0 +1,95 @@ |
|||||
|
odoo.define('account_financial_report_qweb.account_financial_report_backend', function (require) { |
||||
|
'use strict'; |
||||
|
|
||||
|
var core = require('web.core'); |
||||
|
var Widget = require('web.Widget'); |
||||
|
var ControlPanelMixin = require('web.ControlPanelMixin'); |
||||
|
var ReportWidget = require('account_financial_report_qweb.account_financial_report_widget'); |
||||
|
var Model = require('web.Model'); |
||||
|
|
||||
|
|
||||
|
var report_backend = Widget.extend(ControlPanelMixin, { |
||||
|
// Stores all the parameters of the action.
|
||||
|
events: { |
||||
|
'click .o_account_financial_reports_print': 'print', |
||||
|
'click .o_account_financial_reports_export': 'export', |
||||
|
}, |
||||
|
init: function(parent, action) { |
||||
|
this.actionManager = parent; |
||||
|
this.given_context = {}; |
||||
|
this.odoo_context = action.context; |
||||
|
this.controller_url = action.context.url; |
||||
|
if (action.context.context) { |
||||
|
this.given_context = action.context.context; |
||||
|
} |
||||
|
this.given_context.active_id = action.context.active_id || action.params.active_id; |
||||
|
this.given_context.model = action.context.active_model || false; |
||||
|
this.given_context.ttype = action.context.ttype || false; |
||||
|
return this._super.apply(this, arguments); |
||||
|
}, |
||||
|
willStart: function() { |
||||
|
return $.when(this.get_html()); |
||||
|
}, |
||||
|
set_html: function() { |
||||
|
var self = this; |
||||
|
var def = $.when(); |
||||
|
if (!this.report_widget) { |
||||
|
this.report_widget = new ReportWidget(this, this.given_context); |
||||
|
def = this.report_widget.appendTo(this.$el); |
||||
|
} |
||||
|
def.then(function () { |
||||
|
self.report_widget.$el.html(self.html); |
||||
|
}); |
||||
|
}, |
||||
|
start: function() { |
||||
|
this.set_html(); |
||||
|
return this._super(); |
||||
|
}, |
||||
|
// Fetches the html and is previous report.context if any, else create it
|
||||
|
get_html: function() { |
||||
|
var self = this; |
||||
|
var defs = []; |
||||
|
self.model = new Model(this.given_context.model); |
||||
|
return self.model.call('get_html', [this.given_context], {context: self.odoo_context}).then(function |
||||
|
(result) { |
||||
|
self.html = result.html; |
||||
|
defs.push(self.update_cp()); |
||||
|
return $.when.apply($, defs); |
||||
|
}); |
||||
|
}, |
||||
|
// Updates the control panel and render the elements that have yet to be rendered
|
||||
|
update_cp: function() { |
||||
|
if (!this.$buttons) { |
||||
|
|
||||
|
} |
||||
|
var status = { |
||||
|
breadcrumbs: this.actionManager.get_breadcrumbs(), |
||||
|
cp_content: {$buttons: this.$buttons}, |
||||
|
}; |
||||
|
return this.update_control_panel(status); |
||||
|
}, |
||||
|
do_show: function() { |
||||
|
this._super(); |
||||
|
this.update_cp(); |
||||
|
}, |
||||
|
print: function() { |
||||
|
var self = this; |
||||
|
self.model = new Model(this.given_context.model); |
||||
|
self.model.call('print_report', [this.given_context.active_id, 'qweb-pdf'], {context: self.odoo_context}) |
||||
|
.then(function(result){ |
||||
|
self.do_action(result); |
||||
|
}); |
||||
|
}, |
||||
|
export: function() { |
||||
|
var self = this; |
||||
|
self.model = new Model(this.given_context.model); |
||||
|
self.model.call('print_report', [this.given_context.active_id, 'xlsx'], {context: self.odoo_context}) |
||||
|
.then(function(result){ |
||||
|
self.do_action(result); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
core.action_registry.add("account_financial_report_backend", report_backend); |
||||
|
return report_backend; |
||||
|
}); |
@ -0,0 +1,69 @@ |
|||||
|
odoo.define('account_financial_report_qweb.account_financial_report_widget', function |
||||
|
(require) { |
||||
|
'use strict'; |
||||
|
|
||||
|
var Widget = require('web.Widget'); |
||||
|
|
||||
|
|
||||
|
var accountFinancialReportWidget = Widget.extend({ |
||||
|
events: { |
||||
|
'click .o_account_financial_reports_web_action': 'boundLink', |
||||
|
'click .o_account_financial_reports_web_action_multi': 'boundLinkmulti', |
||||
|
'click .o_account_financial_reports_web_action_monetary': 'boundLinkMonetary', |
||||
|
'click .o_account_financial_reports_web_action_monetary_multi': 'boundLinkMonetarymulti', |
||||
|
}, |
||||
|
init: function() { |
||||
|
this._super.apply(this, arguments); |
||||
|
}, |
||||
|
start: function() { |
||||
|
return this._super.apply(this, arguments); |
||||
|
}, |
||||
|
boundLink: function(e) { |
||||
|
var res_model = $(e.target).data('res-model'); |
||||
|
var res_id = $(e.target).data('active-id'); |
||||
|
return this.do_action({ |
||||
|
type: 'ir.actions.act_window', |
||||
|
res_model: res_model, |
||||
|
res_id: res_id, |
||||
|
views: [[false, 'form']], |
||||
|
target: 'current' |
||||
|
}); |
||||
|
}, |
||||
|
boundLinkmulti: function(e) { |
||||
|
var res_model = $(e.target).data('res-model'); |
||||
|
var domain = $(e.target).data('domain'); |
||||
|
return this.do_action({ |
||||
|
type: 'ir.actions.act_window', |
||||
|
res_model: res_model, |
||||
|
domain: domain, |
||||
|
views: [[false, "list"], [false, "form"]], |
||||
|
target: 'current' |
||||
|
}); |
||||
|
}, |
||||
|
boundLinkMonetary: function(e) { |
||||
|
var res_model = $(e.target.parentElement).data('res-model'); |
||||
|
var res_id = $(e.target.parentElement).data('active-id'); |
||||
|
return this.do_action({ |
||||
|
type: 'ir.actions.act_window', |
||||
|
res_model: res_model, |
||||
|
res_id: res_id, |
||||
|
views: [[false, 'form']], |
||||
|
target: 'current' |
||||
|
}); |
||||
|
}, |
||||
|
boundLinkMonetarymulti: function(e) { |
||||
|
var res_model = $(e.target.parentElement).data('res-model'); |
||||
|
var domain = $(e.target.parentElement).data('domain'); |
||||
|
return this.do_action({ |
||||
|
type: 'ir.actions.act_window', |
||||
|
res_model: res_model, |
||||
|
domain: domain, |
||||
|
views: [[false, "list"], [false, "form"]], |
||||
|
target: 'current' |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
return accountFinancialReportWidget; |
||||
|
|
||||
|
}); |
@ -0,0 +1,79 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Copyright 2018 Eficent Business and IT Consulting Services S.L. |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import logging |
||||
|
from . import abstract_test |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class AbstractTestForeignCurrency(abstract_test.AbstractTest): |
||||
|
"""Common technical tests for all reports.""" |
||||
|
|
||||
|
def _chart_template_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._chart_template_create() |
||||
|
# Account for foreign payments |
||||
|
self.account_type_other = self.env['account.account.type'].create( |
||||
|
{'name': 'foreign expenses', |
||||
|
'type': 'other', |
||||
|
}) |
||||
|
act = self.env['account.account.template'].create({ |
||||
|
'code': '0012', |
||||
|
'name': 'Foreign Expenses', |
||||
|
'user_type_id': self.account_type_other.id, |
||||
|
'chart_template_id': self.chart.id, |
||||
|
'currency_id': self.env.ref('base.EUR').id, |
||||
|
}) |
||||
|
self.env['ir.model.data'].create({ |
||||
|
'res_id': act.id, |
||||
|
'model': act._name, |
||||
|
'name': 'foreign expenses', |
||||
|
}) |
||||
|
return True |
||||
|
|
||||
|
def _add_chart_of_accounts(self): |
||||
|
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts() |
||||
|
self.foreign_expense = self.env['account.account'].search( |
||||
|
[('currency_id', '=', self.env.ref('base.EUR').id)], limit=1) |
||||
|
self.foreign_currency_id = self.foreign_expense.currency_id |
||||
|
return True |
||||
|
|
||||
|
def _journals_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._journals_create() |
||||
|
self.journal_foreign_purchases = self.env['account.journal'].create({ |
||||
|
'company_id': self.company.id, |
||||
|
'name': 'Test journal for purchase', |
||||
|
'type': 'purchase', |
||||
|
'code': 'TFORPUR', |
||||
|
'default_debit_account_id': self.foreign_expense.id, |
||||
|
'default_credit_account_id': self.foreign_expense.id, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
}) |
||||
|
return True |
||||
|
|
||||
|
def _invoice_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._invoice_create() |
||||
|
# vendor bill foreign currency |
||||
|
foreign_vendor_invoice_lines = [(0, False, { |
||||
|
'name': 'Test description #1', |
||||
|
'account_id': self.revenue.id, |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100.0, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
}), (0, False, { |
||||
|
'name': 'Test description #2', |
||||
|
'account_id': self.revenue.id, |
||||
|
'quantity': 2.0, |
||||
|
'price_unit': 25.0, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
})] |
||||
|
self.foreign_invoice_in = self.env['account.invoice'].create({ |
||||
|
'partner_id': self.partner.id, |
||||
|
'type': 'in_invoice', |
||||
|
'invoice_line_ids': foreign_vendor_invoice_lines, |
||||
|
'account_id': self.partner.property_account_payable_id.id, |
||||
|
'journal_id': self.journal_foreign_purchases.id, |
||||
|
}) |
||||
|
self.foreign_invoice_in.action_invoice_open() |
||||
|
return True |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="report_aged_partner_balance_html"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report_qweb.report_buttons"/> |
||||
|
<t t-call="account_financial_report_qweb.report_aged_partner_balance_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="report_general_ledger_html"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report_qweb.report_buttons"/> |
||||
|
<t t-call="account_financial_report_qweb.report_general_ledger_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="report_journal_html"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report_qweb.report_buttons"/> |
||||
|
<t t-call="account_financial_report_qweb.report_journal_qweb_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="report_open_items_html"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report_qweb.report_buttons"/> |
||||
|
<t t-call="account_financial_report_qweb.report_open_items_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,57 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<template id="account_financial_report_assets_backend" |
||||
|
name="account_financial_report assets" inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<link href="/account_financial_report_qweb/static/src/css/report.css" rel="stylesheet"/> |
||||
|
<script type="text/javascript" |
||||
|
src="/account_financial_report_qweb/static/src/js/account_financial_report_qweb_backend.js"/> |
||||
|
<script type="text/javascript" |
||||
|
src="/account_financial_report_qweb/static/src/js/account_financial_report_qweb_widgets.js"/> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
<template id="report_buttons"> |
||||
|
<div class="button_row"> |
||||
|
<button class="o_account_financial_reports_print btn btn-sm oe_button"><span class="fa fa-print"/> Print</button> |
||||
|
<button class="o_account_financial_reports_export btn btn-sm oe_button"><span class="fa fa-download"/> Export</button> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<record id="action_report_general_ledger" model="ir.actions.client"> |
||||
|
<field name="name">General Ledger</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_general_ledger_qweb'}" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_report_journal_ledger" model="ir.actions.client"> |
||||
|
<field name="name">Journal</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_journal_qweb'}" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_report_open_items" model="ir.actions.client"> |
||||
|
<field name="name">Open Items</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_open_items_qweb'}" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_report_trial_balance" model="ir.actions.client"> |
||||
|
<field name="name">Trial Balance</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_trial_balance_qweb'}" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_report_aged_partner_balance" model="ir.actions.client"> |
||||
|
<field name="name">Aged Partner Balance</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_aged_partner_balance_qweb'}" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_report_vat_report" model="ir.actions.client"> |
||||
|
<field name="name">VAT Report</field> |
||||
|
<field name="tag">account_financial_report_backend</field> |
||||
|
<field name="context" eval="{'active_model': 'report_vat_report'}" /> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,11 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<template id="report_trial_balance_html"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report_qweb.report_buttons"/> |
||||
|
<t t-call="account_financial_report_qweb.report_trial_balance_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue