问题描述
有什么方法可以在OpenERP中获取已删除记录的列表?我听说openerp记录了已删除的记录列表..但是我不知道在哪里浏览..
Is there any way to get the list of deleted records in OpenERP? I have heard that openerp records the deleted record list.. but i don't know where to browse for it..
我正在尝试同步两个数据库.因此,我几乎不需要删除记录的型号名称和ID,以便可以从其他数据库中删除相应的记录
I'm trying to synchronize two databases. So I hardly require the deleted record's model name and id so that i can delete the corresponding record from the other database
推荐答案
您可以基于 base_action_rule 模型制作类似 replication_automated_rule 的内容.在 addons/base_action_rule/base_action_rule.py 中查找代码.
You can make something like a replication_automated_rule based on the base_action_rule model. Look for the code at addons/base_action_rule/base_action_rule.py.
操作规则将服务器操作链接到完成给定条件(由过滤器定义)的对象(给定模型).即使在管理界面上,操作规则也非常易于使用.
An action rule links server actions to objects (of a given model) that accomplish a given condition (defined by filters). Action rules are very easy to use, even on the administrative interface.
在 creation 和 update 上检查对象,但是您可以从 base_action_rule 继承并定义 delete 上的检查>也.它的工作方式是为 create 和 write 方法创建自定义包装,以指示模型对象在其上起作用的内存表示形式.您需要基于 _wrap_create 添加 _wrap_unlink 方法,并在 _register_hook 中添加一行:
The objects are checked on creation and update but you can inherit from base_action_rule and define the check on delete also. It works by mean of creating custom wrappers to the create and write methods for the memory representation of the model object over it is told to work. You would need to add an _wrap_unlink method based on _wrap_create and adds a line to _register_hook:
model_obj.unlink = self._wrap_unlink(model_obj.unlink, model)
_wrap_create 和 _wrap_update 中的 wrapper 方法在执行其正常功能后执行挂钩.当您在 _wrap_unlink 中定义 wrapper 方法时,应该注意在取消链接正常功能之前执行钩子,因为取消链接会擦除对象,并且不会可用于钩子.
The wrapper method inside _wrap_create and _wrap_update execute the hooks after execute its normal function. When you define the wrapper method inside your _wrap_unlink, you should be care of executing the hooks before the normal function of unlink, given that unlink erase the object and it would not be available for the hooks.
此外,您还应该定义一个服务器操作,该操作将为复制队列或日志保存必要的数据.
Also, you should define an server action which saves the necessary data for your replication queue or log.
祝你好运!
这篇关于openerp中已删除记录的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!