Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
44836 Weergaven

Hi Experts,

  Purpose: Intend to hide the "sale price" when a product is not marked as "can be sold" under the product "general information" tab.  

 Version: 10 CE

 Found this original field from product_views.xml: 

<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id'}"/>

 I wrote this:

<record id= "product_template_form_view_inherited" model= "ir.ui.view">

            <field name="inherit_id" ref="product.product_template_form_view" />

            <field name="model">product.template</field >

            <field name="arch" type= "xml">

                <group name="group_standard_price">

                   <field name="list_price" position="attributes">

                     <attrs name='invisible'>{[('sale_ok','=',False)]}</attrs>

                     <attrs name='widget'>{'monetary'}</attrs>

                    <attrs name='options'>{'currency_field': 'currency_id'}</attrs>

                 </field>

                </group>

            </field>

          </record>


It did not work, any idea? 

p/s: I always have this doubt, if I extend a field with the purpose to override one intended attribute only, I still need to include all other original attributes so they are all retained, right?

Thank you!

Tom

 

Avatar
Annuleer

use xpath to find the field you want to modify, then your code will work. you don't need to rewrite all attributes in your extension. only the ones you need to modify. otherwise you will mess with other things.

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

<attribute name=" ... "> ... value here ... </attribute>

</xpath>

Beste antwoord

Hello Tom,

try this.

<xpath expr="//field[@name='list_price']" position="attributes">
      <attribute name="attrs">{'invisible':[('sale_ok','=', False)]}</attribute>
</xpath>

or

<xpath expr="//field[@name='list_price']" position="attributes">
      <attribute name="attrs">{'invisible':[('sale_ok','!=', True)]}</attribute>
</xpath>
Avatar
Annuleer
Beste antwoord

Extending the schema refers to adding elements to the schema, usually object classes and attributes. The default schema comes with many object classes and attributes that are ready to be used for entries. Before you extend the schema, see if there are existing elements in the default schema that you might use instead of extending the schema. For example, if you need an additional attribute for the dominoPerson object class, evaluate if you can use an attribute already defined for dominoPerson.

https://www.dltutuapp.com/

https://www.9apps.ooo/

https://www.showbox.run/

Avatar
Annuleer
Beste antwoord

You can extend the schema by adding forms, subforms, and fields to the Domino Directory. This method allows Notes and Web users to create and view entries that use the new schema elements as documents, while also enabling LDAP user access to the entries. This method is more time consuming than using the Schema database, and must be done carefully to avoid mistakes in schema definition.

https://9appsapk.com https://vidmate.vin

Avatar
Annuleer
Beste antwoord

 You don't need to recreate all field attributes again with the new API:

from odoo import models, fields class SaleOrder(models.Model): _inherit = "sale.order" website_description = fields.Html(translate=False)

That should be enough.

I https://get-shareit.com

I https://get-vidmateapk.com

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
feb. 23
7944
1
feb. 25
1129
2
mei 21
18863
1
jul. 15
6986
0
mrt. 15
5309