oerp.get('xxx') can't handle field type 'string'

Bug #1289781 reported by Martin Bramwell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OERPLib
Fix Released
Undecided
Unassigned

Bug Description

Attempting to get the "Sales Teams" module causes exception:

* * * * * * * In oerp.py(570)/get(model) model is crm.case.section
Traceback (most recent call last):
  File "./try.py", line 15, in <module>
    theCrmCaseSection = oerp.get(OPENERP_MODULE_NAME)
  File "/usr/local/lib/python2.7/dist-packages/oerplib/oerp.py", line 571, in get
    return osv.Model(self, model)
  File "/usr/local/lib/python2.7/dist-packages/oerplib/service/osv/osv.py", line 65, in __init__
    self._browse_class = self._generate_browse_class()
  File "/usr/local/lib/python2.7/dist-packages/oerplib/service/osv/osv.py", line 116, in _generate_browse_class
    self, field_name, field_data)
  File "/usr/local/lib/python2.7/dist-packages/oerplib/service/osv/fields.py", line 538, in generate_field
    txt.format(field_name=name, field_type=data['type']))
oerplib.error.InternalError: Can't instanciate the field 'monthly_planned_revenue', 'string' type unknown

Fix :
yourself@your_machine:/usr/local/lib/python2.7/dist-packages/oerplib/service/osv/fields.patch
532c532
< 'boolean', 'text', 'binary', 'html']:
---
> 'boolean', 'text', 'binary', 'html', 'string']:

Tags: fatal
Revision history for this message
Sébastien Alix (sebastien-alix) wrote :

Hi Martin,

Is it OpenERP v8? I suspect a "bug" in this version as "fields.string" does not exist, and it appears to be used as a type in some fields.function instead of the type "char":

openerp@oerp:~/instances/openerp-8.0/openerp/addons$ grep -Hn "type=.string." $(find . -name "*.py")
./crm/crm.py:175: type="string", readonly=True, multi='_get_opportunities_data',
./crm/crm.py:178: type="string", readonly=True, multi='_get_opportunities_data',
./sale_crm/sale_crm.py:105: type='string', readonly=True, multi='_get_sale_orders_data',
./sale_crm/sale_crm.py:108: type='string', readonly=True, multi='_get_sale_orders_data',
./sale_crm/sale_crm.py:111: type='string', readonly=True,

These fields seem to have been introduced from the v8.0.

Anyway, in OERPLib, maybe the best choice would be to set the "char" type by default for unknown type, raising an exception can be a blocking point...

Revision history for this message
Martin Bramwell (martinhbramwell) wrote :

Yes it is V8. I've changed my code to accept that field with no apparent negative effect.

Revision history for this message
Sébastien Alix (sebastien-alix) wrote :

I should interpret unknown field types as 'char' fields, and integrate logging to warn the user about that (logging integration is part of the roadmap).
It will be done for the next release (0.9).

In the meantime, I will open a bug on openobject-addons about these mistyped fields in 'crm' and 'sale_crm' modules.

Revision history for this message
Sébastien Alix (sebastien-alix) wrote :
Changed in oerplib:
status: New → Confirmed
Revision history for this message
Sébastien Alix (sebastien-alix) wrote :
Changed in oerplib:
milestone: none → 0.8.2
status: Confirmed → Fix Committed
Changed in oerplib:
status: Fix Committed → Fix Released
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.