[IMP] account: automatic sequence on bank statement lines

[FIX] account: multi company on bank/cash statement

bzr revid: qdp-launchpad@tinyerp.com-20100914175307-2g876zrv7vtdnrvl
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-09-14 19:53:07 +02:00
parent 15836238a4
commit 3d9c59ff01
3 changed files with 26 additions and 14 deletions

View File

@ -29,6 +29,24 @@ import decimal_precision as dp
class account_bank_statement(osv.osv):
def create(self, cr, uid, vals, context=None):
seq = 0
for line in vals['line_ids']:
seq += 1
line[2]['sequence'] = seq
vals[seq - 1] = line
return super(account_bank_statement, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context=None):
res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
for statement in self.browse(cr, uid, ids, context):
seq = 0
for line in statement.line_ids:
seq += 1
if not line.sequence:
self.pool.get('account.bank.statement.line').write(cr, uid, [line.id], {'sequence': seq}, context=context)
return res
def button_import_invoice(self, cr, uid, ids, context=None):
mod_obj = self.pool.get('ir.model.data')
if context is None:
@ -141,7 +159,7 @@ class account_bank_statement(osv.osv):
'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'),
states={'confirm':[('readonly', True)]}),
'balance_end': fields.function(_end_balance, method=True, string='Balance'),
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'line_ids': fields.one2many('account.bank.statement.line',
'statement_id', 'Statement lines',
states={'confirm':[('readonly', True)]}),
@ -717,7 +735,6 @@ class account_bank_statement_line(osv.osv):
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
'date': lambda *a: time.strftime('%Y-%m-%d'),
'type': lambda *a: 'general',
'sequence': lambda *a: 10,
}
account_bank_statement_line()

View File

@ -204,7 +204,6 @@ class account_cash_statement(osv.osv):
return res
_columns = {
'company_id':fields.many2one('res.company', 'Company', required=True, states={'draft': [('readonly', False)]}, readonly=True,),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True, domain=[('type', '=', 'cash')]),
'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"),
'state': fields.selection(
@ -224,22 +223,18 @@ class account_cash_statement(osv.osv):
'state': lambda *a: 'draft',
'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"),
'user_id': lambda self, cr, uid, context=None: uid,
'company_id': _get_company,
'starting_details_ids':_get_cash_open_box_lines,
'ending_details_ids':_get_default_cash_close_box_lines
}
def create(self, cr, uid, vals, context=None):
company_id = vals and vals.get('company_id',False)
if company_id:
sql = [
('company_id', '=', vals['company_id']),
sql = [
('journal_id', '=', vals['journal_id']),
('state', '=', 'open')
]
open_jrnl = self.search(cr, uid, sql)
if open_jrnl:
raise osv.except_osv('Error', _('You can not have two open register for the same journal'))
]
open_jrnl = self.search(cr, uid, sql)
if open_jrnl:
raise osv.except_osv('Error', _('You can not have two open register for the same journal'))
if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash':
lines = end_lines = self._get_cash_close_box_lines(cr, uid, [], context)

View File

@ -524,7 +524,7 @@
<page string="Transaction">
<field colspan="4" name="line_ids" nolabel="1">
<tree editable="bottom" string="Statement lines">
<field name="sequence"/>
<field name="sequence" readonly="1"/>
<field name="date"/>
<field name="ref"/>
<field name="name"/>
@ -546,7 +546,7 @@
<field name="amount"/>
<field context="{'partner_id':partner_id,'amount':amount,'account_id':account_id,'currency_id': parent.currency,'journal_id':parent.journal_id, 'date':date}" name="reconcile_id"/>
<field name="ref"/>
<field name="sequence"/>
<field name="sequence" readonly="0"/>
<separator colspan="4" string="Notes"/>
<field colspan="4" name="note" nolabel="1"/>
</form>