mirror of https://github.com/OCA/web.git
[ADD] Model based quick create config option.
parent
7b5930f2da
commit
ce7e3f621f
|
@ -1 +1,2 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
from . import models
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
'static/src/xml/base.xml',
|
'static/src/xml/base.xml',
|
||||||
],
|
],
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'data': ['views/view.xml'],
|
'data': [
|
||||||
|
'views/view.xml',
|
||||||
|
'views/model_view.xml',
|
||||||
|
],
|
||||||
"author": "0k.io,Odoo Community Association (OCA)",
|
"author": "0k.io,Odoo Community Association (OCA)",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# coding: utf-8
|
||||||
|
from . import model
|
|
@ -0,0 +1,9 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from openerp import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class IrModel(models.Model):
|
||||||
|
_inherit = 'ir.model'
|
||||||
|
|
||||||
|
disable_quick_create = fields.Boolean('Disable quick create')
|
|
@ -100,8 +100,19 @@ openerp.web_m2x_options = function (instance) {
|
||||||
|
|
||||||
var create_rights;
|
var create_rights;
|
||||||
if (!(self.options && (self.options.no_create || self.options.no_create_edit))) {
|
if (!(self.options && (self.options.no_create || self.options.no_create_edit))) {
|
||||||
create_rights = new instance.web.Model(this.field.relation).call(
|
// check quick create options
|
||||||
"check_access_rights", ["create", false]);
|
var target_model = this.field.relation
|
||||||
|
create_rights = new instance.web.Model('ir.model').
|
||||||
|
query(['disable_quick_create']).
|
||||||
|
filter([['model', '=', target_model]]).
|
||||||
|
first().
|
||||||
|
then(function(result){
|
||||||
|
if(result.disable_quick_create)
|
||||||
|
return $.when(false);
|
||||||
|
else
|
||||||
|
return new instance.web.Model(target_model).call(
|
||||||
|
"check_access_rights", ["create", false]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.when(search_result, create_rights).then(function (data, can_create) {
|
$.when(search_result, create_rights).then(function (data, can_create) {
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="view_model_form" model="ir.ui.view">
|
||||||
|
<field name="model">ir.model</field>
|
||||||
|
<field name="inherit_id" ref="base.view_model_form"></field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="osv_memory" position="after">
|
||||||
|
<field name="disable_quick_create"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue