【问题标题】:How to display kanban style tile in form view?如何在表单视图中显示看板样式图块?
【发布时间】:2020-04-14 20:59:23
【问题描述】:

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

这是我目前的看法: 这就是我想要的视图: 这是我当前的代码:

    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】:

    马苏德阿扎尔

    在此字段product_image_360_ids 上使用kanban 视图而不是tree 视图,并根据您的设计格式化看板视图,它将适合您。

    <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>
    

    谢谢

    【讨论】:

    • 它有效,但它产生了一些问题。 1. 现在,当我创建记录时,它会在视图上显示我的 many2one 字段: product_tmpl_id = fields 。 Many2one ( 'product.template' , string = 'Related Product' , copy = True ) 我试图通过 python 中的属性 invisible = true 使其不可见。此外,该字段不在我的视图中,因此我在视图中明确包含该字段并在 XML 中尝试了 invisible = true ,但它也不起作用,并且关系字段在创建记录时可见。
    • 2.另一个是当我选择图像时,选择后图像不显示,但仅在我保存记录后才显示(在树视图中不是这种情况)
    • 3.没有办法删除看板,如果我错误地保存了一条记录,就无法删除它(就像它在操作中或任何其他选项中显示的那样)
    • 通过以下方式解决了删除问题:。 . . X
    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多