bzr revid: fp@tinyerp.com-20090116094405-ar373qjnwsqp910w
This commit is contained in:
Fabien Pinckaers 2009-01-16 10:44:05 +01:00
parent a452f024e8
commit 480ab6c9e9
5 changed files with 45 additions and 21 deletions

View File

@ -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

View File

@ -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'})

View File

@ -859,17 +859,22 @@
<field name="state"/>
</form>
<tree editable="top" string="Account Entry Line">
<field name="ref"/>
<field name="invoice"/>
<field name="name"/>
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,parent.date,parent.journal_id)"/>
<field name="account_id"/>
<field name="date_maturity"/>
<field name="ref"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
<field name="analytic_account_id"/>
<field name="amount_currency" groups="base.group_extended"/>
<field name="currency_id" groups="base.group_extended"/>
<field name="tax_code_id"/>
<field name="tax_amount"/>
<field name="state"/>
<field name="reconcile_id"/>
<field name="reconcile_partial_id" groups="base.group_extended"/>
</tree>
</field>

View File

@ -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'),

View File

@ -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):