Odoo 11在同一模型的两个不同区域中添加了不同的操作菜单 [英] Odoo 11 add different action menu in two different area for the same model

查看:209
本文介绍了Odoo 11在同一模型的两个不同区域中添加了不同的操作菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Odoo 11中,我想要具有两个不同功能的两个不同的动作菜单.

In Odoo 11 I want two different action menu with two different functionality.

在小时工资单中,我想添加电子邮件工资单链接,这就是为什么我使用此代码添加电子邮件工资单操作菜单

In the hr payroll I wanted to add email payslip link thats why I used this code to add the email payslip action menu

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="action_email_payslip" model="ir.actions.server">
      <field name="name">Email Payslip</field>
            <field name="model_id" ref="hr_payroll.model_hr_payslip"/> 
            <field name="binding_model_id" ref="hr_payroll.model_hr_payslip"/>
            <field name="state">code</field> 
            <field name="code"> 
            action = records.action_email_payslip_send() 
            </field>
    </record>
    </data>
</odoo>

但是,这也是在雇员行中添加了操作菜单.在员工行中,我想要一个不同的操作菜单.那么有人可以告诉我如何实现吗?

But this one is adding the action menu in the employees row as well. In the employee rows I want a different action menu. So can some one tell me how to achieve that?

推荐答案

好,最后一次更改,我放弃了.我希望这正是您想要的.使用我在

Ok, last change and I give up. I hope this is exactly what you want. Using the code of the answer I gave you in How to send an email from a button located in the action dropdown of an Odoo 11 form?, just replace the Python method by this one:

@api.multi
def action_email_payslip_send(self):
    template = self.env.ref(
        'your_module_name.email_template_payslip',
        False,
    )
    compose_form = self.env.ref(
        'mail.email_compose_message_wizard_form',
        False,
    )
    ctx = dict(
        default_model='hr.payslip',
        default_use_template=bool(template),
        default_template_id=template and template.id or False,
    )
    if len(self) == 1:
        ctx.update({
            'default_composition_mode': 'comment',
            'default_res_id': self.ensure_one().id,
        })
    else:
        ctx.update({
            'default_composition_mode': 'mass_mail',
            'active_ids': self.ids,
        })
    return {
        'name': _('Compose Email'),
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'mail.compose.message',
        'views': [(compose_form.id, 'form')],
        'view_id': compose_form.id,
        'target': 'new',
        'context': ctx,
    }

即使您选择多个工资单,这也会打开您喜欢的电子邮件撰写消息弹出窗口(在这种情况下,预览不会替换Mako变量).

This will open you the email compose message pop-up you like even when you are selecting several payslips (in this case the preview will not replace the Mako variables).

我知道一开始很困难,但是正如@EasyOdoo所评论的那样,您必须从答案中获取想法并对它进行调查,这样您就可以提出更小,更准确的问题并轻松获得良好的答复.

I know it is difficult at the beginning, but as @EasyOdoo commented, you have to get ideas from the answers and investigate about it, that way you will be able to make smaller and more accurate questions and get good responses easily.

这篇关于Odoo 11在同一模型的两个不同区域中添加了不同的操作菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆