diff --git a/addons/account/account.py b/addons/account/account.py
index 432a90a653e..278e752cfe4 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -2524,7 +2524,10 @@ class account_account_template(osv.osv):
#deactivate the parent_store functionnality on account_account for rapidity purpose
ctx = context.copy()
ctx.update({'defer_parent_store_computation': True})
- children_acc_template = self.search(cr, uid, ['|', ('chart_template_id','=', chart_template_id),'&',('parent_id','child_of', [template.account_root_id.id]),('chart_template_id','=', False), ('nocreate','!=',True)], order='id')
+ children_acc_criteria = [('chart_template_id','=', chart_template_id)]
+ if template.account_root_id.id:
+ children_acc_criteria = ['|'] + children_acc_criteria + ['&',('parent_id','child_of', [template.account_root_id.id]),('chart_template_id','=', False)]
+ children_acc_template = self.search(cr, uid, [('nocreate','!=',True)] + children_acc_criteria, order='id')
for account_template in self.browse(cr, uid, children_acc_template, context=context):
# skip the root of COA if it's not the main one
if (template.account_root_id.id == account_template.id) and template.parent_id:
@@ -2982,7 +2985,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
tax_templ_obj = self.pool.get('account.tax.template')
if 'bank_accounts_id' in fields:
- res.update({'bank_accounts_id': [{'acc_name': _('Cash'), 'account_type': 'cash'}]})
+ res.update({'bank_accounts_id': [{'acc_name': _('Cash'), 'account_type': 'cash'},{'acc_name': _('Bank'), 'account_type': 'bank'}]})
if 'company_id' in fields:
res.update({'company_id': self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id})
if 'seq_journal' in fields:
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index bd31b01a41d..9cfda051ec1 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -52,8 +52,9 @@ class account_bank_statement(osv.osv):
journal_pool = self.pool.get('account.journal')
journal_type = context.get('journal_type', False)
journal_id = False
+ company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement',context=context)
if journal_type:
- ids = journal_pool.search(cr, uid, [('type', '=', journal_type)])
+ ids = journal_pool.search(cr, uid, [('type', '=', journal_type),('company_id','=',company_id)])
if ids:
journal_id = ids[0]
return journal_id
@@ -169,30 +170,31 @@ class account_bank_statement(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement',context=c),
}
- def onchange_date(self, cr, user, ids, date, context=None):
+ def _check_company_id(self, cr, uid, ids, context=None):
+ for statement in self.browse(cr, uid, ids, context=context):
+ if statement.company_id.id != statement.period_id.company_id.id:
+ return False
+ return True
+
+ _constraints = [
+ (_check_company_id, 'The journal and period chosen have to belong to the same company.', ['journal_id','period_id']),
+ ]
+
+ def onchange_date(self, cr, uid, ids, date, company_id, context=None):
"""
- Returns a dict that contains new values and context
- @param cr: A database cursor
- @param user: ID of the user currently logged in
- @param date: latest value from user input for field date
- @param args: other arguments
- @param context: context arguments, like lang, time zone
- @return: Returns a dict which contains new values, and context
+ Find the correct period to use for the given date and company_id, return it and set it in the context
"""
res = {}
period_pool = self.pool.get('account.period')
if context is None:
context = {}
-
- pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
+ ctx = context.copy()
+ ctx.update({'company_id': company_id})
+ pids = period_pool.find(cr, uid, dt=date, context=ctx)
if pids:
- res.update({
- 'period_id':pids[0]
- })
- context.update({
- 'period_id':pids[0]
- })
+ res.update({'period_id': pids[0]})
+ context.update({'period_id': pids[0]})
return {
'value':res,
@@ -385,8 +387,10 @@ class account_bank_statement(osv.osv):
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cr.fetchone()
balance_start = res and res[0] or 0.0
- account_id = self.pool.get('account.journal').read(cr, uid, journal_id, ['default_debit_account_id'], context=context)['default_debit_account_id']
- return {'value': {'balance_start': balance_start, 'account_id': account_id}}
+ journal_data = self.pool.get('account.journal').read(cr, uid, journal_id, ['default_debit_account_id', 'company_id'], context=context)
+ account_id = journal_data['default_debit_account_id']
+ company_id = journal_data['company_id']
+ return {'value': {'balance_start': balance_start, 'account_id': account_id, 'company_id': company_id}}
def unlink(self, cr, uid, ids, context=None):
stat = self.read(cr, uid, ids, ['state'], context=context)
diff --git a/addons/account/account_financial_report.py b/addons/account/account_financial_report.py
index 4ee8ac3d74b..0688d6f12b1 100644
--- a/addons/account/account_financial_report.py
+++ b/addons/account/account_financial_report.py
@@ -104,20 +104,30 @@ class account_financial_report(osv.osv):
('account_report','Report Value'),
],'Type'),
'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'),
+ 'account_report_id': fields.many2one('account.financial.report', 'Report Value'),
+ 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'),
+ 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'),
'display_detail': fields.selection([
('no_detail','No detail'),
('detail_flat','Display children flat'),
('detail_with_hierarchy','Display children with hierarchy')
], 'Display details'),
- 'account_report_id': fields.many2one('account.financial.report', 'Report Value'),
- 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'),
- 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'),
+ 'style_overwrite': fields.selection([
+ (0, 'Automatic formatting'),
+ (1,'Main Title 1 (bold, underlined)'),
+ (2,'Title 2 (bold)'),
+ (3,'Title 3 (bold, smaller)'),
+ (4,'Normal Text'),
+ (5,'Italic Text (smaller)'),
+ (6,'Smallest Text'),
+ ],'Financial Report Style', help="You can set up here the format you want this record to be displayed. If you leave the automatic formatting, it will be computed based on the financial reports hierarchy (auto-computed field 'level')."),
}
_defaults = {
'type': 'sum',
'display_detail': 'detail_flat',
'sign': 1,
+ 'style_overwrite': 0,
}
account_financial_report()
diff --git a/addons/account/account_financial_report_data.xml b/addons/account/account_financial_report_data.xml
index 18624f94749..6410a5e887c 100644
--- a/addons/account/account_financial_report_data.xml
+++ b/addons/account/account_financial_report_data.xml
@@ -4,23 +4,6 @@
-