summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>2012-10-05 09:53:56 +0200
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>2012-10-05 09:53:56 +0200
commit0b66a6854bf7bbb7a5e77ec3c15eec79661eb4bc (patch)
treeba7ba58c2c3b281c7db981f2111e969a1bf19163
parentdf78f29db74c4c4dd31db7488cc92bfd776dc86e (diff)
[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
-rw-r--r--addons/account_voucher/account_voucher.py22
-rw-r--r--addons/account_voucher/account_voucher_view.xml1
-rw-r--r--addons/account_voucher/test/account_voucher_report.yml1
-rw-r--r--addons/account_voucher/voucher_sales_purchase_view.xml14
4 files changed, 22 insertions, 16 deletions
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index ccb4f952310..5f48a8020c4 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -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
diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml
index 5e26c366778..f8bab444453 100644
--- a/addons/account_voucher/account_voucher_view.xml
+++ b/addons/account_voucher/account_voucher_view.xml
@@ -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>
diff --git a/addons/account_voucher/test/account_voucher_report.yml b/addons/account_voucher/test/account_voucher_report.yml
index a87e4f0fc2a..60dc4103553 100644
--- a/addons/account_voucher/test/account_voucher_report.yml
+++ b/addons/account_voucher/test/account_voucher_report.yml
@@ -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
diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml
index 38b0bbefd18..4c388730644 100644
--- a/addons/account_voucher/voucher_sales_purchase_view.xml
+++ b/addons/account_voucher/voucher_sales_purchase_view.xml
@@ -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">