【问题标题】:Odoo 9 where can I find action button dropdown in stock.move xml?Odoo 9 在哪里可以找到 stock.move xml 中的操作按钮下拉菜单?
【发布时间】:2016-06-01 06:02:33
【问题描述】:

我想用addingdeleting 更改action 按钮下拉菜单stock.move class 中的子菜单(或更改导出功能),但我在xml 中找不到描述按钮@ 的位置987654329@ 与 "export""delete" 下拉菜单。据我了解,它必须记录 model="ir.actions.act_window"tree 视图。

我说的是这个菜单:


(来源:part.lt

我有这些来自核心 stock 插件的 xml:

<record id="act_product_stock_move_open" model="ir.actions.act_window">
        <field name="context">{'search_default_product_id': active_id, 'default_product_id': active_id}</field>
        <field name="name">Moves</field>
        <field name="res_model">stock.move</field>
        <field name="view_id" ref="stock.view_move_tree"/>
    </record>

    <record id="action_move_form2" model="ir.actions.act_window">
        <field name="name">Stock Moves</field>
        <field name="res_model">stock.move</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="view_move_tree"/>
        <field name="search_view_id" ref="view_move_search"/>
        <field name="context">{}</field>
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to create a stock movement.
          </p><p>
            This menu gives you the full traceability of inventory
            operations on a specific product. You can filter on the product
            to see all the past or future movements for the product.
          </p>
        </field>
    </record>

    <record model="ir.actions.act_window.view" id="action_stock_move_tree_all">
        <field name="sequence" eval="1"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_move_tree"/>
        <field name="act_window_id" ref="action_move_form2"/>
    </record>

    <record model="ir.actions.act_window.view" id="action_stock_move_form_all">
        <field name="sequence" eval="3"/>
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_move_form"/>
    <field name="act_window_id" ref="action_move_form2"/>
    </record>

<record model="ir.actions.act_window.view" id="action_stock_move_graph_all">
    <field name="sequence" eval="3"/>
    <field name="view_mode">graph</field>
    <field name="view_id" ref="view_move_graph"/>
    <field name="act_window_id" ref="action_move_form2"/>
</record>

也许我搜索的地方不对?

【问题讨论】:

    标签: xml treeview odoo odoo-9 odoo-view


    【解决方案1】:

    base.xml(在 addons/web/static/src/xml/base.xml) 有 FieldBinaryFileUploader 调用控制器 /web/binary/upload_attachment (在 addons/web/controllers/main.py)

    <t t-name="FieldBinaryFileUploader">
        <div t-att-style="widget.node.attrs.style" t-attf-class="oe_fileupload #{widget.node.attrs.class ? widget.node.attrs.class :''}">
            <div class="oe_placeholder_files"/>
            <div class="oe_add" t-if="!widget.get('effective_readonly')">
                <!-- uploader of file -->
                <button class="oe_attach"><i class="fa fa-paperclip"/></button>
                <span class='oe_attach_label'><t t-esc="widget.string"/></span>
                <t t-call="HiddenInputFile">
                    <t t-set="fileupload_id" t-value="widget.fileupload_id"/>
                    <t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t>
                    <input type="hidden" name="model" t-att-value="widget.view.model"/>
                    <input type="hidden" name="id" value="0"/>
                    <input type="hidden" name="session_id" t-att-value="widget.session.session_id" t-if="widget.session.override_session"/>
                </t>
            </div>
        </div>
    </t>
    

    已编辑:用于在选项中添加新值

    在xml中创建model="ir.values"的记录并将stock.move放入&lt;field name="model"&gt;并创建动作

    &lt;record id="my_module.my_new_action_stock_move" model="ir.actions.server"&gt;

    &lt;record id="my_module.my_new_action_stock_move" model="ir.actions.act_window"&gt;

    用于处理动作的点击

    示例代码 ir.values 如下:

    <record model="ir.values" id="my_module.model_stock_move_values">
        <field name="model_id" ref="stock.model_stock_move" />
        <field name="name">My Options</field>
        <field name="key2">client_action_multi</field>
        <field name="value" eval="'ir.actions.act_window,'+str(ref('my_module.my_new_action_stock_move'))" />
        <field name="key">action</field>
        <field name="model">stock.move</field>
    </record>
    

    希望此参考资料有助于理解导出的工作原理。

    【讨论】:

    • 谢谢。因此,如果我想在 stock.move 类的“Action”下拉菜单中添加一个功能,那么我必须用 ir.actions.act_window 重写 stock.xml?
    • 我已更新我的答案已编辑:用于在选项中添加新值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-03
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    • 2012-03-01
    相关资源
    最近更新 更多