OpenERP 7-在“记录笔记"中创建自动记录消息字段作为历史日志记录 [英] OpenERP 7 - Create auto log message in "Log a Note" field as history log record

查看:81
本文介绍了OpenERP 7-在“记录笔记"中创建自动记录消息字段作为历史日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在OpenERP 7中创建用于实验室测试目的的自定义模块.用户将需要在此处输入其实验室测试组件和结果.

I am now creating a customize module for a lab test purpose in OpenERP 7. The users will require to enter their lab test components and result here.

现在我有一个名为"Reason For Changes"的字段.我想知道该方法如何记录此内容的输入,作为记录便笺"消息,以通过mail.thread在底部显示?

Now i having a field which called "Reason For Changes". I would like to know the method how i can log the input of this content as a "log a note" message to display at the bottom through mail.thread?

该步骤将是:

  1. 更改原因(ROC)"为必填字段

  1. Reason For Changes (ROC) as a required field

我的其他字段中的任何更改都会调用我的onchange方法来清除ROC字段的内容.

Any changes in my others fields will calling my onchange method to clearing the content of ROC field.

如果用户更改了某些内容而未在ROC字段中输入文本,则单击保存",将弹出错误消息请输入更改原因".这将使用户无法保存它.

If the user changed something without enter a text to the ROC field, then click save, a error message "Please Enter Reason For Change" will pop up. This will disable the user from saving this.

如果用户进行了一些更改并向ROC字段输入文本,然后保存,则ROC字段内容将作为底部的消息(例如记录便笺")创建为参考和历史记录记录.

If the user changed something and enter a text to ROC field, then save, the ROC field content will create as a message at the bottom (such as "log a note") as a reference and history log record.

我的问题是我该如何实现第3步和第4步?非常感谢您的帮助

My question would be how could i achieve the step 3 and 4? Deeply appreciate for your help

推荐答案

有两种可能性,但是使用的模型必须继承email.thread!但是我想它是继承的,因为您写了一些关于chat不休消息的内容.

There are two possiblities, but the used model has to inherit email.thread! But i guess it is inheriting, because you wrote something about the chatter messages.:

  1. 使用Odoo(以前的OpenERP)自动跟踪系统.您只需要在字段定义上添加参数track_visibility,例如(新的然后是旧的API)

roc = fields.Char(string="Reason For Changes", track_visibility="on_change")

_columns = {
    roc: fields.char(string="Reason For Changes", track_visibility="on_change"),
}

  1. 发布有关您自己写的消息. email.thread附带了一些简单但有用的方法.其中之一是message_post().覆盖模型的write(),如下所示(新/旧API):
  1. Post a message on write by yourself. email.thread is coming with some simple yet useful methods. One of them is message_post(). Override the write() of the model, like the following (new/old API):

@api.multi
def write(self, vals):
    res = super(YourModel, self).write(vals)
    if 'roc' in vals:
        for your_model_record in self:
            your_model_record.message_post(vals.get('roc'))
    return res


def write(self, cr, uid, ids, vals, context=None):
    res = super(YourModel, self).write(vals)
    if 'roc' in vals:
        for your_model_record_id in ids:
        self.message_post(cr, uid, your_model_record_id, vals.get('roc')), context=context)
    return res

这篇关于OpenERP 7-在“记录笔记"中创建自动记录消息字段作为历史日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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