mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[IMP] Port account_move_line.py on new API
This commit is contained in:
@@ -19,32 +19,27 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class AccountMoveLine(orm.Model):
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
def _get_journal_entry_ref(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
res[record.id] = record.move_id.name
|
||||
if record.move_id.state == 'draft':
|
||||
if record.invoice.id:
|
||||
res[record.id] = record.invoice.number
|
||||
else:
|
||||
res[record.id] = '*' + str(record.move_id.id)
|
||||
@api.one
|
||||
def _get_journal_entry_ref(self):
|
||||
if self.move_id.state == 'draft':
|
||||
if self.invoice.id:
|
||||
self.journal_entry_ref = self.invoice.number
|
||||
else:
|
||||
res[record.id] = record.move_id.name
|
||||
return res
|
||||
self.journal_entry_ref = '*' + str(self.move_id.id)
|
||||
else:
|
||||
self.journal_entry_ref = self.move_id.name
|
||||
|
||||
_columns = {
|
||||
'journal_entry_ref': fields.function(_get_journal_entry_ref,
|
||||
string='Journal Entry Ref',
|
||||
type="char")
|
||||
}
|
||||
journal_entry_ref = fields.Char(compute=_get_journal_entry_ref,
|
||||
string='Journal Entry Ref')
|
||||
|
||||
def get_balance(self, cr, uid, ids, context=None):
|
||||
@api.multi
|
||||
def get_balance(self):
|
||||
"""
|
||||
Return the balance of any set of move lines.
|
||||
|
||||
@@ -52,9 +47,6 @@ class AccountMoveLine(orm.Model):
|
||||
returns the account balance that the move line applies to.
|
||||
"""
|
||||
total = 0.0
|
||||
if not ids:
|
||||
return total
|
||||
for line in self.read(
|
||||
cr, uid, ids, ['debit', 'credit'], context=context):
|
||||
total += (line['debit'] or 0.0) - (line['credit'] or 0.0)
|
||||
for line in self:
|
||||
total += (line.debit or 0.0) - (line.credit or 0.0)
|
||||
return total
|
||||
|
||||
Reference in New Issue
Block a user