您好,我想更改 odoo 中的基本字段属性

问题描述 投票:0回答:1

我尝试更改基本字段属性并按照该视频进行操作https://www.youtube.com/watch?v=6bIgk4mtfQ4它在必需或只读属性为1的情况下运行良好,但不使用翻译属性为 True 或 1。 这段代码运行良好

    <?xml version="1.0"?>
<data>
<xpath expr="//field[@name='url']" position= "attributes">
    <attribute name="required">1</attribute>/>
</xpath>
</data>

不是那个

    <?xml version="1.0"?>
<data>
<xpath expr="//field[@name='url']" position= "attributes">
    <attribute name="translate">1</attribute>/>
</xpath>
</data>

Rgds

attributes odoo
1个回答
0
投票

使字段可翻译必须在字段定义 IIRC 上完成。因此,您必须为此创建一个自定义模块,然后“重新定义”该字段。

class MyModel(models.Model):
   _inherit = "my.model"

   my_field = fields.Char(translate=True)

这就是基本字段、由模块和应用程序创建的字段。对于自定义字段、在 GUI 中创建的字段(直接或通过 Odoo Studio),您可以根据需要设置“可翻译”。

© www.soinside.com 2019 - 2024. All rights reserved.