当前位置 : 主页 > 网页制作 > xml >

xml – 如何在“更多”菜单或顶部菜单中添加条目以在多个选项上添加操作?

来源:互联网 收集:自由互联 发布时间:2021-06-13
目标 我想从选择的订单行创建交货,但我无法显示按钮. 模 compose_delivery_order/├── delivery_order_button.py├── delivery_order_button.xml├── images/│ └── delivery_order_button.png├── __ini
目标

我想从选择的订单行创建交货,但我无法显示按钮.

compose_delivery_order/
├── delivery_order_button.py
├── delivery_order_button.xml
├── images/
│   └── delivery_order_button.png
├── __init__.py
├── __openerp__.py
├── order_to_invoice_create_delivery_button.py
├── order_to_invoice_create_delivery_button.xml ← I'm working on this
├── sale_order_button.py
└── sale_order_confirm_button.xml

XML< record>

<record id="action_sale_order_liquidar" model="ir.actions.server">
    <field name="name">Liquidar</field>
    <field name="type">ir.actions.server</field>
    <field name="model_id" ref="model_sale_order"/>
    <field name="state">code</field>
    <field name="code">self.some_custom_code(cr, uid, context.get('active_ids'), context=context)</field>
</record><record id="id_of_the_action_value" model="ir.values">
    <field name="name">Liquidar</field>
    <field name="action_id" ref="action_sale_order_liquidar"/>
    <field name="value" eval="'ir.actions.server,' + str(ref('action_sale_order_liquidar'))"/>
    <field name="key">action</field>
    <field name="model_id" ref="model_sale_order"/>
    <field name="model">sale.order</field>
    <field name="key2">client_action_multi</field>
</record>

Python

import logging
from openerp import netsvc
from openerp.osv import osv

logger = logging.getLogger(__name__)

class sale_order_line(osv.osv):
    _inherit = 'sale.order.line'

    def some_custom_code(self, db_cursor, user_id, ids, context=None):
        logger.error('+ + + + + + sale_order_line -> some_custom_code + + + + + + ')
        return True


def some_custom_code(self, db_cursor, user_id, ids, context=None):
    logger.error('+ + + + + + some_custom_code + + + + + + ')
    return True

如何添加按钮?可以是[更多v]的子菜单,也可以是[创建]或导入的子菜单.

N.B.:我检查它是在__openerp __.py的数据部分导入的.

在更多菜单上添加新菜单时,您需要注意以下事项.

>注册表单视图
>注册行动视图
>注册ir_values(从你想要显示菜单的位置)
>给出适当的相关view_id参考
>动作视图中的目标属性
>为记录标签提供相关名称

尝试使用以下代码(在.xml文件上添加代码):

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_create_delivery_button" model="ir.ui.view">
            <field name="name">Create Delivery</field>
            <field name="model">sale.order.line</field>
            <field name="arch" type="xml">
                <form string="Create Delivery" version="7.0">

                    <!-- Design Form or put your field here -->                
                    <footer>
                        <!-- Add button on footer of pop-up window -->
                    </footer>
               </form>
            </field>
        </record>

        <record id="action_create_delivery_button" model="ir.actions.act_window">
            <field name="name">Create Delivery</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_create_delivery_button"/>
            <field name="target">new</field>
            <field name="multi">True</field>
        </record>

        <record model="ir.values" id="ir_values_create_delivery_button">
            <field name="model_id" ref="sale.model_sale_order_line" />
            <field name="name">Create Delivery</field>
            <field name="key2">client_action_multi</field>
            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_create_delivery_button'))" />
            <field name="key">action</field>
            <field name="model">sale.order.line</field>
        </record>
    </data>
</openerp>
网友评论