odoo11为同一个mod在两个不同的区域添加不同的操作菜单

2024-04-18 15:04:51 发布

您现在位置:Python中文网/ 问答频道 /正文

在奥多11我想要两个不同的行动菜单和两个不同的功能。在

在人力资源工资单我想添加电子邮件工资单链接,这就是为什么我使用这个代码添加电子邮件工资单行动菜单

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

但这一个也在employees行中添加了action菜单。在员工行中,我想要一个不同的操作菜单。有人能告诉我怎么做到吗?在


Tags: nameodoorefidfielddatamodel电子邮件
1条回答
网友
1楼 · 发布于 2024-04-18 15:04:51

好吧,最后一次改变,我放弃了。我希望这正是你想要的。使用我在How to send an email from a button located in the action dropdown of an Odoo 11 form?中给出的答案的代码,只需将Python方法替换为以下方法:

@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变量)。在

我知道一开始很难,但正如@EasyOdoo评论的那样,你必须从答案中获得想法并对此进行调查,这样你就能提出更小、更准确的问题,并轻松获得良好的回答。在

相关问题 更多 >