← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 861244] Re: [6.1] Voucher with no currency_id

 

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

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP Project Group.
https://bugs.launchpad.net/bugs/861244

Title:
  [6.1] Voucher with no currency_id

Status in OpenERP Addons (modules):
  Incomplete

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/861244/+subscriptions


References