Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
510 Vues

I added this 

class SupplierInherit(models.Model):
_inherit = 'product.supplierinfo'

vendor_stockinfo = fields.Integer(string="Vendor Stock")
<record id="inherit_supplierinfo_tree_view_vendor_stockinfo" model="ir.ui.view">
<field name="name">Add vendor_stockinfo to product.product_supplierinfo_tree_view</field>
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_code']" position="after">
<field name="vendor_stockinfo"/>
</xpath>
</field>
</record>
<record id="product_template_form_view_inherit_override_seller_ids" model="ir.ui.view">
    <field name="name">Override seller_ids with custom tree</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='seller_ids']" position="replace">
            <field name="seller_ids"
                   context="{'default_product_tmpl_id': id, 'list_view_ref': 'your_module.custom_supplierinfo_tree_view_with_vendor_stock'}"
                   nolabel="1"
                   invisible="product_variant_count &gt; 1"
                   readonly="product_variant_count &gt; 1"
            />
        </xpath>
    </field>
</record>


but field is not showing
Avatar
Ignorer

Source looks fine. What are your manifest and init files and what is your folder structure looking?

Meilleure réponse

Hi,

Please refer to the code below:

Python

class SupplierInherit(models.Model):
_inherit = 'product.supplierinfo'

vendor_stockinfo = fields.Integer(string="Vendor Stock")

XML


<record id="product_supplierinfo_subcontractor_tree_view" model="ir.ui.view">
<field name="name">product.supplierinfo.subcontractor.list.view</field>
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_code']" position="after">
<field name="vendor_stockinfo"/>
</xpath>
</field>
</record>

Result:




Hope it helps.

Avatar
Ignorer
Auteur

It doesn't work for me.

Meilleure réponse

Hii,

Define the vendor_stockinfo Field in product.supplierinfo

First, you correctly define the vendor_stockinfo field in the product.supplierinfo model.

class SupplierInherit(models.Model): _inherit = 'product.supplierinfo' vendor_stockinfo = fields.Integer(string="Vendor Stock")

Modify the product.supplierinfo Tree View to Display vendor_stockinfo

Now, you need to modify the tree view for the product.supplierinfo model to display the vendor_stockinfo field. You can inherit and update the view like this:

<record id="inherit_supplierinfo_tree_view_vendor_stockinfo" model="ir.ui.view"> <field name="name">Add vendor_stockinfo to product_supplierinfo_tree_view</field> <field name="model">product.supplierinfo</field> <field name="inherit_id" ref="product.product_supplierinfo_tree_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='product_code']" position="after"> <field name="vendor_stockinfo"/> </xpath> </field> </record>

Override the product.template Form View to Display the Custom Tree View

The seller_ids field in the product.template form view needs to be replaced with a custom tree view that includes the vendor_stockinfo field.

Here’s how to do it:

<record id="product_template_form_view_inherit_override_seller_ids" model="ir.ui.view"> <field name="name">Override seller_ids with custom tree</field> <field name="model">product.template</field> <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='seller_ids']" position="replace"> <field name="seller_ids" context="{'default_product_tmpl_id': id, 'list_view_ref': 'your_module.custom_supplierinfo_tree_view_with_vendor_stock'}" nolabel="1" invisible="product_variant_count &gt; 1" readonly="product_variant_count &gt; 1" /> </xpath> </field> </record>

Define the Custom Tree View for product.supplierinfo

You need to create a custom tree view that includes the vendor_stockinfo field. Here’s how to define the tree view:

<record id="custom_supplierinfo_tree_view_with_vendor_stock" model="ir.ui.view"> <field name="name">product.supplierinfo.tree.with.vendor.stock</field> <field name="model">product.supplierinfo</field> <field name="arch" type="xml"> <tree> <field name="product_code"/> <field name="vendor_stockinfo"/> <!-- Your custom field here --> <field name="price"/> <field name="min_qty"/> <!-- Add other necessary fields here --> </tree> </field> </record>

Ensure Your Module is Loaded Correctly

Make sure your module's manifest file references the correct XML files, and then update your module.

__manifest__.py:


{ 'name': 'Plantillas Personalizadas', 'version': '1.0', 'summary': 'Plantillas Servicio Externo', 'description': 'Aplicación que guarda las plantillas para la aplicación servicio externo', 'depends': ['product'], 'data': [ 'views/worksheet_template_views.xml', # Your custom view file 'views/product_template_form_view_inherit.xml', # Form view inheritance ], 'license': 'LGPL-3', }

i hope it is use full

Avatar
Ignorer
Auteur

not worked

Publications associées Réponses Vues Activité
3
sept. 15
6082
8
août 15
16512
1
mars 15
3184
1
mars 23
1823
3
avr. 17
5346