Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wish] View dicts attributes and domain inheritance improvement #56661

Open
LuisMalave2001 opened this issue Aug 27, 2020 · 5 comments
Open

[Wish] View dicts attributes and domain inheritance improvement #56661

LuisMalave2001 opened this issue Aug 27, 2020 · 5 comments

Comments

@LuisMalave2001
Copy link
Contributor

Current behavior:

If you want to overwrite some attribute which value must to be and dict, for example, attrs, you need to rewrite the original value with your changes. The problem with this is when two modules overwrite that attribute in that tag.

For example:

Original Module:

<field name="foo" attrs="{'readonly': True}"/>

Module A trying to modifying attrs:

<attribute name="attrs">{'readonly': True, 'invisible': [<domain>] }</attribute>

Module B trying to modifying attrs:

<attribute name="attrs">{'readonly': False, 'invisible': [<other_domain>]}</attribute>

So... to get this work, A or B needs to know each other their invisible domain... And to know the exact values that the Original Module has.

Request:

It would be fixed if we can modify, add or remove by 'key'. Something like:

Module A now can do

<attribute name="attrs" type="dict">
    <key name="invisible" value="[<domain>]"/>
</attribute>

And Module B can now do this

<attribute name="attrs" type="dict">
    <key name="invisible" value="[<other_domain>]"/>
</attribute>

And if we can be allowed to add domains so:

Module A:

<attribute name="attrs" type="dict">
    <key name="invisible" type="domain" mode="add" value="[<domain>]"/>
</attribute>

Module B:

<attribute name="attrs" type="dict">
    <key name="invisible" type="domain" mode="add" value="[<other_domain>]"/>
</attribute>

The final Original Module domain in the final view will be

<attribute name="attrs">{'readonly': True, 'invisible': [<domain>, <other_domain>]}</attribute>

This can be added to context attributes and domain.

@LuisMalave2001 LuisMalave2001 changed the title View dicts attributes and domain inheritance improvement [Wish] View dicts attributes and domain inheritance improvement Aug 27, 2020
@pedrobaeza
Copy link
Collaborator

This is a known problem, but with no solution so far. That's why I proposed #26607. @xmo-odoo did you get to any alternative meanwhile?

@pedrobaeza
Copy link
Collaborator

@LuisMalave2001
Copy link
Contributor Author

To be honest, I am new at odoo and python development, but, I would like to try, I already see that string manipulation is tricky and there should be an alternative. My english and programming skills are not the best. But I could try to modify the current view engine.

Could you provide me where I should look up?

@pedrobaeza
Copy link
Collaborator

For your current level, better that you depend on the proposed module and use its mechanism for what you want.

@celm1990
Copy link
Contributor

celm1990 commented Sep 16, 2020

Hi, i have similar problem, i use module base_view_inheritance_extension

I try change attrs readonly on field partner_type

my code is
image

image

error is load current json https://github.com/OCA/server-tools/blob/13.0/base_view_inheritance_extension/models/ir_ui_view.py#L115

image

I tested on V13 but i see on V12 is diff to V13. my code is bad or is problem of library???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants