首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何模仿stock.picking.type看板观点的行为?

如何模仿stock.picking.type看板观点的行为?
EN

Stack Overflow用户
提问于 2017-12-18 14:01:44
回答 1查看 399关注 0票数 1

的目的

我正在尝试开发一个类似于您可能使用的菜单项目(如果您安装了stock模块)。如果您转到仓库>操作>所有操作,您将看到一个漂亮的stock.picking.type模型的kanban视图和可用的选择类型。如果单击任何拾取类型框的“所有操作”链接,您将被重定向到stock.picking树视图。嗯,这是我唯一需要的东西,但是,我希望链接可以将您重定向到我的自定义stock.move树。

因此,我已经创建了我的菜单项,以及我自己的stock.picking.type kanban视图,它将重定向到我的自定义stock.move树视图。

我的代码

我的看板视图

代码语言:javascript
运行
复制
<record id="stock_picking_type_2_move_kanban" model="ir.ui.view">
    <field name="name">stock.picking.type.2.move.kanban</field>
    <field name="model">stock.picking.type</field>
    <field name="priority" eval="20"/>
    <field name="arch" type="xml">
        <kanban class="oe_background_grey" create="0">
            <field name="complete_name"/>
            <field name="color"/>
            <templates>
                <t t-name="kanban-box">
                    <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_stock_picking_type">
                        <div class="oe_kanban_content">
                            <h4 class="text-center"><strong><field name="complete_name"/></strong></h4>
                            <div class="oe_items_list oe_kanban_ellipsis">
                                <div>
                                    <a name="%(action_in_alt_move_views)d" type="action">Open moves</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </t>
            </templates>
        </kanban>
    </field>
</record>

打开kanban的操作(以及的默认形式)

代码语言:javascript
运行
复制
<record id="action_in_alt_picking_type_views" model="ir.actions.act_window">
    <field name="name">Picking types</field>
    <field name="res_model">stock.picking.type</field>
    <field name="type">ir.actions.act_window</field>
    <field name="view_type">form</field>
    <field name="view_mode">kanban,form</field>
    <field name="search_view_id" ref="stock.view_pickingtype_filter"/>
    <field name="help" type="html">
        <p class="oe_view_nocontent_create">
        Click to create a new picking type. 
        </p><p>
        The picking type system allows you to assign each stock
        operation a specific type which will alter its views accordingly.  
        On the picking type you could e.g. specify if packing is needed by default, 
        if it should show the customer.  
        </p>
    </field>
</record>

<record id="action_in_alt_picking_type_kanban" model="ir.actions.act_window.view">
    <field name="view_mode">kanban</field>
    <field name="view_id" ref="poc_alternative_stock.stock_picking_type_2_move_kanban"/>
    <field name="act_window_id" ref="action_in_alt_picking_type_views"/>
</record>

<record id="action_in_alt_picking_type_form" model="ir.actions.act_window.view">
    <field name="view_mode">form</field>
    <field name="view_id" ref="stock.view_picking_type_form"/>
    <field name="act_window_id" ref="action_in_alt_picking_type_views"/>
</record>

我的菜单项目

代码语言:javascript
运行
复制
<menuitem action="action_in_alt_picking_type_views"
    id="menu_action_in_alt_move_views"
    parent="stock.menu_stock_warehouse_mgmt" sequence="4"/>

THE BEHAVIOUR

当我点击我的菜单项目时,我得到了不同的错误,大多数错误告诉我,这个领域问题是,所有这些字段都属于我为stock.move模型创建的搜索视图。我不知道为什么在我的stock.picking.type操作中加载这个搜索视图,所以Odoo试图用stock.move的搜索视图显示我的kanban视图。这就是错误的原因。如果我注释搜索视图的每个字段,就会得到以下错误:

代码语言:javascript
运行
复制
raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))
ValueError: Invalid field 'state' in leaf "<osv.ExtendedLeaf: ('state', '=', 'draft') on stock_picking_type (ctx: )>"

这是我的stock.move搜索视图的第一个过滤器的域。

为什么Odoo试图加载搜索视图?(如果您看到我的操作代码,我甚至添加了参数search_view_id,尝试加载stock.picking.type的默认搜索视图,而不是stock.move 1)。

还有一件更令人惊讶的事情,那就是如果我修改我的stock.picking.type看板视图的优先级并编写16,它将比原来的优先级(在stock模型中声明)有更多的优先级,所以现在如果再次单击仓库>操作>所有操作,我的kanban视图就会被加载。但是,嘿,这里正确地加载了,它工作得很完美,正如我想要的那样,kanban视图是OK的,它的搜索视图也是,链接重定向到我想要的stock.move视图.

有人能解释一下这里发生了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2017-12-19 09:31:06

从代码的外观来看,您没有任何域('state', '=', 'draft'),我假设当您在您的操作代码中第一次使用您的代码时,会有一个。当你有错误的时候你就把它删除了。而在XML中,删除代码将不会更新数据库中的数据。

代码语言:javascript
运行
复制
  <!-- you must tell Odoo empty the field first and next time 
       remove the code(in production) when odoo load some thing to database
       like context, domain, any other value clear it first then remove
       the code -->
  <fied name="domain">[] </field> 

当xml中出现错误时,请记住在从数据库中清除之前删除了哪些代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47870094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档