跳至内容
菜单
此问题已终结
1 回复
1415 查看

hello,

I write simple module with one feild (name) which refer to the company name in footer copyright in website

How can i use value of this field  to be shown in footer copyright 


形象
丢弃
最佳答案

Hi Heba,


>
<template id="footer_copyright_company_name_custom" inherit_id="website.layout">
<xpath expr="//footer//span[hasclass('o_footer_copyright_name')]" position="replace">
<span class="o_footer_custom_name me-2" t-esc="website.company_id.your_custom_field_name">span>
xpath>
template>
odoo>



Make sure to replace "your_custom_field_name" with the actual name of the custom field you want to use from the company master, or modify the expression if the field is defined somewhere else. Once you have added this code and upgraded the module that contains the XML file, the value of the custom field will be displayed in the footer.

Hope it helps,
Kiran K

形象
丢弃

<odoo>
<template id="footer_copyright_company_name_custom" inherit_id="website.layout">
<xpath expr="//footer//span[hasclass('o_footer_copyright_name')]" position="replace">
<span class="o_footer_custom_name me-2" t-esc="website.company_id.your_custom_field_name"></span>
</xpath>
</template>
</odoo>

编写者

thanks for you:

what should i write instead of this  website.company_id.your_custom_field_name

if the field is in  my custom module :Copy_right_chang

field name :company_name

i try Copy_right_chang.company_name

give error 

in which model you defined the field company_name ?

if its in res.company , the code will be website.company_id.company_name

编写者

THE field company_name IN MY CUSTOM MODULE CALLED Copy_right_chang

'Model' and 'Module' are different.

Within the 'Copy_right_chang' module, please specify the model name where the field 'company_name' is defined. The model name usually starts with _name or _inherit in the Python file .

编写者

The module name is CopyRightChange >>>> the model name is :
_name=copy.right.change

I suggest creating a key in the system parameters and fetching the corresponding value using the code

<span t-esc="env['ir.config_parameter'].sudo().get_param('your_parameter_key')"/>

OR

Inherit 'res.company' create your custom field .

<span class="o_footer_custom_name me-2" t-esc="website.company_id.your_custom_field_name"/>