تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
16 الردود
9852 أدوات العرض

I am trying to edit definition of inherited field in odoo 8 but no changes at all. For example i want to change  product description

models.py

from openerp.osv import osv, fields, expression
import openerp.addons.decimal_precision as dp

class product_template(osv.osv):
    _name = "product.template"    _inherit =  "product.template"
    _columns = {        'description': fields.text('Description', translate=True,help="A precise description of the   Product, used only for internal information purposes. Extended!!!"),    }


I can't figure out what is the problem, why my change has no effect ??

الصورة الرمزية
إهمال
أفضل إجابة

Hi Ayman,

I tested your code in Odoo 8 and its perfectly working. There is no issue with providing _name

So in your case, please double check the following things:

- Your *.py file is included in __init__.py

- You restarted the server n upgraded the correct module

- Your module depends on product module

- Test with a new DB

الصورة الرمزية
إهمال
أفضل إجابة

you add file name in to __init__.py

and remove _name

restart server and update module and reload page.

then it's work i am 100% sure. 


Thank you.


الصورة الرمزية
إهمال
أفضل إجابة

Try this..

class product_template(osv.osv):
    _inherit =  "product.template"   

    _columns = { 'description': fields.text('Description', translate=True,help="A precise description of the   Product, used                                 only for internal information purposes. Extended!!!"),    }

Note: No need to write the name of the model (_name = "product.template") while inheriting a model .. !

Hope this helps !!!

الصورة الرمزية
إهمال

If its working for you just vote for it, so that it will be useful for others

الكاتب

no change yet

pls upgrade the module if not done.

الكاتب

sure i upgraded it restart server then upgrade module

i think it isn't about providing _name or not

الكاتب

also i tested the same scenario , i has made two modules one is inheriting from the other one

then every thing was correct but the problem when inheriting form "product.template"

أفضل إجابة

Hi Ayman, as you are already inheriting the product.template object then,again there is no need of defining the _name for your inherited model, so you need to remove this : _name = "product.template"

الصورة الرمزية
إهمال
الكاتب

i know but providing it shouldn't cause any problem,correct ??

Yes its not going to throw any error but, its not the proper way of inheriting an object.

by the way,which odoo version are you using,and what are you trying to do with description field.

الكاتب

thanks for the hint about inheritance ^_^

i am using odoo 8 trying to modify help massage of description field of the product as a test for further modification on other fields

أفضل إجابة

In Odoo/OpenERP we can inherit or use existing modules object/class/model and views. We can also inherit single field of existing modules. The question is why we need such inheritance.

The purpose of inheritance or why we need inheritance is given below:

  • To change attributes of some fields which exists on existing/custom model (e.g. making fields readonly,invisible)

  • To add/modify/delete old or new fields in existing/custom model (e.g. Product, Sales, HR, Fleet Management, Attendance modules model etc)

  • We can also add buttons in already existing/custom model (form and tree) view by using inheritance

Get detailed description about inheritance: http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

الصورة الرمزية
إهمال
أفضل إجابة

remove _name and put only _inherit . _inherit should contain the table name

الصورة الرمزية
إهمال
أفضل إجابة

If you create a new field in your inheritance class, does it appear in the fields list of the model product.template ?

What if you try to use this syntax?

description = fields.Text(string="Description", translate=True,help="A precise description of the Product, used only for internal information purposes. Extended!!!")

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يناير 20
14823
1
يناير 19
5189
5
يونيو 18
10593
0
سبتمبر 17
2302
0
فبراير 17
2814