[FIX] account_voucher: fixed errors in yalm tests due to value returned for a field not present in the view
bzr revid: qdp-launchpad@openerp.com-20121005075356-857hfyqcrdjjv04r
This commit is contained in:
parent
df78f29db7
commit
0b66a6854b
|
@ -547,6 +547,20 @@ class account_voucher(osv.osv):
|
|||
vals = self.recompute_payment_rate(cr, uid, ids, res, currency_id, date, ttype, journal_id, amount, context=context)
|
||||
for key in vals.keys():
|
||||
res[key].update(vals[key])
|
||||
#TODO: onchange_partner_id() should not returns [pre_line, line_dr_ids, payment_rate...] for type sale, and not
|
||||
# [pre_line, line_cr_ids, payment_rate...] for type purchase.
|
||||
# We should definitively split account.voucher object in two and make distinct on_change functions. In the
|
||||
# meanwhile, bellow lines must be there because the fields aren't present in the view, what crashes if the
|
||||
# onchange returns a value for them
|
||||
print "TTYPE", ttype
|
||||
if ttype == 'sale':
|
||||
del(res['value']['line_dr_ids'])
|
||||
del(res['value']['pre_line'])
|
||||
del(res['value']['payment_rate'])
|
||||
elif ttype == 'purchase':
|
||||
del(res['value']['line_cr_ids'])
|
||||
del(res['value']['pre_line'])
|
||||
del(res['value']['payment_rate'])
|
||||
return res
|
||||
|
||||
def recompute_voucher_lines(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
|
||||
|
@ -588,7 +602,7 @@ class account_voucher(osv.osv):
|
|||
|
||||
#set default values
|
||||
default = {
|
||||
'value': {'line_ids': [] ,'line_dr_ids': [] ,'line_cr_ids': [] ,'pre_line': False,},
|
||||
'value': {'line_dr_ids': [] ,'line_cr_ids': [] ,'pre_line': False,},
|
||||
}
|
||||
|
||||
#drop existing lines
|
||||
|
@ -772,8 +786,10 @@ class account_voucher(osv.osv):
|
|||
if account_id and account_id.tax_ids:
|
||||
tax_id = account_id.tax_ids[0].id
|
||||
|
||||
vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
|
||||
vals['value'].update({'tax_id':tax_id,'amount': amount})
|
||||
vals = {'value':{} }
|
||||
if ttype in ('sale', 'purchase'):
|
||||
vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
|
||||
vals['value'].update({'tax_id':tax_id,'amount': amount})
|
||||
currency_id = False
|
||||
if journal.currency:
|
||||
currency_id = journal.currency.id
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- where and when is this view used?? -->
|
||||
<record model="ir.ui.view" id="view_voucher_form">
|
||||
<field name="name">account.voucher.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Demo for Account Voucher
|
||||
-
|
||||
!record {model: account.voucher, id: account_voucher_voucheraxelor0again, view: view_sale_receipt_form}:
|
||||
type: sale
|
||||
account_id: account.cash
|
||||
company_id: base.main_company
|
||||
journal_id: account.bank_journal
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<h1><label for="number" string="Sale Receipt"/> <field name="number" class="oe_inline" readonly="1"/></h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="type" invisible="True"/>
|
||||
<field name="partner_id" domain="[('customer','=',True)]" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, context)" string="Customer" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": true}'/>
|
||||
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
|
@ -83,7 +84,6 @@
|
|||
<field name="paid_amount_in_company_currency" invisible="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</group>
|
||||
<field name="type" invisible="True"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Sales Information">
|
||||
|
@ -95,12 +95,6 @@
|
|||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||
</tree>
|
||||
</field>
|
||||
<!-- TODO: onchange_partner_id() should not returns [line_ids, pre_line, line_dr_ids...] for type sale, and not [line_ids, pre_line, line_cr_ids,...] for type purchase -->
|
||||
<!-- in the meanwhile, bellow lines must be there because the fields must be present in the view if the onchange returns a value for them-->
|
||||
<field name="pre_line" invisible="1"/>
|
||||
<field name="line_ids" invisible="1"/>
|
||||
<field name="payment_rate" invisible="1"/>
|
||||
<field name="line_dr_ids" invisible="1"/>
|
||||
<group>
|
||||
<field name="narration" placeholder="Internal Notes" nolabel="1"/>
|
||||
<group class="oe_subtotal_footer oe_right">
|
||||
|
@ -255,12 +249,6 @@
|
|||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||
</tree>
|
||||
</field>
|
||||
<!-- TODO: onchange_partner_id() should not returns [line_ids, pre_line, line_dr_ids...] for type sale, and not [line_ids, pre_line, line_cr_ids,...] for type purchase -->
|
||||
<!-- in the meanwhile, bellow lines must be there because the fields must be present in the view if the onchange returns a value for them-->
|
||||
<field name="pre_line" invisible="1"/>
|
||||
<field name="line_ids" invisible="1"/>
|
||||
<field name="payment_rate" invisible="1"/>
|
||||
<field name="line_cr_ids" invisible="1"/>
|
||||
<group>
|
||||
<field name="narration" placeholder="Internal Notes" nolabel="1"/>
|
||||
<group class="oe_subtotal_footer oe_right">
|
||||
|
|
Loading…
Reference in New Issue