[IMP] improve customer payment

bzr revid: shp@tinyerp.com-20120625123913-cojrmo49t7bkmtx6
This commit is contained in:
pankita shah (Open ERP) 2012-06-25 18:09:13 +05:30
parent 0a22debf5f
commit e645dc56be
3 changed files with 29 additions and 6 deletions

View File

@ -53,6 +53,15 @@ class account_voucher(osv.osv):
res[voucher.id] = paid
return res
def _amount_all(self, cr, uid, ids, name, args, context=None):
res = {}
amount = 0.0
for voucher in self.browse(cr, uid, ids, context=context):
for line in voucher.line_cr_ids:
amount += line.amount
res[voucher.id] = amount
return res
def _get_type(self, cr, uid, context=None):
if context is None:
context = {}
@ -312,6 +321,7 @@ class account_voucher(osv.osv):
help='The specific rate that will be used, in this voucher, between the selected currency (in \'Payment Rate Currency\' field) and the voucher currency.'),
'paid_amount_in_company_currency': fields.function(_paid_amount_in_company_currency, string='Paid Amount in Company Currency', type='float', readonly=True),
'is_multi_currency': fields.boolean('Multi Currency Voucher', help='Fields with internal purpose only that depicts if the voucher is a multi currency one or not'),
'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Invoice Total'),
}
_defaults = {
'period_id': _get_period,
@ -1337,6 +1347,7 @@ class account_voucher_line(osv.osv):
'amount_unreconciled': fields.function(_compute_balance, multi='dc', type='float', string='Open Balance', store=True, digits_compute=dp.get_precision('Account')),
'company_id': fields.related('voucher_id','company_id', relation='res.company', type='many2one', string='Company', store=True, readonly=True),
'currency_id': fields.function(_currency_id, string='Currency', type='many2one', relation='res.currency', readonly=True),
}
_defaults = {
'name': '',

View File

@ -53,11 +53,13 @@
<group col="6" colspan="4">
<field name="partner_id" required="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
<field name="date" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id)"/>
<field name="name"/>
<field name="journal_id" widget="selection" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
<field name="type" required="1"/>
<field name="name" colspan="2"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name="reference"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name="account_id" widget="selection" invisible="True"/>
</group>
<notebook colspan="4">

View File

@ -304,6 +304,7 @@
<sheet>
<div class="oe_title">
<div class="oe_edit_only">
customer
<label for="parter_id" />
</div>
<h1>
@ -312,12 +313,13 @@
</div>
<div>
Pay
<h2>
<field name="amount"
invisible="context.get('line_type', False)"
string="Paid Amount"
class="oe_inline"
on_change="onchange_amount(amount, payment_rate, partner_id, journal_id, currency_id, type, date, payment_rate_currency_id, company_id, context)"/>
by
by
<field name="journal_id"
domain="[('type','in',['bank', 'cash'])]"
invisible="context.get('line_type', False)"
@ -325,14 +327,15 @@
class="oe_inline"
on_change="onchange_journal(journal_id, line_cr_ids, False, partner_id, date, amount, type, company_id, context)"
string="Payment Method"/>
</h2>
</div>
<group col="6">
<field name="currency_id" invisible="1"/>
<field name="date" invisible="context.get('line_type', False)" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
<field name="name" colspan="2" invisible="context.get('line_type', False)" placeholder="Invoice SAJ/0042"/>
<field name="reference" invisible="context.get('line_type', False)" string="Payment Ref" placeholder="003/10"/>
<field name="name" colspan="2" invisible="context.get('line_type', False)" placeholder="Invoice SAJ/0042"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name="account_id"
widget="selection"
@ -376,7 +379,7 @@
</field>
<group col="3">
<group col="2" string="Internal Notes">
<field name="narration" colspan="2" nolabel="1"/>
<field name="narration" colspan="2" nolabel="1" placeholder="Add an internal note"/>
</group>
<group col="4" attrs="{'invisible':[('currency_id','=',False),('is_multi_currency','=',False)]}">
<separator string="Currency Options" colspan="4"/>
@ -385,6 +388,7 @@
<field name="payment_rate_currency_id" colspan="1" nolabel="1" on_change="onchange_payment_rate_currency(currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context)"/>
<field name="paid_amount_in_company_currency" colspan="4" invisible="1"/>
</group>
<group>
<group col="2">
<separator string="Payment Options" colspan="2"/>
<field name="writeoff_amount"/>
@ -396,8 +400,13 @@
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
<field name="analytic_id"
groups="analytic.group_analytic_accounting"/>
</group>
</group>
<group class="oe_subtotal_footer">
<field name="amount_total" class="oe_subtotal_footer_separator"/>
</group>
</group>
</group>
</page>
<page string="Journal Items" attrs="{'invisible': [('state','!=','posted')]}">
<group col="4">
@ -425,6 +434,7 @@
</page>
</notebook>
</sheet>
</form>
</field>
</record>