Community mailing list archives

community@mail.odoo.com

Re: Functional overriding

by
mudoko
- 02/26/2016 06:56:52
Hi Houssine and Dhirendrashing, Thanks so much for your response, i want to extract stock valuation(esp. on hand)  of all finished products and raw material and display in mrp.bom.form thats why i was inheriting mrp.bom and calling the valuation function, is this correct, or what should i do.


Systems developer

Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com


On Fri, Feb 26, 2016 at 2:21 PM, Houssine BAKKALI <houssine.bakkali@gmail.com> wrote:
yep Dhirendrashing pointed a wrong call to the super class...

your class is declared as mrp_exend you inherit from mrp.bom
 model and you call the parent class as stock_quant which can't work...

so you should change things. follow the suggestion of Dhirendrasing even if osv.osv is deprecated...

Check also your import declaration as you probably imported from new api and using old api...

2016-02-26 9:16 GMT+01:00 Dhirendrasinh Thakor <dhirendra718@gmail.com>:
Hello Peter,

In your cash maybe this will be help you.

class stock_quant(osv.osv):

    _inherit = 'stock.quant'


    def _calc_inventory_values(self, cr, uid, ids, name, attr, context=None):

           RS=super(stock_quant, self)

                res=RS._calc_inventory_value(cr, uid, ids, name,attr, context=None)

                return res


and the functional field is:

 _columns = { 'inventory_value': fields.function(_calc_inventory_values, string="Inventory Value", type='float', readonly=True),}

On Wed, Feb 24, 2016 at 3:06 PM, Houssine BAKKALI <houssine.bakkali@gmail.com> wrote:
you seem to use old api with models.Model

so if you imported the fields from the same place that the models It will not work.

You better use new api for this or switch you import and model declaration to the old api...

2016-02-24 10:13 GMT+01:00 Peter Mudoko <petypi@gmail.com>:

 Hi guys am trying to overide a fumctional field in stocks(stocks_quant) _calc_inventory_value, as follows:


class mrp_extend(models.Model):

    _inherit = 'mrp.bom'

    def _calc_inventory_values(self, cr, uid, ids, name, attr, context=None):

       RS=super(stock_quant, self)

                res=RS._calc_inventory_value(cr, uid, ids, name,attr, context=None)

                return res


and the functional field is:

 _columns = { 'inventory_value': fields.function(_calc_inventory_values, string="Inventory Value", type='float', readonly=True),}



But am getting 'TypeError: super(type, obj): obj must be an instance or subtype of type' any help kindly.


Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe