OCA / vertical-travel

GNU Affero General Public License v3.0
33 stars 74 forks source link

Add missing field attributes #36

Closed ghost closed 9 years ago

bwrsandman commented 9 years ago

Why are these missing? The field is related. Please explain the change.

ghost commented 9 years ago

@bwrsandman you can make the test 1 - go to the list of travel.travel 2 - export the data including the field travel_state of the related traveller you will get an error saying the field has no attribute selection

ghost commented 9 years ago

@bwrsandman in openerp/osv/orm.py ? in __export_row row 1173 I know this does not seem much logic, and this could be fixed in the orm. I guess this problem is fixed in v8.

bwrsandman commented 9 years ago

Ok, I see the error. That's an odoo bug.

One thing to fix, though. Don't duplicate the states, just factor them into a class-less function in travel.py

def _get_states(self, cr, uid, ids=None, context=None):
    return [
        ('draft', _('Draft')),
        ('open', _('Saved')),
        ('booking', _('In Reservation')),
        ('reserved', _('Reserved')),
        ('confirmed', _('Confirmed')),
        ('done', _('Closed')),
    ]

Then use it like this:

from openerp.addons.travel.travel import _get_states
# ...
_columns = {
    # ...
    'state': fields.related(
        selection=lambda *a, **kw: _get_states(*a, **kw),
    ),
    # ...
}

Also factor the original so the states are only defined once.

ghost commented 9 years ago

@bwrsandman can you add wip label ?

ghost commented 9 years ago

@bwrsandman I fixed the issue. You may remove the wip label. Thanks

pedrobaeza commented 9 years ago

:+1:

houssine78 commented 9 years ago

:+1: review no test

ghost commented 9 years ago

@max3903 Can you merge this PR please ?

bwrsandman commented 9 years ago

@max3903 @dufresnedavid This repo has been failing since this was merged, please fix before merging anythin else.

ghost commented 9 years ago

@bwrsandman the travis build was ok in this PR. Why do you think it is related to the current problem ? I would say https://github.com/OCA/vertical-travel/pull/38 is the cause of the problem.

bwrsandman commented 9 years ago

This was merged before #38 and you can see the build starts failing at this merge:

https://travis-ci.org/OCA/vertical-travel/builds