Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
5 Replies
44388 Tampilan

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
Buang

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>

Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

 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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Feb 23
7479
1
Feb 25
772
2
Mei 21
18516
1
Jul 15
6750
0
Mar 15
5011