diff --git a/base_custom_info/__openerp__.py b/base_custom_info/__openerp__.py index 7bcc581bf..9b4521191 100644 --- a/base_custom_info/__openerp__.py +++ b/base_custom_info/__openerp__.py @@ -12,7 +12,11 @@ 'base', ], 'data': [ - 'views/custom_info_template_view.xml' + 'views/custom_info_template_view.xml', + 'views/custom_info_template_line_view.xml', + 'views/custom_info_value_view.xml', + 'views/menu.xml', + 'security/ir.model.access.csv', ], 'author': 'Antiun IngenierĂ­a S.L., ' 'Incaser Informatica S.L., ', diff --git a/base_custom_info/models/__init__.py b/base_custom_info/models/__init__.py index f523517ad..c7f3fd66c 100644 --- a/base_custom_info/models/__init__.py +++ b/base_custom_info/models/__init__.py @@ -3,4 +3,4 @@ # (c) 2015 Antiun IngenierĂ­a S.L. - Carlos Dauden # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from . import custom_info_template +from . import custom_info diff --git a/base_custom_info/models/custom_info_template.py b/base_custom_info/models/custom_info.py similarity index 78% rename from base_custom_info/models/custom_info_template.py rename to base_custom_info/models/custom_info.py index 505166abb..3001ae6bd 100644 --- a/base_custom_info/models/custom_info_template.py +++ b/base_custom_info/models/custom_info.py @@ -8,6 +8,7 @@ from openerp import api, fields, models, _ class CustomInfoTemplate(models.Model): _name = "custom.info.template" + _description = "Template of properties" name = fields.Char() model_id = fields.Many2one(comodel_name='ir.model', string='Data Model') @@ -19,6 +20,7 @@ class CustomInfoTemplate(models.Model): class CustomInfoTemplateLine(models.Model): _name = "custom.info.template.line" + _description = "Properties" name = fields.Char() template_id = fields.Many2one( @@ -32,18 +34,22 @@ class CustomInfoTemplateLine(models.Model): class CustomInfoValue(models.Model): _name = "custom.info.value" + _description = "Values of properties" _rec_name = 'value' - model = fields.Char(select=True) - res_id = fields.Integer(select=True) + model = fields.Char(index=True, required=True) + res_id = fields.Integer(index=True, required=True) custom_info_name_id = fields.Many2one( comodel_name='custom.info.template.line', + required=True, string='Property Name') + name = fields.Char(related='custom_info_name_id.name') value = fields.Char() class CustomInfo(models.AbstractModel): _name = "custom.info" + _description = "Abstract model from inherit to add info in any model" custom_info_template_id = fields.Many2one( comodel_name='custom.info.template', @@ -67,3 +73,11 @@ class CustomInfo(models.AbstractModel): 'model': self._name, 'custom_info_name_id': info_name.id, }) + + @api.multi + def unlink(self): + info_values = self.mapped('custom_info_ids') + res = super(CustomInfo, self).unlink() + if res: + info_values.unlink() + return res diff --git a/base_custom_info/security/ir.model.access.csv b/base_custom_info/security/ir.model.access.csv new file mode 100644 index 000000000..388445929 --- /dev/null +++ b/base_custom_info/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_custom_info_template_user,custom.info.template.user,model_custom_info_template,base.group_user,1,0,0,0 +access_custom_info_template_line_user,custom.info.template.line.user,model_custom_info_template_line,base.group_user,1,0,0,0 +access_custom_info_value_user,custom.info.value.user,model_custom_info_value,base.group_user,1,0,0,0 +access_custom_info_template_sale_manager,custom.info.template.salemanager,model_custom_info_template,base.group_sale_manager,1,1,1,1 +access_custom_info_template_line_sale_manager,custom.info.template.line.salemanager,model_custom_info_template_line,base.group_sale_manager,1,1,1,1 +access_custom_info_value_sale_manager,custom.info.value.salemanager,model_custom_info_value,base.group_sale_manager,1,1,1,1 diff --git a/base_custom_info/views/custom_info_template_line_view.xml b/base_custom_info/views/custom_info_template_line_view.xml new file mode 100644 index 000000000..d682499fe --- /dev/null +++ b/base_custom_info/views/custom_info_template_line_view.xml @@ -0,0 +1,43 @@ + + + + + + base.custom.info.template.line.tree + custom.info.template.line + + + + + + + + + + base.custom.info.template.line.form + custom.info.template.line + +
+ + + + + + + + + +
+
+
+ + + Properties + ir.actions.act_window + custom.info.template.line + tree,form + form + + +
+
diff --git a/base_custom_info/views/custom_info_template_view.xml b/base_custom_info/views/custom_info_template_view.xml index e432e5336..60f4e8e40 100644 --- a/base_custom_info/views/custom_info_template_view.xml +++ b/base_custom_info/views/custom_info_template_view.xml @@ -2,8 +2,6 @@ - - base.custom.info.template.tree custom.info.template @@ -56,79 +54,5 @@ - - - - - - - - base.custom.info.template.line.tree - custom.info.template.line - - - - - - - - - - base.custom.info.template.line.form - custom.info.template.line - -
- - - - - - - - - -
-
-
- - - Properties - ir.actions.act_window - custom.info.template.line - tree,form - form - - - - - - - - base.custom.info.value.tree - custom.info.value - - - - - - - - - - - - Values - ir.actions.act_window - custom.info.value - tree,form - form - - - -
diff --git a/base_custom_info/views/custom_info_value_view.xml b/base_custom_info/views/custom_info_value_view.xml new file mode 100644 index 000000000..5a08a9c5d --- /dev/null +++ b/base_custom_info/views/custom_info_value_view.xml @@ -0,0 +1,27 @@ + + + + + + base.custom.info.value.tree + custom.info.value + + + + + + + + + + + + Values + ir.actions.act_window + custom.info.value + tree,form + form + + + + diff --git a/base_custom_info/views/menu.xml b/base_custom_info/views/menu.xml new file mode 100644 index 000000000..d23ef5fc8 --- /dev/null +++ b/base_custom_info/views/menu.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + +