I Have a requirement to remove the Duplicate button from more button in form view in openertest.pngp 7.0 based on user groups how to achieve this scenario
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
I've searching around many sites I can't find the solution, I guess is not possible for now remove/hide the Duplicate link option.
Looking at the code around the line as @pradeep shows, if the user has no permission to create record, the Duplicate link option into menu More will not show.
Seems to be the only possibility to hide the Duplicate link, but in my module the user can create the record but not duplicate.
So, overriding the copy method for Model seems to works better for me. I just show a warning message call "raise osv.excert_osv" for user knows he cannot duplicate records and OpenERP, rollback possible changes.
Follow my snippet code:
from openerp.osv import osv
from openerp.tools.translate import _
def copy(self, cr, uid, id, default=None, context=None):
raise osv.except_osv(_('Forbbiden to duplicate'), _('Is not possible to duplicate the record, please create a new one.'))
Maybe will works for you too.
yes this solution is working
Thanks, also this working for me :D
From https://github.com/menecio/oerp-addons, you can find web_hide_duplicate
while installing web_hide_duplicate in Openerp 7 i got an error Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1132, in call_button action = self._call_kw(req, model, method, args, {}) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(*args, **kwargs) File "/opt/openerp/server/openerp/addons/web/session.py", line 42, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/opt/openerp/server/openerp/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/opt/openerp/server/openerp/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/server/openerp/addons/base/module/module.py", line 424, in button_immediate_install return self._button_immediate_function(cr, uid, ids, self.button_install, context=context) File "/opt/openerp/server/openerp/addons/base/module/module.py", line 475, in _button_immediate_function _, pool = pooler.restart_pool(cr.dbname, update_module=True) File "/opt/openerp/server/openerp/pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/registry.py", line 233, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 354, in load_modules loaded_modules, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/opt/openerp/server/openerp/modules/loading.py", line 188, in load_module_graph load_data(module_name, idref, mode) File "/opt/openerp/server/openerp/modules/loading.py", line 76, in load_data = lambda *args: _load_data(cr, *args, kind='data') File "/opt/openerp/server/openerp/modules/loading.py", line 124, in _load_data tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report) File "/opt/openerp/server/openerp/tools/convert.py", line 945, in convert_xml_import relaxng.assert_(doc) File "lxml.etree.pyx", line 3027, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:129517) AssertionError: Did not expect element template there, line 4 Please help Me Omal Bastin Thanks
You can as well add a css rule to hide the button. I would create a css file in a custom module. Create the following xml to add the css to the backend.
<template id=assets_backend" name="hide_duplicate assets" inherit_id="web.assets_backend"> <xpath expr="." position="inside"> <link rel="stylesheet" href="/hide_duplicate/static/src/css/hide.css"/> </xpath> </template>
Then add this to hide.css
[data-index="3"] { display:none; }
I think if the user doesn't have write access on the object the Duplicate will not appear. Does your user have write access ?
yes the user have write access, but when we click on duplicate it will create new record rite.
The rights permission to Duplicate don't show is create access not write access. Write access controls if user can edit the record or something like that.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Aug 22
|
1268 | ||
|
3
Jan 24
|
13212 | ||
|
2
Feb 24
|
11069 | ||
|
1
Nov 22
|
2739 | ||
|
1
Oct 15
|
9722 |