Skip to Content
Menu
This question has been flagged
2 Replies
10550 Views

Hi,


I try to inherit(models.Model) a model defined with osv.osv that contains a field selection which is computed.

I redefined the whole Selection field with the same parameters as I want to override the function called by the compute.

As value of my compute field option, I put my new compute method.

The new compute method call the super one, set the field and then I do my stuff.


Module install is ok, new compute function is well called.

But when I let debugging continue, I got the Exception : 'undefined get method'.

After deep debugging, it appears that my Selection field got the type osv.fields.selection instead of osv.fields.function => the selection type don't have a get method (see the _column object in openerp.osv.fields).

The original model (without my module) has the good type osv.fields.function...


Is it a framework error?


Many thanks for your help

Avatar
Discard

There is no bug for selection field, you might using wrong coding structure in odoo 8, Can you give the sample code what you have tried to set selection?

Author Best Answer

The code looks like that : 

 @api.one

    @api.depends('move_type','move_lines.state', 'move_lines.partially_available')

    def _state__get(self):

        result = super(stock_picking,self)._state_get(None,None)

        self.state = result[self.id]

        

        if self.state == 'assigned':

            self._update_intervention_tasks()



    

    state=fields.Selection(compute=_state__get, copy=False,

            store=True,

            selection=[

                ('draft', 'Draft'),

                ('cancel', 'Cancelled'),

                ('waiting', 'Waiting Another Operation'),

                ('confirmed', 'Waiting Availability'),

                ('partially_available', 'Partially Available'),

                ('assigned', 'Ready to Transfer'),

                ('done', 'Transferred'),

                ], string='Status', readonly=True, select=True, track_visibility='onchange',

            help="""

                * Draft: not confirmed yet and will not be scheduled until confirmed\n

                * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n

                * Waiting Availability: still waiting for the availability of products\n

                * Partially Available: some products are available and reserved\n

                * Ready to Transfer: products reserved, simply waiting for confirmation.\n

                * Transferred: has been processed, can't be modified or cancelled anymore\n

                * Cancelled: has been cancelled, can't be confirmed anymore"""

                )

    

 


Avatar
Discard
Author

EDIT : Is it possible that when you change a field that has 'track_visibility' attribute and obviously inherits from 'mail.thread', you have to redeclare inheritance in the new module model you write (error has disappeared)?

@Denis don't you still get an error on install of the module on an empty database? We get Exception: undefined get method ! like here: https://github.com/OCA/carrier-delivery/pull/47

Related Posts Replies Views Activity
1
May 25
753
0
Jan 24
1506
2
Mar 24
5155
2
May 23
8368
1
Feb 22
23523