Skip to Content
Menu
This question has been flagged
2 Replies
3738 Views

Is it possible to add variables in a html field in crm.lead panel or res.partner panel?

For example: Add an html field with some fixed data and the name of the customer or the name of the seller

Thanks

Avatar
Discard
Author Best Answer

What I want is to create an html code that has a fixed part and a variable part (you must take the name of the customer, the name of the seller and the phone number). All show it in crm.lead panel.

It's possible?

How can I inherit crm.lead?

Avatar
Discard
Best Answer

Please explain what you mean by html field  ? A text box or else? 
You can inherit crm.lead  and add new Many2one field from res.partner. Then inherit the xml view and display this new field.

Avatar
Discard
Author

What I want is to create an html code that has a fixed part and a variable part (you must take the name of the customer, the name of the seller and the phone number). All show it in crm.lead panel.

It's possible?

How can I inherit crm.lead?

Yes this is possible. What I guess you need to generate sequence something like Code = CustName-SellerName-59821654 and display on the crm.lead form view.

crm.lead already has a customer (partner_id). Where you taking the seller? Do you have customized field for Seller?

Author

I need to do something like this:

<a href="Path+<field name="partner_address_phone"/><field name="partner_id"/><field name="user_id"/>">Text </a>

The code: <field name="partner_address_phone"/><field name="partner_id"/><field name="user_id"/> It works if I write it outside <a>

But I think that because of the quotes (") I don't get it to work. The variables are not shown..

How can I do it? How can I concatenate the variables with the code?

Thanks

You have to use widget to show hyper link on form view. Here is an example.

<field name="partner_address_phone" widget="url"/>

But remember field partner_address_phone build its path in the python code.

e.g. make it a compute field where you concatenate the path and partner_address_phone and widget="url" will make it a link.

Author

This way I can use 2 variables?

For example: <field name="path+partner_address_phone+user_id" widget="url"/>?

I think you cannot use <field name="path+partner_address_phone+user_id" widget="url"/>.

You have to do it in python code and in a compute function.

Author

Thank you. I think the same. Do not let concatenate variables.

Where should I do that python code? How do you create a function?

To create a function in odoo you need to now little bit coding and python.

See this video how to inherit a model and add new field.. https://www.youtube.com/watch?v=z1Tx7EGkPy0

Here you will find what you need in your function..

https://stackoverflow.com/questions/35311903/how-to-define-link-text-different-in-odoo-widget-url