From 3f8ae50046d8b2709ef381ac438e7582e809a63e Mon Sep 17 00:00:00 2001 From: Dmitrijs Ledkovs Date: Thu, 3 Nov 2011 14:52:42 +0000 Subject: [PATCH] [FIX] Calculate correct parter payables & receivables if debit/credit are NULL Set a "not null" constraint on debit and credit columns of account_move_lines to prevent similar sql errors in the future. lp bug: https://launchpad.net/bugs/885714 fixed bzr revid: dmitrijs.ledkovs@credativ.co.uk-20111103145242-zu13vwjv2hdxbqjl --- addons/account/account_move_line.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 13803d3ff79..ca66c7e1b4d 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -481,8 +481,8 @@ class account_move_line(osv.osv): 'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports."), 'product_uom_id': fields.many2one('product.uom', 'UoM'), 'product_id': fields.many2one('product.product', 'Product'), - 'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')), - 'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')), + 'debit': fields.float('Debit', digits_compute=dp.get_precision('Account'), required=True), + 'credit': fields.float('Credit', digits_compute=dp.get_precision('Account'), required=True), 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2), 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", help="The move of this entry line.", select=2, required=True), 'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Internal Note'), @@ -559,6 +559,8 @@ class account_move_line(osv.osv): 'state': 'draft', 'currency_id': _get_currency, 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False), + 'credit': 0.0, + 'debit': 0.0, 'account_id': lambda self, cr, uid, c: c.get('account_id', False), 'period_id': lambda self, cr, uid, c: c.get('period_id', False), 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)