在Odoo 10中,是否可以定义报告来列出标记为已确认但未通过电子邮件发送给供应商的采购订单?
即,如何检测采购订单中是否完成了“通过电子邮件发送PO”的行为。Odoo 10如何检查采购订单“通过电子邮件发送采购订单”是否已执行
感谢,
在Odoo 10中,是否可以定义报告来列出标记为已确认但未通过电子邮件发送给供应商的采购订单?
即,如何检测采购订单中是否完成了“通过电子邮件发送PO”的行为。Odoo 10如何检查采购订单“通过电子邮件发送采购订单”是否已执行
感谢,
你可以使用以下简单的方法。
步骤1:在中添加一个布尔字段采购订单型号并更新以下方法中的上下文。
from odoo import fields,models,api
class purchase_order(models.Model):
_inherit="purchase.order"
sent_po_via_email=fields.Boolean("Sent PO Via Email",default=False,copy=False)
@api.multi
def action_rfq_send(self):
'''
This function opens a window to compose an email, with the edi purchase template message loaded by default
'''
self.ensure_one()
ctx = dict(self.env.context or {})
ir_model_data = self.env['ir.model.data']
try:
if self.env.context.get('send_rfq', False):
template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase')[1]
else:
ctx.update({'sent_po_via_email':True})
template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase_done')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference('mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx.update({
'default_model': 'purchase.order',
'default_res_id': self.ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
})
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,
}
我们有覆盖action_rfq_send方法 &检查,如果用户不发送REF然后更新上下文ctx.update({ 'sent_po_via_email':真})。
第2步:继承mail.compose.message的send_mail方法。
class MailComposeMessage(models.TransientModel):
_inherit = 'mail.compose.message'
@api.multi
def send_mail(self, auto_commit=False):
context = self._context
if context.get('default_model') == 'purchase.order' and \
context.get('default_res_id') and context.get('sent_po_via_email'):
po_order = self.env['purchase.order'].browse(context['default_res_id'])
po_order.sent_po_via_email = True
return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
在如果用户通过电子邮件发送采购为了我们检查了上述方法再设置对勾真。
我们已经使用简单的情况下,以确定基于背景过程 &,写在采购订单值。
这可能对你有帮助。
试试这个:
purchase.order' model and add a
布尔field`。True
到这个Boolean
字段。report.py
中,选择一个查询来获取记录,其中boolean_field =True and state ='purchase'
。希望这会对你有帮助。
非常感谢,我会尝试并确认回答 –
谢谢,它完美的作品。容易和非侵入性。剩下的一个问题是,我找不到如何翻译“通过电子邮件发送PO”字段说明。当我用--i18n-export运行odoo时,生成的.po缺少那个msg。任何提示? –