ACCOUNT: fix pay invoice to use period
- pay invoice use the period of the wizard for the moves. - the line now check the sign of the invoice to choice debit/credit bzr revid: ced-13e1c173a82852030707ba5382b46cb35bbd46e4
This commit is contained in:
parent
d4d6c81713
commit
58c3e3add6
|
@ -543,7 +543,7 @@ class account_invoice(osv.osv):
|
|||
new_ids.append(self.create(cr, uid, invoice))
|
||||
return new_ids
|
||||
|
||||
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context={}):
|
||||
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context={}):
|
||||
assert len(ids)==1, "Can only pay one invoice at a time"
|
||||
invoice = self.browse(cr, uid, ids[0])
|
||||
src_account_id = invoice.account_id.id
|
||||
|
@ -556,22 +556,22 @@ class account_invoice(osv.osv):
|
|||
direction = types[invoice.type]
|
||||
l1 = {
|
||||
'name': name,
|
||||
'debit': direction == 1 and pay_amount,
|
||||
'credit': direction == -1 and pay_amount,
|
||||
'debit': direction * pay_amount>0 and direction * pay_amount,
|
||||
'credit': direction * pay_amount<0 and - direction * pay_amount,
|
||||
'account_id': src_account_id,
|
||||
'partner_id': invoice.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
l2 = {
|
||||
'name':name,
|
||||
'debit': direction == -1 and pay_amount,
|
||||
'credit': direction == 1 and pay_amount,
|
||||
'debit': direction * pay_amount<0 and - direction * pay_amount,
|
||||
'credit': direction * pay_amount>0 and direction * pay_amount,
|
||||
'account_id': pay_account_id,
|
||||
'partner_id': invoice.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
lines = [(0, 0, l1), (0, 0, l2)]
|
||||
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id}
|
||||
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
|
||||
move_id = self.pool.get('account.move').create(cr, uid, move)
|
||||
|
||||
line_ids = []
|
||||
|
|
|
@ -47,10 +47,11 @@ pay_fields = {
|
|||
def _pay_and_reconcile(self, cr, uid, data, context):
|
||||
service = netsvc.LocalService("object_proxy")
|
||||
form = data['form']
|
||||
account_id = form.get('writeoff_acc_id', False)
|
||||
period_id = form.get('period_id', False)
|
||||
journal_id = form.get('journal_id', False)
|
||||
service.execute(cr.dbname, uid, 'account.invoice', 'pay_and_reconcile', [data['id']], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
|
||||
writeoff_account_id = form.get('writeoff_acc_id', False)
|
||||
writeoff_journal_id = form.get('writeoff_journal_id', False)
|
||||
service.execute(cr.dbname, uid, 'account.invoice', 'pay_and_reconcile', [data['id']], form['amount'], form['dest_account_id'], period_id, journal_id, writeoff_account_id, period_id, writeoff_journal_id, context)
|
||||
return {}
|
||||
|
||||
def _trans_reconcile(self, cr, uid, data, context):
|
||||
|
@ -68,10 +69,12 @@ _transaction_add_form = '''<?xml version="1.0"?>
|
|||
<form string="Information addendum">
|
||||
<separator string="Write-Off Move" colspan="4"/>
|
||||
<field name="writeoff_acc_id"/>
|
||||
<field name="writeoff_journal_id"/>
|
||||
</form>'''
|
||||
|
||||
_transaction_add_fields = {
|
||||
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
||||
}
|
||||
|
||||
def _get_value_addendum(self, cr, uid, data, context={}):
|
||||
|
|
Loading…
Reference in New Issue