[IMP] Account payment & l10_nch: Remove bank reconcile object reference and use voucher instead of it
bzr revid: mra@mra-laptop-20100928045252-c5wrsjze3knfa8l0
This commit is contained in:
parent
c98b0949e5
commit
fd6c7a0c54
|
@ -61,7 +61,6 @@ class account_coda_import(osv.osv_memory):
|
|||
bank_statement_obj = self.pool.get('account.bank.statement')
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
bank_statement_line_obj = self.pool.get('account.bank.statement.line')
|
||||
# statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
account_coda_obj = self.pool.get('account.coda')
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* a basic mechanism to easily plug various automated payment.
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['account'],
|
||||
'depends': ['account_voucher'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/account_payment_security.xml',
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from lxml import etree
|
||||
|
||||
from osv import osv, fields
|
||||
|
@ -53,7 +54,9 @@ class account_payment_populate_statement(osv.osv_memory):
|
|||
statement_obj = self.pool.get('account.bank.statement')
|
||||
statement_line_obj = self.pool.get('account.bank.statement.line')
|
||||
currency_obj = self.pool.get('res.currency')
|
||||
statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
|
@ -68,11 +71,37 @@ class account_payment_populate_statement(osv.osv_memory):
|
|||
ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now
|
||||
amount = currency_obj.compute(cr, uid, line.currency.id,
|
||||
statement.currency.id, line.amount_currency, context=ctx)
|
||||
if line.partner_id:
|
||||
# line['partner_id'] = mv.partner_id.id
|
||||
if amount < 0 :
|
||||
account = line.partner_id.property_account_payable.id
|
||||
else :
|
||||
account = line.partner_id.property_account_receivable.id
|
||||
|
||||
if line.move_line_id:
|
||||
reconcile_id = statement_reconcile_obj.create(cr, uid, {
|
||||
'line_ids': [(6, 0, [line.move_line_id.id])]
|
||||
}, context=context)
|
||||
voucher_res = { 'type': 'payment' ,
|
||||
'name': line.name,
|
||||
'partner_id': line.partner_id.id,
|
||||
'journal_id': statement.journal_id.id,
|
||||
'account_id': account,
|
||||
'company_id': statement.company_id.id,
|
||||
'currency_id': statement.currency.id,
|
||||
'date': line.date or time.strftime('%Y-%m-%d'),
|
||||
'amount': abs(amount),
|
||||
'period_id': statement.period_id.id
|
||||
}
|
||||
voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment')
|
||||
voucher_line_dict = False
|
||||
if result['value']['line_ids']:
|
||||
for line_dict in result['value']['line_ids']:
|
||||
move_line = self.pool.get('account.move.line').browse(cr, uid, line_dict['move_line_id'], context)
|
||||
if line.move_line_id.move_id.id == move_line.move_id.id:
|
||||
voucher_line_dict = line_dict
|
||||
if voucher_line_dict:
|
||||
voucher_line_dict.update({'voucher_id':voucher_id})
|
||||
voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
|
||||
|
||||
st_line_id = statement_line_obj.create(cr, uid, {
|
||||
'name': line.order_id.reference or '?',
|
||||
'amount': - amount,
|
||||
|
@ -81,8 +110,9 @@ class account_payment_populate_statement(osv.osv_memory):
|
|||
'account_id': line.move_line_id.account_id.id,
|
||||
'statement_id': statement.id,
|
||||
'ref': line.communication,
|
||||
'reconcile_id': reconcile_id,
|
||||
'voucher_id': voucher_id,
|
||||
}, context=context)
|
||||
|
||||
line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ TODO :
|
|||
"base_vat",
|
||||
"base_iban",
|
||||
"account_payment",
|
||||
"account_voucher",
|
||||
],
|
||||
"init_xml" : [
|
||||
"dta_data.xml",
|
||||
|
|
|
@ -73,7 +73,9 @@ def _import(obj, cursor, user, data, context=None):
|
|||
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
statement_line_obj = pool.get('account.bank.statement.line')
|
||||
statement_reconcile_obj = pool.get('account.bank.statement.reconcile')
|
||||
# statement_reconcile_obj = pool.get('account.bank.statement.reconcile')
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
move_line_obj = pool.get('account.move.line')
|
||||
property_obj = pool.get('ir.property')
|
||||
model_fields_obj = pool.get('ir.model.fields')
|
||||
|
@ -200,9 +202,32 @@ def _import(obj, cursor, user, data, context=None):
|
|||
values['partner_id'] = partner_id
|
||||
|
||||
if line2reconcile:
|
||||
values['reconcile_id'] = statement_reconcile_obj.create(cursor, user, {
|
||||
'line_ids': [(6, 0, [line2reconcile])],
|
||||
}, context=context)
|
||||
voucher_res = { 'type': 'payment' ,
|
||||
'name': line.name,
|
||||
'partner_id': line.partner_id.id,
|
||||
'journal_id': statement.journal_id.id,
|
||||
'account_id': account,
|
||||
'company_id': statement.company_id.id,
|
||||
'currency_id': statement.currency.id,
|
||||
'date': line.date or time.strftime('%Y-%m-%d'),
|
||||
'amount': abs(amount),
|
||||
'period_id': statement.period_id.id
|
||||
}
|
||||
voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment')
|
||||
voucher_line_dict = False
|
||||
if result['value']['line_ids']:
|
||||
for line_dict in result['value']['line_ids']:
|
||||
move_line = self.pool.get('account.move.line').browse(cr, uid, line_dict['move_line_id'], context)
|
||||
if line.move_line_id.move_id.id == move_line.move_id.id:
|
||||
voucher_line_dict = line_dict
|
||||
if voucher_line_dict:
|
||||
voucher_line_dict.update({'voucher_id':voucher_id})
|
||||
voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
|
||||
values['voucher_id'] = voucher_id
|
||||
# values['reconcile_id'] = statement_reconcile_obj.create(cursor, user, {
|
||||
# 'line_ids': [(6, 0, [line2reconcile])],
|
||||
# }, context=context)
|
||||
|
||||
statement_line_obj.create(cursor, user, values, context=context)
|
||||
attachment_obj.create(cursor, user, {
|
||||
|
|
Loading…
Reference in New Issue