@@ -231,9 +219,11 @@
[[ repeatIn(get_lines(data), 'a') ]]
[[ (a.get('level') <> 0) or removeParentNode('tr') ]]
[[ setTag('tr','tr',{'style': 'Table'+str(min(3,'level' in a and a.get('level') or 1))}) ]]
- [[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.get('level')))+'_name'}) ]][[ a.get('name') ]] |
- [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
- [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_name'}) ]][[ a.get('name') ]] |
+ [[ a.get('account_type') =='view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
+ [[ a.get('account_type') <>'view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
@@ -256,11 +246,15 @@
[[ repeatIn(get_lines(data), 'a') ]]
[[ (a.get('level') <> 0) or removeParentNode('tr') ]]
[[ setTag('tr','tr',{'style': 'Table'+str(min(3,'level' in a and a.get('level') or 1))}) ]]
- [[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.get('level')))+'_name'}) ]][[ a.get('name') ]] |
- [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
- [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
- [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] |
- [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] |
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_name'}) ]][[ a.get('name') ]] |
+ [[ a.get('account_type') =='view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
+ [[ a.get('account_type') <>'view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] |
+ [[ a.get('account_type') =='view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] |
+ [[ a.get('account_type') <>'view' or removeParentNode('td') ]]
+ [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] |
diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py
index d43adeef2be..2669a3d174c 100644
--- a/addons/account/report/account_journal.py
+++ b/addons/account/report/account_journal.py
@@ -30,8 +30,9 @@ class journal_print(report_sxw.rml_parse, common_report_header):
context = {}
super(journal_print, self).__init__(cr, uid, name, context=context)
self.period_ids = []
+ self.last_move_id = False
self.journal_ids = []
- self.sort_selection = 'date'
+ self.sort_selection = 'am.name'
self.localcontext.update({
'time': time,
'lines': self.lines,
@@ -47,6 +48,10 @@ class journal_print(report_sxw.rml_parse, common_report_header):
'display_currency':self._display_currency,
'get_sortby': self._get_sortby,
'get_target_move': self._get_target_move,
+ 'check_last_move_id': self.check_last_move_id,
+ 'set_last_move_id': self.set_last_move_id,
+ 'tax_codes': self.tax_codes,
+ 'sum_vat': self._sum_vat,
})
def set_context(self, objects, data, ids, report_type=None):
@@ -55,17 +60,53 @@ class journal_print(report_sxw.rml_parse, common_report_header):
self.query_get_clause = ''
self.target_move = data['form'].get('target_move', 'all')
if (data['model'] == 'ir.ui.menu'):
+ self.period_ids = tuple(data['form']['periods'])
+ self.journal_ids = tuple(data['form']['journal_ids'])
new_ids = data['form'].get('active_ids', [])
self.query_get_clause = 'AND '
self.query_get_clause += obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
self.sort_selection = data['form'].get('sort_selection', 'date')
objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids)
- if new_ids:
+ elif new_ids:
+ #in case of direct access from account.journal.period object, we need to set the journal_ids and periods_ids
self.cr.execute('SELECT period_id, journal_id FROM account_journal_period WHERE id IN %s', (tuple(new_ids),))
res = self.cr.fetchall()
self.period_ids, self.journal_ids = zip(*res)
return super(journal_print, self).set_context(objects, data, ids, report_type=report_type)
+ def set_last_move_id(self, move_id):
+ self.last_move_id = move_id
+
+ def check_last_move_id(self, move_id):
+ '''
+ return True if we need to draw a gray line above this line, used to separate moves
+ '''
+ if self.last_move_id:
+ return not(self.last_move_id == move_id)
+ return False
+
+ def tax_codes(self, period_id, journal_id):
+ ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid,
+ [('journal_id', '=', journal_id), ('period_id', '=', period_id)])
+ self.cr.execute(
+ 'select distinct tax_code_id from account_move_line ' \
+ 'where period_id=%s and journal_id=%s and tax_code_id is not null and state<>\'draft\'',
+ (period_id, journal_id)
+ )
+ ids = map(lambda x: x[0], self.cr.fetchall())
+ tax_code_ids = []
+ if ids:
+ self.cr.execute('select id from account_tax_code where id in %s order by code', (tuple(ids),))
+ tax_code_ids = map(lambda x: x[0], self.cr.fetchall())
+ tax_codes = self.pool.get('account.tax.code').browse(self.cr, self.uid, tax_code_ids)
+ return tax_codes
+
+ def _sum_vat(self, period_id, journal_id, tax_code_id):
+ self.cr.execute('select sum(tax_amount) from account_move_line where ' \
+ 'period_id=%s and journal_id=%s and tax_code_id=%s and state<>\'draft\'',
+ (period_id, journal_id, tax_code_id))
+ return self.cr.fetchone()[0] or 0.0
+
def _sum_debit(self, period_id=False, journal_id=False):
if journal_id and isinstance(journal_id, int):
journal_id = [journal_id]
@@ -118,7 +159,7 @@ class journal_print(report_sxw.rml_parse, common_report_header):
if self.target_move == 'posted':
move_state = ['posted']
- self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + ', l.move_id',(tuple(move_state), period_id, tuple(journal_id) ))
+ self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY '+ self.sort_selection + ', l.move_id',(tuple(move_state), period_id, tuple(journal_id) ))
ids = map(lambda x: x[0], self.cr.fetchall())
return obj_mline.browse(self.cr, self.uid, ids)
@@ -155,5 +196,6 @@ class journal_print(report_sxw.rml_parse, common_report_header):
return 'Date'
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='internal')
+report_sxw.report_sxw('report.account.journal.period.print.sale.purchase', 'account.journal.period', 'addons/account/report/account_journal_sale_purchase.rml', parser=journal_print, header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml
index 122b195c1ef..fb203d4e664 100644
--- a/addons/account/report/account_journal.rml
+++ b/addons/account/report/account_journal.rml
@@ -18,10 +18,7 @@
-
-
-
-
+
@@ -119,11 +116,17 @@
-
-
-
+
-
+
+
+
+
+
+
+
+
+
@@ -173,101 +176,92 @@
[[ repeatIn(objects, 'o') ]]
-
+
-
- Journal
- |
+ Journal |
-
-
-
-
-
-
- [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]]
- [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] |
- Fiscal Year |
- Journal |
- Filters By |
- Entries Sorted By |
- Target Moves |
-
-
- [[ get_account(data) or '' ]] |
- [[ get_fiscalyear(data) or '' ]] |
- [[o.journal_id.name ]] |
- [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]]
- [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]]
-
- Start Date |
- End Date |
-
-
- [[ formatLang(get_start_date(data),date=True) ]] |
- [[ formatLang(get_end_date(data),date=True) ]] |
-
-
- [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]]
-
- Start Period |
- End Period |
-
-
- [[ get_start_period(data) or removeParentNode('para') ]] |
- [[ get_end_period(data) or removeParentNode('para') ]] |
-
-
- |
- [[ get_sortby(data) ]] |
- [[ get_target_move(data) ]] |
-
-
-
-
- [[ display_currency(data) == False or removeParentNode('blockTable') ]]
+
- Date |
- Ref |
- Move |
- Account |
- Partner |
- Label |
- Debit |
- Credit |
+ [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]]
+ [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] |
+ Fiscal Year |
+ Journal |
+ Period |
+ Entries Sorted By |
+ Target Moves |
-
- [[o.period_id.name ]] |
- [[ o.journal_id.code ]] |
- |
- |
- |
- |
- [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
- [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
-
- [[lines(o.period_id.id, o.journal_id.id) or removeParentNode('story') ]]
- [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line.date,date=True) ]] |
- [[ strip_name(line.ref,20) ]] |
- [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
- [[ line.account_id.code ]] |
- [[ line.partner_id and strip_name(line.partner_id.name,17) ]] |
- [[ strip_name(line.name,27) ]] |
- [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
- [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
+ [[ get_account(data) or '' ]] |
+ [[ get_fiscalyear(data) or '' ]] |
+ [[ o.journal_id.name ]] |
+ [[ o.period_id.name ]] |
+ [[ get_sortby(data) ]] |
+ [[ get_target_move(data) ]] |
+
+
+
+
+
+
+ [[ set_last_move_id(False)]]
+
+ [[ display_currency(data) == False or removeParentNode('section') ]]
+
+
+ Move |
+ Date |
+ Account |
+ Partner |
+ Label |
+ Debit |
+ Credit |
+
+
+
+ [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]]
+
+
+ [[ not check_last_move_id(line.move_id.id) and removeParentNode('blockTable') ]] |
+
+
+
+
+ [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
+ [[ formatLang(line.date,date=True) ]] |
+ [[ line.account_id.code ]] |
+ [[ line.partner_id and strip_name(line.partner_id.name,23) ]] |
+ [[ strip_name(line.name,35) ]] |
+ [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
+
+
+ [[ set_last_move_id(line.move_id.id) ]]
+
+
+
+ |
+ |
+ |
+ |
+ Total: |
+ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+ [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+
+
+
- [[ display_currency(data) or removeParentNode('blockTable') ]]
+
+ [[ display_currency(data) or removeParentNode('section') ]]
+
- Date |
- Ref |
Move |
+ Date |
Account |
Partner |
Label |
@@ -275,30 +269,41 @@
Credit |
Currency |
-
- [[o.period_id.name ]] |
- [[ o.journal_id.code ]] |
- |
- |
- |
- |
- [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
- [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
-
- |
-
- [[lines(o.period_id.id, o.journal_id.id) or removeParentNode('story') ]]
-
- [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line.date,date=True) ]] |
- [[ strip_name(line.ref,20) ]] |
- [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
- [[ line.account_id.code ]] |
- [[ line.partner_id and strip_name(line.partner_id.name,15) ]] |
- [[ strip_name(line.name,17) ]] |
- [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
- [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
- [[ line.currency_id and formatLang(line.amount_currency, currency_obj=line.currency_id) or '' ]] |
-
-
+
+
+ [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]]
+
+
+ [[ not check_last_move_id(line.move_id.id) and removeParentNode('blockTable') ]] |
+
+
+
+
+ [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
+ [[ formatLang(line.date,date=True) ]] |
+ [[ line.account_id.code ]] |
+ [[ line.partner_id and strip_name(line.partner_id.name,17) ]] |
+ [[ strip_name(line.name,28) ]] |
+ [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
+ [[ line.currency_id and formatLang(line.amount_currency, currency_obj=line.currency_id) or '' ]] |
+
+
+ [[ set_last_move_id(line.move_id.id) ]]
+
+
+
+ |
+ |
+ |
+ |
+ Total: |
+ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+ [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+
+ |
+
+
+
diff --git a/addons/account/report/account_journal_sale_purchase.rml b/addons/account/report/account_journal_sale_purchase.rml
new file mode 100644
index 00000000000..68f93b88294
--- /dev/null
+++ b/addons/account/report/account_journal_sale_purchase.rml
@@ -0,0 +1,346 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ repeatIn(objects, 'o') ]]
+
+
+
+ Journal |
+
+
+
+
+
+
+
+ [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]]
+ [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] |
+ Fiscal Year |
+ Journal |
+ Period |
+ Entries Sorted By |
+ Target Moves |
+
+
+ [[ get_account(data) or '' ]] |
+ [[ get_fiscalyear(data) or '' ]] |
+ [[ o.journal_id.name ]] |
+ [[ o.period_id.name ]] |
+ [[ get_sortby(data) ]] |
+ [[ get_target_move(data) ]] |
+
+
+
+
+
+
+
+
+ [[ set_last_move_id(False) ]]
+
+ [[ display_currency(data) == False or removeParentNode('section') ]]
+
+
+ Move |
+ Date |
+ Account |
+ Partner |
+ Label |
+ VAT |
+ |
+ Debit |
+ Credit |
+
+
+
+ [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]]
+
+
+ [[ not check_last_move_id(line.move_id.id) and removeParentNode('blockTable') ]] |
+
+
+
+
+ [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
+ [[ formatLang(line.date,date=True) ]] |
+ [[ line.account_id.code ]] |
+ [[ line.partner_id and strip_name(line.partner_id.name,15) ]] |
+ [[ strip_name(line.name,25) ]] |
+ [[ line.tax_code_id and (line.tax_code_id.code + ':') ]] |
+ [[ line.tax_amount and formatLang(line.tax_amount, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
+
+
+ [[ set_last_move_id(line.move_id.id) ]]
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ Total: |
+ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+ [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+
+
+
+
+
+ [[ display_currency(data) or removeParentNode('section') ]]
+
+
+ Move |
+ Date |
+ Account |
+ Partner |
+ Label |
+ VAT |
+ |
+ Debit |
+ Credit |
+ Currency |
+
+
+
+ [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]]
+
+
+ [[ not check_last_move_id(line.move_id.id) and removeParentNode('blockTable') ]] |
+
+
+
+
+ [[ line.move_id.name <> '/' and line.move_id.name or ('*'+str(line.move_id.id)) ]] |
+ [[ formatLang(line.date,date=True) ]] |
+ [[ line.account_id.code ]] |
+ [[ line.partner_id and strip_name(line.partner_id.name,12) ]] |
+ [[ strip_name(line.name,16) ]] |
+ [[ line.tax_code_id and (line.tax_code_id.code + ':') ]] |
+ [[ line.tax_amount and formatLang(line.tax_amount, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.debit, currency_obj=company.currency_id) ]] |
+ [[ formatLang(line.credit, currency_obj=company.currency_id) ]] |
+ [[ line.currency_id and formatLang(line.amount_currency, currency_obj=line.currency_id) or '' ]] |
+
+
+ [[ set_last_move_id(line.move_id.id) ]]
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ Total: |
+ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+ [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] |
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ VAT Declaration |
+ |
+ |
+
+
+ [[ repeatIn(tax_codes(o.period_id.id,o.journal_id.id), 't') ]][[ t.code + ': ' ]] |
+ [[ formatLang(sum_vat( o.period_id.id, o.journal_id.id, t.id)) ]] |
+ |
+ [[ t.name ]] |
+
+
+
+
+
diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/account_tax_report.py
index a3bdc1a75f6..2a0c5987b47 100644
--- a/addons/account/report/account_tax_report.py
+++ b/addons/account/report/account_tax_report.py
@@ -32,6 +32,7 @@ class tax_report(report_sxw.rml_parse, common_report_header):
res = {}
self.period_ids = []
period_obj = self.pool.get('account.period')
+ self.display_detail = data['form']['display_detail']
res['periods'] = ''
res['fiscalyear'] = data['form'].get('fiscalyear_id', False)
@@ -104,6 +105,8 @@ class tax_report(report_sxw.rml_parse, common_report_header):
return top_result
def _get_general(self, tax_code_id, period_list, company_id, based_on, context=None):
+ if not self.display_detail:
+ return []
res = []
obj_account = self.pool.get('account.account')
periods_ids = tuple(period_list)
@@ -159,7 +162,7 @@ class tax_report(report_sxw.rml_parse, common_report_header):
def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context=None):
obj_tc = self.pool.get('account.tax.code')
- ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], context=context)
+ ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], order='sequence', context=context)
res = []
for code in obj_tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
@@ -229,4 +232,4 @@ class tax_report(report_sxw.rml_parse, common_report_header):
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
'addons/account/report/account_tax_report.rml', parser=tax_report, header="internal")
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml
index 45b5605ce31..6a4d04daa70 100644
--- a/addons/account/test/account_report.yml
+++ b/addons/account/test/account_report.yml
@@ -102,7 +102,7 @@
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
ctx={}
ctx.update({'model': 'account.journal.period','active_ids':journal_ids})
- data_dict = {'chart_account_id':ref('account.chart0')}
+ data_dict = {'chart_account_id':ref('account.chart0'), 'period_from':ref('period_1'), 'period_to':ref('period_12')}
from tools import test_reports
test_reports.try_report_action(cr, uid, 'action_account_print_journal',wiz_data=data_dict, context=ctx, our_module='account')
-
diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py
index d2295b5bbf2..849a7a9f514 100644
--- a/addons/account/wizard/account_fiscalyear_close.py
+++ b/addons/account/wizard/account_fiscalyear_close.py
@@ -105,6 +105,7 @@ class account_fiscalyear_close(osv.osv_memory):
'name': '/',
'ref': '',
'period_id': period.id,
+ 'date': period.date_start,
'journal_id': new_journal.id,
}
move_id = obj_acc_move.create(cr, uid, vals, context=context)
@@ -118,7 +119,6 @@ class account_fiscalyear_close(osv.osv_memory):
AND a.type != 'view'
AND t.close_method = %s''', ('unreconciled', ))
account_ids = map(lambda x: x[0], cr.fetchall())
-
if account_ids:
cr.execute('''
INSERT INTO account_move_line (
@@ -130,11 +130,11 @@ class account_fiscalyear_close(osv.osv_memory):
(SELECT name, create_uid, create_date, write_uid, write_date,
statement_id, %s,currency_id, date_maturity, partner_id,
blocked, credit, 'draft', debit, ref, account_id,
- %s, date, %s, amount_currency, quantity, product_id, company_id
+ %s, (%s) AS date, %s, amount_currency, quantity, product_id, company_id
FROM account_move_line
WHERE account_id IN %s
AND ''' + query_line + '''
- AND reconcile_id IS NULL)''', (new_journal.id, period.id, move_id, tuple(account_ids),))
+ AND reconcile_id IS NULL)''', (new_journal.id, period.id, period.date_start, move_id, tuple(account_ids),))
#We have also to consider all move_lines that were reconciled
#on another fiscal year, and report them too
@@ -149,7 +149,7 @@ class account_fiscalyear_close(osv.osv_memory):
b.name, b.create_uid, b.create_date, b.write_uid, b.write_date,
b.statement_id, %s, b.currency_id, b.date_maturity,
b.partner_id, b.blocked, b.credit, 'draft', b.debit,
- b.ref, b.account_id, %s, b.date, %s, b.amount_currency,
+ b.ref, b.account_id, %s, (%s) AS date, %s, b.amount_currency,
b.quantity, b.product_id, b.company_id
FROM account_move_line b
WHERE b.account_id IN %s
@@ -157,7 +157,7 @@ class account_fiscalyear_close(osv.osv_memory):
AND b.period_id IN ('''+fy_period_set+''')
AND b.reconcile_id IN (SELECT DISTINCT(reconcile_id)
FROM account_move_line a
- WHERE a.period_id IN ('''+fy2_period_set+''')))''', (new_journal.id, period.id, move_id, tuple(account_ids),))
+ WHERE a.period_id IN ('''+fy2_period_set+''')))''', (new_journal.id, period.id, period.date_start, move_id, tuple(account_ids),))
#2. report of the accounts with defferal method == 'detail'
cr.execute('''
@@ -180,11 +180,11 @@ class account_fiscalyear_close(osv.osv_memory):
(SELECT name, create_uid, create_date, write_uid, write_date,
statement_id, %s,currency_id, date_maturity, partner_id,
blocked, credit, 'draft', debit, ref, account_id,
- %s, date, %s, amount_currency, quantity, product_id, company_id
+ %s, (%s) AS date, %s, amount_currency, quantity, product_id, company_id
FROM account_move_line
WHERE account_id IN %s
AND ''' + query_line + ''')
- ''', (new_journal.id, period.id, move_id, tuple(account_ids),))
+ ''', (new_journal.id, period.id, period.date_start, move_id, tuple(account_ids),))
#3. report of the accounts with defferal method == 'balance'
diff --git a/addons/account/wizard/account_report_common.py b/addons/account/wizard/account_report_common.py
index 8ae425e0b15..50c5d4adbae 100644
--- a/addons/account/wizard/account_report_common.py
+++ b/addons/account/wizard/account_report_common.py
@@ -29,8 +29,14 @@ class account_common_report(osv.osv_memory):
_name = "account.common.report"
_description = "Account Common Report"
+ def onchange_chart_id(self, cr, uid, ids, chart_account_id=False, context=None):
+ if chart_account_id:
+ company_id = self.pool.get('account.account').browse(cr, uid, chart_account_id, context=context).company_id.id
+ return {'value': {'company_id': company_id}}
+
_columns = {
'chart_account_id': fields.many2one('account.account', 'Chart of Account', help='Select Charts of Accounts', required=True, domain = [('parent_id','=',False)]),
+ 'company_id': fields.related('chart_account_id', 'company_id', type='many2one', relation='res.company', string='Company', readonly=True),
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', help='Keep empty for all open fiscal year'),
'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by", required=True),
'period_from': fields.many2one('account.period', 'Start Period'),
@@ -44,6 +50,22 @@ class account_common_report(osv.osv_memory):
}
+ def _check_company_id(self, cr, uid, ids, context=None):
+ for wiz in self.browse(cr, uid, ids, context=context):
+ company_id = wiz.company_id.id
+ if wiz.fiscalyear_id and company_id != wiz.fiscalyear_id.company_id.id:
+ return False
+ if wiz.period_from and company_id != wiz.period_from.company_id.id:
+ return False
+ if wiz.period_to and company_id != wiz.period_to.company_id.id:
+ return False
+ return True
+
+ _constraints = [
+ (_check_company_id, 'The fiscalyear, periods or chart of account chosen have to belong to the same company.', ['chart_account_id','fiscalyear_id','period_from','period_to']),
+ ]
+
+
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(account_common_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
if context.get('active_model', False) == 'account.account' and view_id:
diff --git a/addons/account/wizard/account_report_common_journal.py b/addons/account/wizard/account_report_common_journal.py
index e71d380e837..92076cfe572 100644
--- a/addons/account/wizard/account_report_common_journal.py
+++ b/addons/account/wizard/account_report_common_journal.py
@@ -29,13 +29,16 @@ class account_common_journal_report(osv.osv_memory):
'amount_currency': fields.boolean("With Currency", help="Print Report with the currency column if the currency is different then the company currency"),
}
- def _build_context(self, cr, uid, ids, data, context=None):
+ def _build_contexts(self, cr, uid, ids, data, context=None):
if context is None:
context = {}
- result = super(account_common_journal_report, self)._build_context(cr, uid, ids, data, context=context)
+ result = super(account_common_journal_report, self)._build_contexts(cr, uid, ids, data, context=context)
+
if data['form']['filter'] == 'filter_date':
cr.execute('SELECT period_id FROM account_move_line WHERE date >= %s AND date <= %s', (data['form']['date_from'], data['form']['date_to']))
result['periods'] = map(lambda x: x[0], cr.fetchall())
+ elif data['form']['filter'] == 'filter_period':
+ result['periods'] = self.pool.get('account.period').build_ctx_periods(cr, uid, data['form']['period_from'], data['form']['period_to'])
return result
def pre_print_report(self, cr, uid, ids, data, context=None):
diff --git a/addons/account/wizard/account_report_common_view.xml b/addons/account/wizard/account_report_common_view.xml
index 30d90a55245..db1da8223d5 100644
--- a/addons/account/wizard/account_report_common_view.xml
+++ b/addons/account/wizard/account_report_common_view.xml
@@ -10,8 +10,9 @@