[IMP] account_voucher: code cleaning
bzr revid: ara@tinyerp.com-20101026133352-0tb4fmrby1yv8vyg
This commit is contained in:
@@ -24,4 +24,4 @@ import invoice
|
||||
import report
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -573,6 +573,7 @@ class account_voucher(osv.osv):
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
if not inv.line_ids:
|
||||
raise osv.except_osv(_('No Lines !'), _('Please create some lines'))
|
||||
@@ -581,7 +582,7 @@ class account_voucher(osv.osv):
|
||||
if inv.number:
|
||||
name = inv.number
|
||||
elif inv.journal_id.sequence_id:
|
||||
name = self.pool.get('ir.sequence').get_id(cr, uid, inv.journal_id.sequence_id.id)
|
||||
name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
|
||||
else:
|
||||
raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
|
||||
if not inv.reference:
|
||||
@@ -687,7 +688,7 @@ class account_voucher(osv.osv):
|
||||
rec_ids = [master_line, line.move_line_id.id]
|
||||
rec_list_ids.append(rec_ids)
|
||||
|
||||
if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total):
|
||||
if not currency_pool.is_zero(cr, uid, inv.currency_id, line_total):
|
||||
diff = line_total
|
||||
move_line = {
|
||||
'name': name,
|
||||
@@ -854,17 +855,19 @@ class account_bank_statement(osv.osv):
|
||||
_inherit = 'account.bank.statement'
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context=None):
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
for st in self.browse(cr, uid, ids, context):
|
||||
voucher_ids = []
|
||||
for line in st.line_ids:
|
||||
if line.voucher_id:
|
||||
voucher_ids.append(line.voucher_id.id)
|
||||
self.pool.get('account.voucher').cancel_voucher(cr, uid, voucher_ids, context)
|
||||
voucher_obj.cancel_voucher(cr, uid, voucher_ids, context)
|
||||
return super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context)
|
||||
|
||||
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None):
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
bank_st_line_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
|
||||
if st_line.voucher_id:
|
||||
@@ -878,7 +881,7 @@ class account_bank_statement(osv.osv):
|
||||
'move_ids': [(4, v.move_id.id, False)]
|
||||
})
|
||||
|
||||
return self.pool.get('account.move.line').write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
|
||||
return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
|
||||
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
|
||||
|
||||
account_bank_statement()
|
||||
@@ -912,14 +915,15 @@ class account_bank_statement_line(osv.osv):
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
statement_line = self.browse(cr, uid, ids, context)
|
||||
unlink_ids = []
|
||||
for st_line in statement_line:
|
||||
if st_line.voucher_id:
|
||||
unlink_ids.append(st_line.voucher_id.id)
|
||||
self.pool.get('account.voucher').unlink(cr, uid, unlink_ids, context=context)
|
||||
voucher_obj.unlink(cr, uid, unlink_ids, context=context)
|
||||
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
account_bank_statement_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:=======
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -32,7 +32,7 @@ class report_voucher(report_sxw.rml_parse):
|
||||
'get_title': self.get_title,
|
||||
'debit':self.debit,
|
||||
'credit':self.credit,
|
||||
'get_ref' : self._get_ref
|
||||
'get_ref': self._get_ref
|
||||
})
|
||||
|
||||
def convert(self, amount, cur):
|
||||
@@ -58,9 +58,10 @@ class report_voucher(report_sxw.rml_parse):
|
||||
return credit
|
||||
|
||||
def _get_ref(self, voucher_id, move_ids):
|
||||
voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)])
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
voucher_line = voucher_line_obj.search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)])
|
||||
if voucher_line:
|
||||
voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0]
|
||||
voucher = voucher_line_obj.browse(self.cr, self.uid, voucher_line)[0]
|
||||
return voucher.name
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
@@ -25,15 +25,15 @@ from osv import fields
|
||||
class account_voucher_unreconcile(osv.osv_memory):
|
||||
_name = "account.voucher.unreconcile"
|
||||
_description = "Account voucher unreconcile"
|
||||
|
||||
|
||||
_columns = {
|
||||
'remove':fields.boolean('Want to remove accounting entries too ?', required=False),
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'remove': True,
|
||||
}
|
||||
|
||||
|
||||
def trans_unrec(self, cr, uid, ids, context=None):
|
||||
# res = self.browse(cr, uid, ids[0])
|
||||
if context is None:
|
||||
@@ -54,9 +54,9 @@ class account_voucher_unreconcile(osv.osv_memory):
|
||||
voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context)
|
||||
# wf_service = netsvc.LocalService("workflow")
|
||||
# wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr)
|
||||
|
||||
|
||||
return {}
|
||||
|
||||
account_voucher_unreconcile()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
Reference in New Issue
Block a user