Odoo Aide

1

0
2 Answers
3
Harsh Savsani
27/05/2019 02:06

Hi Diego,

As Bhaviraj said, you cannot define one field multiple times in a view. For your requirement, you can use fields_view_get method to change the label of the field.

Try following code:

from lxml import etree

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
submenu=False):
res = super(TestProject, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)
doc = etree.XML(result['arch'])
for node in doc.xpath("//field[@name='partner_id']"):
if self._context.get('quotes'):
node.set('string', 'Customer')
else:
node.set('string', 'Member')
return res
1 Commentaires
Diego B.
27/05/2019 02:11

Thanks a lot! Finally, that was what I made. I've set conditionally 'string' and 'domain' in fields_view_get function and left only one field in XML view.

0

Hello Diego,

Code is not correct. One field can not be used into same xml view twice. Take one more field with member_id name for res.partner. and replace one of partner_id fields with member_id.


Hope this will help you. 

Poser une question
Writer
Étiquettes
Keep Informed
1 Abonné(e)s
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register