Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
16592 Lượt xem

I have a problem in changing the names for odoo addon modules. I've tried with xpath, attributes, but I just can't get it to work.

<xpath expr="//field[@name='manager_id']" position="attributes">
    <attribute name="string">New Field Label</attribute>
</xpath>

<field name="manager_id" position="attributes">
    <attribute name="string">New Field Label</attribute>
</field>

There must be a  way to change the field labels? And is there a way to change it so that it changes in every view the field is used?

EDIT:

code that I tried:

<record model="ir.ui.view" id="view_hr_res_company_form">
	<field name="inherit_id" ref="base.view_company_form" />
	<field name="model">res.company</field>
	<field name="arch" type="xml">
		<xpath expr="//form/sheet/notebook/page/field[@name='company_registry']" position="attributes">
			<attribute name="string">Matična številka</attribute>
		</xpath>
		<xpath expr="//field[@name='vat']" position="after">
			<field name="account_no"/>
			<field name="obcina"/>
			<field name="dejavnost"/>
		</xpath>
	</field>
</record>


  

Ảnh đại diện
Huỷ bỏ

Hi Samo,

Your approach is correct, you need to check with priorities and also check with inherit_id.

Tác giả

can you dumb it down so I could understand :) I edited the question with the code I tried.

Câu trả lời hay nhất

Hi Samo,

You're trying update slovenian string as en_US in view, this is not correct approach better need to do this change into translation file directly.

add in your po file the related field like example:

#. module: <your_module>

#: field: <your_moddel>,field:0

#: field: <your_related_moddel>,field:0

msgid "English"

msgstr "Translation"

Ảnh đại diện
Huỷ bỏ
Tác giả

Can't change directly into the translation file. Needs to be in the custom module so it's independent from odoo install and it's files. Plus I don't have time to figure out another odoo functionality.

You could also change it from odoo ir translation if you're struggling to add it from files

Tác giả

Sushma you are correct, but NOT helpful because I don't have time for the correct way, I just need a quick work around. I'll do the correct way, when I start building the next custom module from ground up.

Tác giả

you where right in the first comment on my question. The xpath was to complicated. With only //field[@name="<name_of_field>"] it works.

Câu trả lời hay nhất

You can inherit the model in python 

_inherit='model.name'

and override the field definition to set the string to whatever label you desire

manager_id = fields.Many2one(string='Your preferred label')
Ảnh đại diện
Huỷ bỏ
Tác giả

It doesn't work, probably because it's translated. Any way to change the translation?

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 18
5953
1
thg 4 18
3394
0
thg 1 18
4098
0
thg 9 17
3236
1
thg 3 19
4429