如何在表单视图中显示看板样式图块?

问题描述 投票:0回答:1

我有一个one2many图像字段,当前以表格形式显示图像。我想做的就是以看板卡之类的卡片样式显示它。

这是我当前的视图:Current view这就是我想要的视图:Current view这是我当前的代码:

    class VariantsLines(models.Model):
    _inherit = 'product.variants.lines'

    product_image_360_ids = fields.One2many('product.image.360', 'product_tmpl_id', string='Images')
    display_360_image = fields.Boolean(string='Display 360 Image')


class ProductImage360(models.Model):
    _name = 'product.image.360'
    _order = 'sequence'

    name = fields.Char(string='Name', readonly=False)
    image = fields.Binary(string='Image', attachment=True, readonly=False)
    product_tmpl_id = fields.Many2one('product.template', string='Related Product', copy=True)
    sequence = fields.Integer(string="Sequence", readonly=False)

view.xml

    <field name="inherit_id" ref="jewellery.view_product_variants_lines_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form" position="inside">
                    <div>
                        <group>
                            <field name="display_360_image"/>
                        </group>

                        <group string="Images for 360 view" attrs="{'invisible': [('display_360_image', '=', False)]}">
                            <field name="product_image_360_ids" nolabel="1"
                                   context="{'default_product_tmpl_id': active_id}">
                                <tree create="true" editable="bottom">
                                    <field name="sequence" widget="handle" readonly="0"/>
                                    <field name="name" readonly="0"/>
                                    <field name="image" widget="image" class="oe_left oe_avatar" readonly="0"/>
                                </tree>
                            </field>
                        </group>
                    </div>
                </xpath>
            </field>
python odoo odoo-11 odoo-12
1个回答
0
投票

Masood Azhar

在此字段kanban上使用tree视图而不是product_image_360_ids视图,并根据您的设计设置看板视图的格式,这将对您有用。

<field name="product_image_360_ids" nolabel="1" context="{'default_product_tmpl_id': active_id}">
    <kanban class="o_kanban_mobile">
        <!-- Design your customise template here -->
    </kanban>
</field>

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.