diff --git a/addons/account/account.py b/addons/account/account.py
index c1a30967aea..c165a7f3b42 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1079,7 +1079,7 @@ class account_period(osv.osv):
def build_ctx_periods(self, cr, uid, period_from_id, period_to_id):
if period_from_id == period_to_id:
- return period_from_id
+ return [period_from_id]
period_from = self.browse(cr, uid, period_from_id)
period_date_start = period_from.date_start
company1_id = period_from.company_id.id
@@ -1652,7 +1652,7 @@ class account_move_reconcile(osv.osv):
'create_date': fields.date('Creation date', readonly=True),
}
_defaults = {
- 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/',
+ 'name': lambda self,cr,uid,ctx=None: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile', context=ctx) or '/',
}
def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None):
diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py
index 5a84dee53de..cbc5a966f79 100644
--- a/addons/account/account_bank.py
+++ b/addons/account/account_bank.py
@@ -55,7 +55,7 @@ class bank(osv.osv):
# Find the code and parent of the bank account to create
dig = 6
current_num = 1
- ids = obj_acc.search(cr, uid, [('type','=','liquidity')], context=context)
+ ids = obj_acc.search(cr, uid, [('type','=','liquidity'), ('company_id', '=', bank.company_id.id)], context=context)
# No liquidity account exists, no template available
if not ids: continue
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 6a2bf7ff0ea..5601179e0fc 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -341,11 +341,11 @@ class account_bank_statement(osv.osv):
if not st.name == '/':
st_number = st.name
else:
+ c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
if st.journal_id.sequence_id:
- c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
st_number = obj_seq.next_by_id(cr, uid, st.journal_id.sequence_id.id, context=c)
else:
- st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement')
+ st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement', context=c)
for line in st.move_line_ids:
if line.state <> 'valid':
@@ -472,6 +472,7 @@ class account_bank_statement_line(osv.osv):
required=True),
'statement_id': fields.many2one('account.bank.statement', 'Statement',
select=True, required=True, ondelete='cascade'),
+ 'journal_id': fields.related('statement_id', 'journal_id', type='many2one', relation='account.journal', string='Journal', store=True, readonly=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'move_ids': fields.many2many('account.move',
'account_bank_statement_line_move_rel', 'statement_line_id','move_id',
diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py
index 226e78ccef6..f19c1e1c639 100644
--- a/addons/account/account_cash_statement.py
+++ b/addons/account/account_cash_statement.py
@@ -212,25 +212,12 @@ class account_cash_statement(osv.osv):
def create(self, cr, uid, vals, context=None):
if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash':
- open_close = self._get_cash_open_close_box_lines(cr, uid, context)
- if vals.get('starting_details_ids', False):
- for start in vals.get('starting_details_ids'):
- dict_val = start[2]
- for end in open_close['end']:
- if end[2]['pieces'] == dict_val['pieces']:
- end[2]['number'] += dict_val['number']
- vals.update({
-# 'ending_details_ids': open_close['start'],
- 'starting_details_ids': open_close['end']
- })
- else:
- vals.update({
- 'ending_details_ids': False,
- 'starting_details_ids': False
- })
- res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context)
- self.write(cr, uid, [res_id], {})
- return res_id
+ amount_total = 0.0
+ for line in vals.get('starting_details_ids',[]):
+ if line and len(line)==3 and line[2]:
+ amount_total+= line[2]['pieces'] * line[2]['number']
+ vals.update(balance_start= amount_total)
+ return super(account_cash_statement, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context=None):
"""
@@ -292,11 +279,11 @@ class account_cash_statement(osv.osv):
raise osv.except_osv(_('Error !'), (_('User %s does not have rights to access %s journal !') % (statement.user_id.name, statement.journal_id.name)))
if statement.name and statement.name == '/':
+ c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id}
if statement.journal_id.sequence_id:
- c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id}
st_number = obj_seq.next_by_id(cr, uid, statement.journal_id.sequence_id.id, context=c)
else:
- st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement')
+ st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement', context=c)
vals.update({
'name': st_number
})
diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml
index 6c651405c92..f06a456037f 100644
--- a/addons/account/account_menuitem.xml
+++ b/addons/account/account_menuitem.xml
@@ -10,27 +10,28 @@
-
+
-
+
-
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+