Community mailing list archives

community@mail.odoo.com

extends field selection without overwriting

by
hans.yonathan
- 02/09/2015 04:40:35

Hi Odoo community,

 

Following about this discussion:

https://www.odoo.com/forum/how-to/developers-13/how-to-extend-fields-selection-options-without-overwriting-them-21529

 

I tried with usecase: “when you don’t have control on the original model”

I tried this code like in the discussion on the version 8:

 

    def __init__(self, cr, uid, name, context=None):

        super(product_category, self).__init__(cr, uid, name, context)

        option = ('special', 'Special')

        type_selection = self._columns['type'].selection

        if option not in type_selection:

            type_selection.append(option)

 

Which is not worked at all, and implied an error.

So I want to revised it, it should be:

    

def __init__(self, pool, cr):

        init_res = super(product_category, self).__init__(pool, cr)

        option = ('special', 'Special')

        type_selection = self._columns['type'].selection

        if option not in type_selection:

            type_selection.append(option)

        return init_res

 

 

This code work fine in version 8, I want to revised that discussion but I don’t have access of it.

 

Thank You.

 

Best Regards,

Hans Yonathan

Odoo Support

FALINWA Limited

Expert in Finance, Information System & Business Intelligence

Odoo Silver Partner

Website: www.falinwa.com

Tel. 13670137019 (China - Shenzhen)