Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5011 มุมมอง

hello guys.. im using odoo 13

i have requirements for showing products on the eCommerce website..

i have a new boolean field "Available on eCommerce" on the product.template model on the eCommerce tab, if the field is True then it will show to the eCommerce website.. if False, it will hide/not showed on the eCommerce website..


can someone help me? thanks a lot

อวตาร
ละทิ้ง

What are you using the field PUBLISHED for? (Normally this hides/shows products on the eCommerce website)

ผู้เขียน

where can i find published field? i cant see on tab ecommerce..

คำตอบที่ดีที่สุด

Hello rehan,

1) you can create a boolean field in product.template

class ProductTemplate(models.Model):

    _inherit = "product.template"

    available_on_ecommerce = fields.Boolean()

<?xml version="1.0" encoding="utf-8" ?>

<odoo>

    <data>

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

            <field name="name">product.template.extension.form.view</field>

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

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

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

                <xpath expr="//field[@name='website_url']" position="after">

                    <field name="available_on_ecommerce"/>

                </xpath>

            </field>

        </record>

    </data>

</odoo>

2) now you can hide/show a particular class(which shows products in website) on check/uncheck of boolean for this you need to inherit in website sale:

<template

    id="products_item"

    inherit_id="website_sale.products_item"

    name="Product item"

>

    <xpath expr="//div[hasclass('o_wsale_product_information')]" position="attributes">

        <attribute name="t-attf-class">

        <attribute

            name="t-attf-class"

        > #{'card-body p-0 text-center o_wsale_product_information' if product.available_on_ecommerce else 'website_invisible'} </attribute>

        </attribute>

    </xpath>

</template>

3) in css:-

.website_invisible {

display: none;

}

This is another way you can do by code else you can also unpublish product from website/shop/products to hide particular product.

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

อวตาร
ละทิ้ง
ผู้เขียน

i think i found a way.. is it okay if i just add new field available_on_ecommerce and add api.constrains('available_on_ecommerce') and field website_published is change based on available_on_ecommerce value?

คำตอบที่ดีที่สุด

Hello Rehan
You can publish/unpublished products with toggle switch as shown in image below.
You can find this under website/shop/products.

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 19
5670
1
ก.พ. 25
1462
1
ม.ค. 24
2528
0
ม.ค. 23
2890
0
ก.พ. 22
2792