Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
3955 Visualizações

trying to add a custom field from Odoo frontend (Settings -> Technical -> Models) but when trying to save Model it is showing error. after given the required things i pressed SAVE & CLOSE button. please check the screenshots below and help what is the problem and how it can be resolved. the Domain is to exclude current logged-in user from selection in Many2one list which seems not working as without this domain filter the field is showing all data successfully, how to write this domain here? the Domain is: 

[lambda self: [('id', '!=', self.env.user.id)]]




regards

Avatar
Cancelar
Melhor resposta

Hi  SmithJohn45,

The error is not related to the domain you added, it is related to the 'Order' field in the 'ir.model'. 



This is a bug in Odoo that arises with models created through Delegation Inheritance. The same issue also occurs with the 'Product Variant' model.

An alternative approach to adding a field in the 'res.users' model is to navigate to Settings / Technical / Database Structure / Fields.



***********************************************************************************

UPDATE

To get current user in domain,

1. Created a new Many2one field in res.users




In the ' ADVANCED PROPERTIES'  Section,

Update the field's dependencies & compute.


Now create the field, Supervisor,



For the field "x_supervisor," apply the domain.






Hope it helps,
Kiran K

Avatar
Cancelar
Autor

thank you for reply.
.
added the field as instructed, it saved and when access the user's form through
Settings -> Users & Companies -> Users
and try to click on newly added field, it is showing below error:

UncaughtPromiseError > TypeError
Uncaught Promise > elem.map is not a function

TypeError: elem.map is not a function
at http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:404:342
at Array.map (<anonymous>)
at toAST (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:404:232)
at new Domain (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:400:147)
at Record.getFieldDomain (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:2337:144)
at get domain [as domain] (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:3255:39)
at Many2OneField.getDomain (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:3264:25)
at Many2XAutocomplete.loadOptionsSource (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:3580:113)
at AutoComplete.loadOptions (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:46:69)
at AutoComplete.loadSources (http://localhost:8069/web/assets/772-13bbf92/web.assets_backend.min.js:44:213)

please advise.
regards
.

Now it's related to your domain I guess.
Can you remove the domain and make sure?

Autor

after removing domain its working fine, but domain is required, how i can add without custom Module?

Hi SmithJohn45,

Updated my answer, Please check.

Autor

thanks a bunch for great help... appreciate your passion to help me.
kind regards

Publicações relacionadas Respostas Visualizações Atividade
1
jul. 23
4053
2
set. 24
2024
2
out. 23
3101
1
ago. 23
1779
1
set. 23
3051