[6.1] Voucher with no currency_id

Bug #861244 reported by Yannick Vaucher @ Camptocamp
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Incomplete
Undecided
Unassigned

Bug Description

Hello,

Here are my current revision numbers:

$ bzr revno addons
5234
$ bzr revno server
3666

In a yaml test that was properly working on previous versions in our l10n_ch module, I get this output.

[2011-09-28 06:53:16,003][ch_6_1_20110928_1] ERROR:tests.l10n_ch:unsupported operand type(s) for /: 'float' and 'NoneType'
Traceback (most recent call last):
  File ".../server/openerp/tools/yaml_import.py", line 736, in process
    self._process_node(node)
  File ".../server/openerp/tools/yaml_import.py", line 751, in _process_node
    self.process_python(node)
  File ".../server/openerp/tools/yaml_import.py", line 422, in process_python
    unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
  File ".../addons/l10n_ch/test/l10n_ch_dta.yml", line 17, in <module>
    address_invoice_id: base.res_partner_address_8
  File ".../addons/account_payment/wizard/account_payment_populate_statement.py", line 114, in populate_statement
    }, context=context)
  File ".../server/openerp/osv/orm.py", line 3977, in create
    self._validate(cr, user, [id_new], context)
  File ".../server/openerp/osv/orm.py", line 1369, in _validate
    if not fun(self, cr, uid, ids):
  File ".../addons/account_voucher/account_voucher.py", line 1059, in _check_amount
    if not self.pool.get('res.currency').is_zero(cr, uid, obj.voucher_id.currency_id, diff):
  File ".../server/openerp/addons/base/res/res_currency.py", line 121, in is_zero
    return abs(self.round(cr, uid, currency, amount)) < currency.rounding
  File ".../server/openerp/addons/base/res/res_currency.py", line 118, in round
    return round(amount / currency.rounding) * currency.rounding
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'
[2011-09-28 06:53:16,004][ch_6_1_20110928_1] ERROR:init.test:Tests failed to execute in module l10n_ch
Traceback (most recent call last):
  File ".../server/openerp/modules/loading.py", line 100, in load_test
    _load_data(cr, module_name, idref, mode, 'test')
  File ".../server/openerp/modules/loading.py", line 135, in _load_data
    tools.convert_yaml_import(cr, module_name, fp, idref, mode, noupdate)
  File ".../server/openerp/tools/yaml_import.py", line 801, in yaml_import
    yaml_interpreter.process(yaml_string)
  File ".../server/openerp/tools/yaml_import.py", line 736, in process
    self._process_node(node)
  File ".../server/openerp/tools/yaml_import.py", line 751, in _process_node
    self.process_python(node)
  File ".../server/openerp/tools/yaml_import.py", line 422, in process_python
    unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
  File ".../addons/l10n_ch/test/l10n_ch_dta.yml", line 17, in <module>
    address_invoice_id: base.res_partner_address_8
  File ".../addons/account_payment/wizard/account_payment_populate_statement.py", line 114, in populate_statement
    }, context=context)
  File ".../server/openerp/osv/orm.py", line 3977, in create
    self._validate(cr, user, [id_new], context)
  File ".../server/openerp/osv/orm.py", line 1369, in _validate
    if not fun(self, cr, uid, ids):
  File ".../addons/account_voucher/account_voucher.py", line 1059, in _check_amount
    if not self.pool.get('res.currency').is_zero(cr, uid, obj.voucher_id.currency_id, diff):
  File ".../server/openerp/addons/base/res/res_currency.py", line 121, in is_zero
    return abs(self.round(cr, uid, currency, amount)) < currency.rounding
  File ".../server/openerp/addons/base/res/res_currency.py", line 118, in round
    return round(amount / currency.rounding) * currency.rounding
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'

Here is the part of my test generating this error:

-
  I import the payment line
-
  !python {model: account.payment.populate.statement}: |
    wiz_id = self.create(cr,uid,[])
    wiz = self.browse(cr, uid, wiz_id)

    line_obj = self.pool.get('payment.line')
    pay_line_ids = line_obj.search(cr, uid, [('communication','=','111111111111111111111111111111'),('amount','=','7000')])

    data = { 'lines': [(6, 0, [pay_line_ids[0]])],}
    wiz.write(data)

    context['active_id'] = ref('dta_bank_statement')
    context['active_ids'] = [ref('dta_bank_statement')]

    self.populate_statement(cr, uid, [wiz_id], context=context)

Somehow, a voucher is generated without a proper currency_id. It's value is False.

Here is the full yaml test, but this is only designed for l10n_ch module.
http://bazaar.launchpad.net/~c2c-localization/openerp-swiss-localization/6.x-trunk/view/head:/l10n_ch/test/l10n_ch_dta.yml

And as this merge is still pending it might not be fully applicable with current version of l10n_ch (because some fix need to be done and it could crash before this state). However, it is not normal that a voucher got no currency_id when using the populate_statement method and fails to compute the rounding of an amount.

My guess is that the issue is on the voucher level when creating it. Weither a check is missing to raise an error, or the currency_id is not set correctly by default. Shouldn't it takes the company currency ?

Best regards,
Yannick

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :

Hello Yannick Vaucher,

I have applied same .yml file as you have specified in your specification but I didn't face any problem at my end.

Would you please checked again and informed us where you faced the problem.

Thanks and waiting for your reply.

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Hello,

I checked again here is how I created my instance:

checkout of object-addons revno 5235
checkout of object-server revno 3666

replaced whole l10n_ch module by our c2c l10n_ch module in order to have all demo data and yaml needed.

Then I tested this way :

Creating new database
  Add more features
    Selection of Invoicing + Comptability & Finance
    Install
    Selection of Switzerland chart of account
    Next

And again * Error in yaml test in server logs

TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :

Hello Yannick Vaucher,

I have applied same scenario as per comment no #2, I got "This Yaml file appears to depend on missing data. This often happens for tests that belong to a module's test suite and depend on each other".

I think some thing is wrong at your end or your file is different then official addons.

Thanks and waiting for your reply.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Hello thanks for your reply,

Ok this might be a bit of a premature bug report.

However, it will show up again if this merge is accepted
https://code.launchpad.net/~c2c/openobject-addons/6.1-fix-l10n_ch-20110916/+merge/75749

I must say that the error shown up only yesterday. It was when I was checking my merge proposal that was perfectly working without any change a day earlier. So the change shouldn't be on my end unless some specifications have change on the mean time.

Here is how you can have the same error as I had :

You couldn't reproduce because of the missing demo data file in current l10n_ch module is not in __openerp__.py on official version but it is already present

--- [ in __openerp__.py ]
add demo/dta_demo.xml

Then, as official l10n_ch 6.1 is not a fixed version, in my yaml file one of my tests will fail.
As it isn't related to the bug (some file creation stuff) we can comment the 2 following lines:

--- [ in test/l10n_ch_dta.yml ]
comment line 100 #assert dta_file, "File is empty"
comment line 103 #assert dta_file[:2] == "01", "File is not a DTA file"

So only those change are made to show up this bug or if it is on my end, this change of behavior. But something that doesn't act as you expect it is quite a bug, isn't it ? :)

bzr status openobject-addons
modified:
  l10n_ch/__openerp__.py
unknown:
  l10n_ch/test/l10n_ch_dta.yml

Can you confirm you have the same output that I double checked ?

Thanks

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

It pass a bit further now with versions :

bzr revno openobject-addons/
5383
bzr revno openobject-server/
3768

But please consider this bug report :
https://bugs.launchpad.net/openobject-addons/+bug/847630

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.