Odoo Help

1

What controls existence of Duplicate function in OpenERP7?

By
mike
on 8/27/13, 1:41 PM 2,243 views

I have created a custom module that defines several new models. Some of my custom models should not be duplicated and others should... Of all these models the More drop-down displays the Duplicate option for all the custom models except for two of them. Why not those two? They happen to be the ones I want to be able to duplicate and not any of the others...

What ORM logic determines whether or not a model can be copied and how can I override it?

As a test I decided to "force" a copy operation as follows:

{
   "jsonrpc":"2.0",
   "method":"call",
   "params":{
      "model":"dbe.application",
      "method":"copy",
      "args":[
         32,
         {

         },
         {
            "lang":"en_US",
            "tz":"America/New_York",
            "uid":1
         }
      ],
      "kwargs":{

      },
      "session_id":"3ebb612049fe4e49a760429632d865ae",
      "context":{
         "lang":"en_US",
         "tz":"America/New_York",
         "uid":1
      }
   },
   "id":"r7"
}

This test resulted in a success message and a copy of the original record. I even had an override of the copy method in this model which changes the value of the state field and that also worked. Yet OpenERP still refuses to display Duplicate in the More drop-down. I have searched through the largely undocumented javascript for the UI and found where the bottun is defined as well as it's callback, on_button_duplicate, but nothing useful here to shed light on my problem. Also of interest, looking through old screengrabs from Q/A testers I see that Duplicate used to be available but has mysteriously gone away since then. Reviewing changes to the models since then shows only very minor tweaks to their code - mainly help text on fields. So if Duplicate was there where has it gone and why? Could this have to do with permissions?

0
mike
On 8/28/13, 1:19 PM

The cause of this problem eludes me. And I do not have time to spend fixing OpenERP. So to answer my own question - override CSS class with module style sheet to remove Duplicate from the menu within the scope of my module so it is not an option for models that should not be duplicated. Then modify the the views for the models I do want to be able to copy (2) with a new button for calling the copy method. Found this helpful related question for inspiration: How to create a Duplicate button. As it is Duplicate appears on all the model that should not be duplicated and not on the models that must be duplicated. Yes this solution is ugly but is faster and less painful than trying to troubleshoot and fix OpenERP. Some available add-on modules (stock, product) do very similar things so the precedent exists.

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 8/27/13, 1:41 PM
Seen: 2243 times
Last updated: 3/16/15, 8:10 AM