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] product_variants_no_automatic_creation: Updated for Odoo 9.0 #1098

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions product_variants_no_automatic_creation/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,54 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<button string="Variant Prices" position="attributes">
<xpath expr="//button[@name='103']" position="attributes">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number won't work in other database. You have to use the same expression as in original.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not a number, its a string.. and the name of the button.
According the view (product.template.common.form) 103 is its name
So instead of looking up the text string "Variant Prices" its looking for
the name of the button

[image: Inline afbeelding 1]

and works just fine.
Its hiding the original variant prices button and adds the new one
[image: Inline afbeelding 2]

2015-12-12 7:36 GMT-05:00 Pedro M. Baeza notifications@github.com:

In product_variants_no_automatic_creation/views/product_view.xml
#1098 (comment):

@@ -17,18 +17,54 @@
product.template

  •            <button string="Variant Prices" position="attributes">
    
  •        <xpath expr="//button[@name='103']" position="attributes">
    

This number won't work in any database. You have to use the same
expression as in original.


Reply to this email directly or view it on GitHub
https://github.com/odoomrp/odoomrp-wip/pull/1098/files#r47431254.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is because it's replaced in execution time by its current XML-ID. Here you can see the correct expression: https://github.com/odoo/odoo/blob/9.0/addons/product/product_view.xml#L77

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so if i understand right, these IDs are generated upon installation and
can vary per install.
so the 103 name is the name from my current install and therefore working
as intended.
And for that it was looking for the text string

2015-12-14 12:51 GMT-05:00 Pedro M. Baeza notifications@github.com:

In product_variants_no_automatic_creation/views/product_view.xml
#1098 (comment):

@@ -17,18 +17,54 @@
product.template

  •            <button string="Variant Prices" position="attributes">
    
  •        <xpath expr="//button[@name='103']" position="attributes">
    

But this is because it's replaced in execution time by its current XML-ID.
Here you can see the correct expression:
https://github.com/odoo/odoo/blob/9.0/addons/product/product_view.xml#L77


Reply to this email directly or view it on GitHub
https://github.com/odoomrp/odoomrp-wip/pull/1098/files#r47531221.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's it


<attribute name="invisible">1</attribute>
</button>
<button string="Variant Prices" position="after">
</xpath>
<xpath expr="//button[@name='103']" position="after">

<button class="oe_inline oe_stat_button" name="action_open_attribute_prices"
icon="fa-strikethrough" type="object" string="Variant Prices">
</button>
</button>
<field name="attribute_line_ids" position="before">
</xpath>
<xpath expr="//field[@name='attribute_line_ids']" position="before">

<group>
<field name="no_create_variants" />
</group>
</xpath>
</field>
</record>

<record model="ir.ui.view" id="product_variants_view">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied-pasted from 8.0, but you have to update all the changes introduce in 8.0. See https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-9.0

<field name="name">product.product.variants.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="attrs">{'invisible':['|',('id','!=',False),('product_tmpl_id','!=',False)],'readonly':[('product_tmpl_id','!=',False)]}</attribute>
</field>
<field name="product_tmpl_id" position="attributes">
<attribute name="readonly" />
<attribute name="attrs">{'readonly':[('id','!=',False)],'required':[('id','!=',False)]}</attribute>
</field>
<xpath expr="//field[@name='product_tmpl_id']/.." position="after">
<p class="oe_grey" attrs="{'invisible':[('id','!=',False)]}">
Select a template for a variant. Keep empty for a new full product.
</p>
</xpath>
<field name="attribute_value_ids" position="after">
<label for="product_attributes"
attrs="{'invisible':['|',('id','!=',False),'|',('product_tmpl_id','=',False),('product_attributes','=',[])]}" />
<field name="product_attributes"
attrs="{'invisible':['|',('id','!=',False),'|',('product_tmpl_id','=',False),('product_attributes','=',[])]}"
options="{'no_create': True, 'no_delete': True}">
<tree create="0" delete="0" editable="1">
<field name="attribute" />
<field name="possible_values" invisible="1" />
<field name="value" context="{'show_attribute': False}" />
</tree>
</field>
</field>
</field>
</record>
Expand Down