*chnaed bahavior of numbering on account_move. The account_move now gets a number only once it is posted, in the meanwhile the name_get display now
'*'+str(account_move.id) *added an overwriting of the function copy on account_move object (to reset state and account move number) *modified views of encoding by move *modified invoice accordingly to latest change of account_move numbering. Cancelling an invoice will keep the account move number it had and will force it the next time it gets validated. bzr revid: qdp@tinyerp.com-20081106142910-8dhs242gi277rt1k
This commit is contained in:
parent
376569e8b6
commit
c8d95cfa95
|
@ -648,7 +648,7 @@ class account_move(osv.osv):
|
|||
data_move = self.pool.get('account.move').browse(cursor,user,ids)
|
||||
for move in data_move:
|
||||
if move.state=='draft':
|
||||
name = '*' + move.name
|
||||
name = '*' + str(move.id)
|
||||
else:
|
||||
name = move.name
|
||||
res.append((move.id, name))
|
||||
|
@ -671,7 +671,7 @@ class account_move(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Entry Name', size=64, required=True),
|
||||
'name': fields.char('Entry Number', size=64, required=True),
|
||||
'ref': fields.char('Ref', size=64),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}),
|
||||
|
@ -692,6 +692,7 @@ class account_move(osv.osv):
|
|||
],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}),
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda *a: '/',
|
||||
'state': lambda *a: 'draft',
|
||||
'period_id': _get_period,
|
||||
'type' : lambda *a : 'journal_voucher',
|
||||
|
@ -727,6 +728,17 @@ class account_move(osv.osv):
|
|||
]
|
||||
def post(self, cr, uid, ids, context=None):
|
||||
if self.validate(cr, uid, ids, context) and len(ids):
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if move.name =='/':
|
||||
new_name = False
|
||||
journal = move.journal_id
|
||||
if journal.sequence_id:
|
||||
new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
||||
else:
|
||||
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
|
||||
if new_name:
|
||||
self.write(cr, uid, [move.id], {'name':new_name})
|
||||
|
||||
cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',))
|
||||
else:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non balanced entry !'))
|
||||
|
@ -772,12 +784,6 @@ class account_move(osv.osv):
|
|||
l[2]['period_id'] = default_period
|
||||
context['period_id'] = default_period
|
||||
|
||||
if not 'name' in vals:
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, context.get('journal_id', vals.get('journal_id', False)))
|
||||
if journal.sequence_id:
|
||||
vals['name'] = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
||||
else:
|
||||
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
|
||||
accnt_journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'])
|
||||
if 'line_id' in vals:
|
||||
c = context.copy()
|
||||
|
@ -788,6 +794,13 @@ class account_move(osv.osv):
|
|||
result = super(account_move, self).create(cr, uid, vals, context)
|
||||
return result
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default.update({'state':'draft', 'name':'/',})
|
||||
return super(account_move, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}, check=True):
|
||||
toremove = []
|
||||
for move in self.browse(cr, uid, ids, context):
|
||||
|
|
|
@ -797,7 +797,8 @@
|
|||
<field name="name"/>
|
||||
<field name="period_id"/>
|
||||
<field name="journal_id"/>
|
||||
|
||||
<field name="partner_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="line_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
@ -812,11 +813,9 @@
|
|||
<form string="Account Entry">
|
||||
<separator colspan="4" string="General Information"/>
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" select="1"/>
|
||||
<field name="name" select="1" readonly="True"/>
|
||||
<field name="period_id" select="2"/>
|
||||
<field name="journal_id" select="1"/>
|
||||
<field name="partner_id" select="2"/>
|
||||
<field name="amount" select="2"/>
|
||||
<field name="ref" select="1" groups="base.group_extended"/>
|
||||
<field name="to_check" select="2" groups="base.group_extended"/>
|
||||
<field name="type" select="1" groups="base.group_extended"/>
|
||||
|
@ -855,8 +854,8 @@
|
|||
<field name="account_id"/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="ref"/>
|
||||
<field name="debit"/>
|
||||
<field name="credit"/>
|
||||
<field name="debit" sum="Total Debit"/>
|
||||
<field name="credit" sum="Total Credit"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
|
@ -191,6 +191,7 @@ class account_invoice(osv.osv):
|
|||
'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Move Lines'),
|
||||
'residual': fields.function(_amount_residual, method=True, digits=(16,2),string='Residual', store=True, help="Remaining amount due."),
|
||||
'payment_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="many2many", string='Payments'),
|
||||
'move_name': fields.char('Account Move', size=64),
|
||||
}
|
||||
_defaults = {
|
||||
'type': _get_type,
|
||||
|
@ -323,7 +324,7 @@ class account_invoice(osv.osv):
|
|||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default.update({'state':'draft', 'number':False, 'move_id':False})
|
||||
default.update({'state':'draft', 'number':False, 'move_id':False, 'move_name':False,})
|
||||
if 'date_invoice' not in default:
|
||||
default['date_invoice'] = False
|
||||
if 'date_due' not in default:
|
||||
|
@ -568,8 +569,10 @@ class account_invoice(osv.osv):
|
|||
|
||||
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
||||
if journal.sequence_id:
|
||||
if journal.sequence_id and not inv.move_name:
|
||||
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
||||
else:
|
||||
name = inv.move_name
|
||||
if journal.centralisation:
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('Can not create invoice move on centralized journal'))
|
||||
|
@ -585,8 +588,9 @@ class account_invoice(osv.osv):
|
|||
for i in line:
|
||||
i[2]['period_id'] = period_id
|
||||
move_id = self.pool.get('account.move').create(cr, uid, move)
|
||||
new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name
|
||||
# make the invoice point to that move
|
||||
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id})
|
||||
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name})
|
||||
self.pool.get('account.move').post(cr, uid, [move_id])
|
||||
self._log_event(cr, uid, ids)
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue