diff --git a/addons/account/account.py b/addons/account/account.py index 8cf7f5c89ec..78a53b053cd 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -854,6 +854,7 @@ class account_move(osv.osv): context['journal_id'] = move.journal_id.id context['period_id'] = move.period_id.id self.pool.get('account.move.line')._update_check(cr, uid, line_ids, context) + self.pool.get('account.move.line').unlink(cr, uid, line_ids, context=context) toremove.append(move.id) result = super(account_move, self).unlink(cr, uid, toremove, context) return result diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 1fea09e3690..4b139622472 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -276,13 +276,13 @@ class account_bank_statement(osv.osv): if move.reconcile_id and move.reconcile_id.line_ids: torec += map(lambda x: x.id, move.reconcile_id.line_ids) - try: - if abs(move.reconcile_amount-move.amount)<0.0001: - account_move_line_obj.reconcile(cr, uid, torec, 'statement', context) - else: - account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) - except: - raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount)) + #try: + if abs(move.reconcile_amount-move.amount)<0.0001: + account_move_line_obj.reconcile(cr, uid, torec, 'statement', context) + else: + account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) + #except: + # raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount)) if st.journal_id.entry_posted: account_move_obj.write(cr, uid, [move_id], {'state':'posted'}) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 41fc73ca29d..1a0318094f8 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -859,17 +859,22 @@ + + - + + + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index c80cda3fe6d..d9d976304bd 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -95,7 +95,7 @@ class account_invoice(osv.osv): paid_amt = 0.0 to_pay = inv.amount_total for lines in inv.move_lines: - paid_amt = paid_amt + lines.credit + paid_amt = paid_amt + lines.credit + lines.debit res[inv.id] = to_pay - paid_amt return res @@ -145,6 +145,27 @@ class account_invoice(osv.osv): result[invoice.id] = lines return result + def _get_invoice_from_line(self, cr, uid, ids, context={}): + move = {} + for line in self.pool.get('account.move.line').browse(cr, uid, ids): + move[line.move_id.id] = True + invoice_ids = [] + if move: + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) + return invoice_ids + + def _get_invoice_from_reconcile(self, cr, uid, ids, context={}): + move = {} + for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): + for line in r.line_partial_ids: + move[line.move_id.id] = True + for line in r.line_id: + move[line.move_id.id] = True + invoice_ids = [] + if move: + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) + return invoice_ids + _name = "account.invoice" _description = 'Invoice' _order = "number" @@ -174,14 +195,16 @@ class account_invoice(osv.osv): ],'State', select=True, readonly=True), 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}), - 'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}), - + 'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}, + help="If you use payment terms, the due date will be computed automatically at the generation "\ + "of accounting entries. If you keep the payment term and the due date empty, it means direct payment."), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}), 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}), - - 'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]} ), - + 'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]}, + help="If you use payment terms, the due date will be computed automatically at the generation "\ + "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\ + "The payment term may compute several due dates: 50% now, 50% in one month."), 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation date."), 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="The partner account used for this invoice."), @@ -224,6 +247,8 @@ class account_invoice(osv.osv): 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50), 'account.invoice.tax': (_get_invoice_tax, None, 50), 'account.invoice.line': (_get_invoice_line, None, 50), + 'account.move.line': (_get_invoice_from_line, None, 50), + 'account.move.reconcile': (_get_invoice_from_reconcile, None, 50), }, help="Remaining amount due."), 'payment_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="many2many", string='Payments'), diff --git a/addons/account/wizard/wizard_unreconcile.py b/addons/account/wizard/wizard_unreconcile.py index 1d263caa0fe..d5fb9848145 100644 --- a/addons/account/wizard/wizard_unreconcile.py +++ b/addons/account/wizard/wizard_unreconcile.py @@ -35,15 +35,8 @@ def _trans_unrec(self, cr, uid, data, context): recs = pool.get('account.move.line').read(cr, uid, data['ids'], ['reconcile_id',]) recs = filter(lambda x: x['reconcile_id'], recs) rec_ids = [rec['reconcile_id'][0] for rec in recs] - move = {} - for r in pool.get('account.move.reconcile').browse(cr, uid, rec_ids): - for line in r.line_id: - move[line.move_id.id] = True if len(rec_ids): pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids) - if move: - invoice_ids = pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) - pool.get('account.invoice').write(cr, uid, invoice_ids, {}, context=context) return {} class wiz_unreconcile(wizard.interface):