[REVERT]: revert thechange of accounting invoice numbering by/order al@tinyerp.com

bzr revid: mga@tinyerp.com-20100730103301-z1hf9g8l8blwppec
This commit is contained in:
Mantavya Gajjar 2010-07-30 16:03:01 +05:30
parent a1ee3e1f8f
commit ec792eb0ff
3 changed files with 44 additions and 33 deletions

View File

@ -629,8 +629,8 @@ class account_journal(osv.osv):
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'),
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
# 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
# help="The sequence used for invoice numbers in this journal."),
'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
help="The sequence used for invoice numbers in this journal."),
'allow_date':fields.boolean('Check Date not in the Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
}

View File

@ -388,14 +388,15 @@
<field name="centralisation" groups="base.group_extended"/>
<field name="entry_posted"/>
</group>
<group colspan="2" col="2">
<separator string="Invoicing Data" colspan="4"/>
<field name="invoice_sequence_id"/>
<field name="group_invoice_lines"/>
</group>
<group colspan="2" col="2" groups="base.group_extended">
<separator string="Sequence" colspan="4"/>
<field name="sequence_id"/>
</group>
<group colspan="2" col="2">
<separator string="Invoicing Data" colspan="4"/>
<field name="group_invoice_lines"/>
</group>
</page>
<page string="Entry Controls" groups="base.group_extended">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>

View File

@ -231,8 +231,8 @@ class account_invoice(osv.osv):
('in_refund','Supplier Refund'),
],'Type', readonly=True, select=True, change_default=True),
'number': fields.related('move_id','name', type='char', readonly=True, size=64, relation='account.move', store=True, string='Number'),
#'number': fields.char('Invoice Number', size=32, readonly=True, help="Unique number of the invoice, computed automatically when the invoice is created."),
# 'number': fields.related('move_id','name', type='char', readonly=True, size=64, relation='account.move', store=True, string='Number'),
'number': fields.char('Invoice Number', size=32, readonly=True, help="Unique number of the invoice, computed automatically when the invoice is created."),
'reference': fields.char('Invoice Reference', size=64, help="The partner reference of this invoice."),
'reference_type': fields.selection(_get_reference_type, 'Reference Type',
required=True, readonly=True, states={'draft':[('readonly',False)]}),
@ -769,7 +769,7 @@ class account_invoice(osv.osv):
cur_obj = self.pool.get('res.currency')
context = {}
for inv in self.browse(cr, uid, ids):
if not inv.journal_id.sequence_id:
if not inv.journal_id.invoice_sequence_id:
raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))
if not inv.invoice_line:
raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.'))
@ -927,35 +927,45 @@ class account_invoice(osv.osv):
}
def action_number(self, cr, uid, ids, *args):
#TODO: not correct fix but required a frech values before reading it.
self.write(cr, uid, ids, {})
# #TODO: not correct fix but required a frech values before reading it.
# self.write(cr, uid, ids, {})
#
cr.execute('SELECT id, type, number, move_id, reference ' \
'FROM account_invoice ' \
'WHERE id IN ('+','.join(map(str,ids))+')')
obj_inv = self.browse(cr, uid, ids)[0]
for obj_inv in self.browse(cr, uid, ids):
id = obj_inv.id
invtype = obj_inv.type
number = obj_inv.number
move_id = obj_inv.move_id and obj_inv.move_id.id or False
reference = obj_inv.reference or ''
if invtype in ('in_invoice', 'in_refund'):
ref = reference
else:
ref = self._convert_ref(cr, uid, number)
cr.execute('UPDATE account_move SET ref=%s ' \
'WHERE id=%s AND (ref is null OR ref = \'\')',
(ref, move_id))
cr.execute('UPDATE account_move_line SET ref=%s ' \
'WHERE move_id=%s AND (ref is null OR ref = \'\')',
(ref, move_id))
cr.execute('UPDATE account_analytic_line SET ref=%s ' \
'FROM account_move_line ' \
'WHERE account_move_line.move_id = %s ' \
'AND account_analytic_line.move_id = account_move_line.id',
for (id, invtype, number, move_id, reference) in cr.fetchall():
if not number:
if obj_inv.journal_id.invoice_sequence_id:
sid = obj_inv.journal_id.invoice_sequence_id.id
number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id})
else:
number = self.pool.get('ir.sequence').get(cr, uid, 'account.invoice.' + invtype)
if invtype in ('in_invoice', 'in_refund'):
ref = reference
else:
ref = self._convert_ref(cr, uid, number)
cr.execute('UPDATE account_invoice SET number=%s ' \
'WHERE id=%s', (number, id))
cr.execute('UPDATE account_move SET ref=%s ' \
'WHERE id=%s AND (ref is null OR ref = \'\')',
(ref, move_id))
cr.execute('UPDATE account_move_line SET ref=%s ' \
'WHERE move_id=%s AND (ref is null OR ref = \'\')',
(ref, move_id))
cr.execute('UPDATE account_analytic_line SET ref=%s ' \
'FROM account_move_line ' \
'WHERE account_move_line.move_id = %s ' \
'AND account_analytic_line.move_id = account_move_line.id',
(ref, move_id))
for inv_id, name in self.name_get(cr, uid, [id]):
message = _('Invoice ') + " '" + name + "' "+ _("is validated.")
self.log(cr, uid, inv_id, message)
return True
def action_cancel(self, cr, uid, ids, *args):