Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
809 Widoki

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
Awatar
Odrzuć

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

It doesn't work for me.

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

not worked

Powiązane posty Odpowiedzi Widoki Czynność
3
wrz 15
6273
8
sie 15
16686
1
mar 15
3283
1
mar 23
1990
3
kwi 17
5465