Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
480 Vizualizări

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
Imagine profil
Abandonează

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

Cel mai bun răspuns

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.

Imagine profil
Abandonează
Autor

It doesn't work for me.

Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

not worked

Related Posts Răspunsuri Vizualizări Activitate
3
sept. 15
6074
8
aug. 15
16497
1
mar. 15
3169
1
mar. 23
1818
3
apr. 17
5336