Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2283 Widoki

Hi I am currently trying to learn Odoo watching tutorials from Youtube and building my custom module. In my custom module I have inherited 'res.partner' model and added view that inherits the CRM->Sales->Customers->Customer view. I have succesfully added my own new fields into a customer view, but if I try to replace existing field the Odoo gives error since it is expecting these fields to exist. Is there a way to replace or remove these required fields?

Odoo version: 16

Awatar
Odrzuć
Autor

Hi and thank you Savya for taking your time to help.

After adding your code and making sure it didn't break anything I tried to add the following to my custom view:

name="mobile" position="replace">
​name="my_new_field"/>

But upgrading the custom module shows the following error message:

Name or id 'mobile' in 

Could be that the problem is not that field 'mobile' has attribute required, but perhaps something else in the app requires the field to exist?​​

Najlepsza odpowiedź

Hi,

The field that you are trying to replace is used in the same view for some other purpose, like may be in attrs, as per the shared message, it says that you cannot remove that field like that.

Instead if you don't need the field to be visible in the form, just keep it as hidden using the invisible attribute.


name="mobile" position="after"
​ ​name="my_new_field"


Using position after you can add the new field and if you need to hide the mobile field

name="mobile" position="attributes"
​ ​attribute name="invisible">1<


Thanks

Awatar
Odrzuć
Autor

Thank you this worked perfectly!

Najlepsza odpowiedź

Hi, 

you can try removing the required parameter of those fields like this,

<xpath expr="//field[@name='field_name']" position="attributes">

    <attribute name="required">0</attribute>

</xpath>


Thanks

Awatar
Odrzuć