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

[FIX] base: better branding with view inheritance #31039

Closed
wants to merge 1 commit into
base: 12.0
from

Conversation

Projects
None yet
3 participants
@nle-odoo
Copy link
Contributor

nle-odoo commented Feb 12, 2019

To edit a view on the website, we use the branding mechanism.

This mechanism adds informations to node which can be edited about how
or where the change should be saved, for example:

  <template id="a">
    <div><b>hello</b></div>
  </template>

might be rendered to someone that can edit it:

<div data-oe-model="ir.ui.view" data-oe-id="5" data-oe-field="arch" data-oe-xpath="/div[1]"><b>hello</b></div>

when something is changed: we will send the modified content, the view
id (eg. 5 for view a) and the xpath in this view of what is replaced.

If a view is overridden, there is mechanism to distribute the branding
to children, for example:

  <template id="b">
    <div>
      <b>hello</b>
    <div>
  </template>
  <template inherit_id="b">
    <div position="inside">
      <b>world</b>
    </div>
  </template>

The branding can't be on the parent div that will contain other content,
because the other content is in another template and should not be saved
in template b, so this would be rendered like this:

<div><b data-oe-model="ir.ui.view" data-oe-id="6" data-oe-field="arch" data-oe-xpath="/div[1]/b[1]">hello</b><b data-oe-model="ir.ui.view" data-oe-id="7" data-oe-field="arch" data-oe-xpath="/div[1]/b[1]"><b> world</b></div>

This changeset fixes two issues:

  • if we have a primary inheriting view: the xpath are wrong in the
    primary inheriting view part, they are computed on the view applied on
    its inherit_id; the part of the inherit_id view have the primary
    inheriting view ID instead of inherit_id view id.

  • if we have <div t-call="..."/> in a view, the branding of view
    should be distributed to children and not affect t-call part: this was
    done for <t t-call="..."/> but not for <anyothertag t-call/>.

The added test failed on all assertions before the change:

  • "test_branding_primary_inherit" would not distributed
  • "test_call_no_branding" would distribute branding on t-call

opw-1937757

@nle-odoo nle-odoo force-pushed the odoo-dev:12.0-base-opw-1937757-nle branch Feb 12, 2019

@robodoo robodoo added the seen 🙂 label Feb 12, 2019

@nle-odoo nle-odoo added the OE label Feb 12, 2019

@robodoo robodoo added the CI 🤖 label Feb 12, 2019

@nle-odoo nle-odoo force-pushed the odoo-dev:12.0-base-opw-1937757-nle branch Feb 13, 2019

@robodoo robodoo removed the CI 🤖 label Feb 13, 2019

@nle-odoo nle-odoo requested a review from KangOl Feb 13, 2019

@robodoo robodoo added the CI 🤖 label Feb 13, 2019

@nle-odoo nle-odoo requested review from KangOl and removed request for KangOl Feb 20, 2019

odoo/addons/base/tests/test_views.py Outdated

[initial] = arch.xpath('//item[@order=1]')
self.assertEqual(
str(view1.id),

This comment has been minimized.

@KangOl

KangOl Feb 20, 2019

Contributor

While it works, you invert the operands. Your know value should be the second one.

This comment has been minimized.

@nle-odoo

nle-odoo Feb 20, 2019

Author Contributor

ok, I did the same as other test in the file. I will adapt

@nle-odoo nle-odoo force-pushed the odoo-dev:12.0-base-opw-1937757-nle branch Feb 20, 2019

@robodoo robodoo removed the CI 🤖 label Feb 20, 2019

[FIX] base: better branding with view inheritance
To edit a view on the website, we use the branding mechanism.

This mechanism adds informations to node which can be edited about how
or where the change should be saved, for example:

```
  <template id="a">
    <div><b>hello</b></div>
  </template>
```

might be rendered to someone that can edit it:

  `<div data-oe-model="ir.ui.view" data-oe-id="5" data-oe-field="arch"
     data-oe-xpath="/div[1]"><b>hello</b></div>`

when something is changed: we will send the modified content, the view
id (eg. 5 for view `a`) and the xpath in this view of what is replaced.

If a view is overridden, there is mechanism to distribute the branding
to children, for example:

```
  <template id="b">
    <div>
      <b>hello</b>
    <div>
  </template>
  <template inherit_id="b">
    <div position="inside">
      <b>world</b>
    </div>
  </template>
```

The branding can't be on the parent div that will contain other content,
because the other content is in another template and should not be saved
in template `b`, so this would be rendered like this:

  `<div><b data-oe-model="ir.ui.view" data-oe-id="6" data-oe-field="arch"
    data-oe-xpath="/div[1]/b[1]">hello</b><b data-oe-model="ir.ui.view"
    data-oe-id="7" data-oe-field="arch" data-oe-xpath="/div[1]/b[1]"><b>
    world</b></div>`

This changeset fixes two issues:

- if we have a primary inheriting view: the xpath are wrong in the
  primary inheriting view part, they are computed on the view applied on
  its inherit_id; the part of the inherit_id view have the primary
  inheriting view ID instead of inherit_id view id.

- if we have `<div t-call="..."/>` in a view, the branding of view
  should be distributed to children and not affect t-call part: this was
  done for `<t t-call="..."/>` but not for `<anyothertag t-call/>`.

The added test failed on all assertions before the change:

- "test_branding_primary_inherit" would not distributed
- "test_call_no_branding" would distribute branding on `t-call`

opw-1937757
closes #31039

@nle-odoo nle-odoo force-pushed the odoo-dev:12.0-base-opw-1937757-nle branch to 2a38dea Feb 20, 2019

@KangOl

This comment has been minimized.

Copy link
Contributor

KangOl commented Feb 20, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Feb 20, 2019

Merged, thanks!

@nle-odoo nle-odoo deleted the odoo-dev:12.0-base-opw-1937757-nle branch Feb 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.