[IMP] account_voucher: added feature for reconciliation on the bank statement
bzr revid: qdp-launchpad@tinyerp.com-20100918124330-d4k83ne26h0t69xf
This commit is contained in:
parent
6d6d2d912f
commit
fee8716166
|
@ -45,7 +45,7 @@ account_move_line()
|
|||
|
||||
class account_voucher(osv.osv):
|
||||
def _get_type(self, cr, uid, ids, context={}):
|
||||
return context.get('type')
|
||||
return context.get('type', False)
|
||||
|
||||
def _get_period(self, cr, uid, context={}):
|
||||
if context.get('period_id', False):
|
||||
|
@ -101,7 +101,8 @@ class account_voucher(osv.osv):
|
|||
|
||||
def _get_narration(self, cr, uid, context={}):
|
||||
return context.get('narration', False)
|
||||
|
||||
|
||||
|
||||
_name = 'account.voucher'
|
||||
_description = 'Accounting Voucher'
|
||||
_order = "date desc, id desc"
|
||||
|
@ -308,7 +309,7 @@ class account_voucher(osv.osv):
|
|||
tr_type = 'receipt'
|
||||
|
||||
default['value']['account_id'] = account_id
|
||||
default['value']['type'] = tr_type
|
||||
default['value']['type'] = ttype or tr_type
|
||||
|
||||
vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context)
|
||||
default['value'].update(vals.get('value'))
|
||||
|
@ -810,3 +811,44 @@ class account_voucher_line(osv.osv):
|
|||
})
|
||||
return values
|
||||
account_voucher_line()
|
||||
|
||||
class account_bank_statement(osv.osv):
|
||||
_inherit = 'account.bank.statement'
|
||||
|
||||
def create_move_from_st_line(self, cr, uid, st_line, company_currency_id, next_number, context=None):
|
||||
#TODO: test me please
|
||||
if st_line.voucher_id:
|
||||
return self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id])
|
||||
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context)
|
||||
|
||||
account_bank_statement()
|
||||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
_inherit = 'account.bank.statement.line'
|
||||
|
||||
def _amount_reconciled(self, cursor, user, ids, name, args, context=None):
|
||||
if not ids:
|
||||
return {}
|
||||
res_currency_obj = self.pool.get('res.currency')
|
||||
res = {}
|
||||
company_currency_id = False
|
||||
|
||||
for line in self.browse(cursor, user, ids, context=context):
|
||||
if not company_currency_id:
|
||||
company_currency_id = line.company_id.id
|
||||
if line.voucher_id:
|
||||
res[line.id] = res_currency_obj.compute(cursor, user,
|
||||
company_currency_id, line.statement_id.currency.id,
|
||||
line.voucher_id.amount, context=context)
|
||||
else:
|
||||
res[line.id] = 0.0
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'amount_reconciled': fields.function(_amount_reconciled,
|
||||
string='Amount reconciled', method=True, type='float'),
|
||||
'voucher_id': fields.many2one('account.voucher', 'Payment'),
|
||||
|
||||
}
|
||||
|
||||
account_bank_statement_line()
|
||||
|
|
|
@ -80,6 +80,72 @@
|
|||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_low_priority_payment_form">
|
||||
<field name="name">account.voucher.payment.low.priority.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority">1</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bill Payment">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)" context="{'invoice_currency':currency_id}" string="Vendor"/>
|
||||
<field name="journal_id"
|
||||
domain="[('type','in',['bank', 'cash'])]"
|
||||
widget="selection" select="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"
|
||||
string="Payment Method"/>
|
||||
<field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"/>
|
||||
<field name="reference" select="1" string="Payment Ref"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="account_id"
|
||||
widget="selection"
|
||||
invisible="True"/>
|
||||
<field name="pre_line" invisible="1"/>
|
||||
<field name="type" invisible="True"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Payment Information">
|
||||
<field name="line_dr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
|
||||
<tree string="Vendor Invoices and Outstanding transactions" editable="bottom">
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
<form string="Payment Information">
|
||||
<label string="Form view not available for Payment Lines"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
|
||||
<tree string="Credits" editable="bottom">
|
||||
<field name="move_line_id"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original"/>
|
||||
<field name="amount_original"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group col="2" colspan="3">
|
||||
<separator string="Internal Notes" colspan="2"/>
|
||||
<field name="narration" colspan="2" nolabel="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<field name="date" select="1" on_change="onchange_date(date)"/>
|
||||
<field name="currency_id" invisible="True"/>
|
||||
<field name="number"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_vendor_payment_form">
|
||||
<field name="name">account.voucher.payment.form</field>
|
||||
|
|
|
@ -179,5 +179,19 @@
|
|||
<field name="search_view_id" ref="view_voucher_filter"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_bank_statement_form_voucher" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.voucher.form.inherit</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
|
||||
<field name="voucher_id" context="{'default_type': amount < 0 and 'payment' or 'receipt', 'type': amount < 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
|
||||
<field name="amount_reconciled"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue