Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
5381 Представления

According to read-the-docs at https://media.readthedocs.org/pdf/odoo-new-api-guide-line/latest/odoo-new-api-guide-line.pdf :

One of the new features of the API is to be able to change only one attribute of the field:

name = fields.Char(string=’New Value’)

 

So i do this in my_res_partner.py:

class my_res_partner(models.Model):

    _inherit = 'res.partner'

    is_company = fields.Boolean(string='Company')

AND IT DOES NOT CHANGE THE STRING? Why?

Аватар
Отменить
Лучший ответ

Hello John,

There are many ways to apply the string for a field.

The string for "is_company" is applied from the xml file from the view side. You can search in xml like "Is a Company?"

You metioned you want to change string of "is_company" right ?

Аватар
Отменить
Автор

Thanks for answering Hardikgiri. I want to be able to override the string in my inherited model inside my class, not in the xml view. My reason is that you are supposed to be able to do that and I would like to know how to do it properly in the new API. I already know I can do it in individual views and is_company really only shows up in one view but I would like to be able to do it in a module so that other fields that I use in multiple views can have their sting changed in the one file not multiple files. Do you understand?

Автор

Sorry, now I see what you are saying, in the ORIGINAL res.partner view the string is defined inside the label tag! That's why I can't get it to override! Thanks! I completely overlooked that.

Автор Лучший ответ

Field inheritance is still not working for me! I've tried it again and can't figure it out. See:
https://www.odoo.com/forum/help-1/question/does-field-inheritance-actually-work-or-is-it-buggy-74016

for my detailed experience and frustration with this problem. Hardikgiri's advice for xml views containing string overrides was helpful in that instance but in the link above you will see that I'm not dealing with that; just pure fied inheritance and it's buggy. Please help if you can.

Аватар
Отменить
Автор

It was acting buggy because I did not import my .py file in init but had imported other where it was working... DOH!