Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Error in overwrting model method

By
Vitaliy
on 6/5/13, 5:53 AM 1,444 views

I'm trying to overwrite delete method with log information into the db:

def post_write(self, cr, uid, ids, action, model, context=None):
    if isinstance(ids, (int, long)):
      ids = [ids]
    queue = self.pool.get("hr.changes.queue")
    for id in ids:
        queue.create(self, cr, uid, {
            "action": action,
            "related_model": model,
            "affected_id": id
        })

def unlink(self, cr, uid, ids, context=None):
    self.post_write(self, cr, uid, ids, "delete", "hr.employee")
    return super(hr_employee, self).unlink(cr, uid, ids)

but I have this error: "'hr.employee' object has no attribute 'execute'"

At least you don't pass context in your method unlink. Probably won't fix it, but it is better to do it. In your code, there is no execute, Can you post the complete stacktrace, it will probably tell you something more.

patrick
on 6/5/13, 5:45 PM
3

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/5/13, 6:18 AM

Hi,

Another way to follow users operations see module Audit Trail audittrail exists in the apps openerp.

This module lets administrator track every user operation on all the objects of the system.

The administrator can subscribe to rules for read, write and delete on objects and can check logs.

installl this module and in menu Reporting>>Audit Rules define the objects to be tracked . For example partner:

image description

No, its not all the task and installing this module is not solution.

Vitaliy
on 6/5/13, 6:47 AM

Yes, you can track one operation 'delete' for one object 'hr.employee' and not all task for all objects.

Borni DHIFI
on 6/5/13, 6:56 AM

I think installing the whole module is not the best solution if I can do it by overwriting the only method.

Vitaliy
on 6/5/13, 7:04 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/5/13, 5:53 AM
Seen: 1444 times
Last updated: 3/16/15, 8:10 AM