Browse Source

[FIX][8.0] base_custom_info: Minor fix and security

pull/313/head
Carlos Incaser 9 years ago
committed by Jairo Llopis
parent
commit
a694cfac0a
  1. 6
      base_custom_info/__openerp__.py
  2. 2
      base_custom_info/models/__init__.py
  3. 18
      base_custom_info/models/custom_info.py
  4. 7
      base_custom_info/security/ir.model.access.csv
  5. 43
      base_custom_info/views/custom_info_template_line_view.xml
  6. 76
      base_custom_info/views/custom_info_template_view.xml
  7. 27
      base_custom_info/views/custom_info_value_view.xml
  8. 22
      base_custom_info/views/menu.xml

6
base_custom_info/__openerp__.py

@ -12,7 +12,11 @@
'base', 'base',
], ],
'data': [ '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., ' 'author': 'Antiun Ingeniería S.L., '
'Incaser Informatica S.L., ', 'Incaser Informatica S.L., ',

2
base_custom_info/models/__init__.py

@ -3,4 +3,4 @@
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden # (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import custom_info_template
from . import custom_info

18
base_custom_info/models/custom_info_template.py → base_custom_info/models/custom_info.py

@ -8,6 +8,7 @@ from openerp import api, fields, models, _
class CustomInfoTemplate(models.Model): class CustomInfoTemplate(models.Model):
_name = "custom.info.template" _name = "custom.info.template"
_description = "Template of properties"
name = fields.Char() name = fields.Char()
model_id = fields.Many2one(comodel_name='ir.model', string='Data Model') model_id = fields.Many2one(comodel_name='ir.model', string='Data Model')
@ -19,6 +20,7 @@ class CustomInfoTemplate(models.Model):
class CustomInfoTemplateLine(models.Model): class CustomInfoTemplateLine(models.Model):
_name = "custom.info.template.line" _name = "custom.info.template.line"
_description = "Properties"
name = fields.Char() name = fields.Char()
template_id = fields.Many2one( template_id = fields.Many2one(
@ -32,18 +34,22 @@ class CustomInfoTemplateLine(models.Model):
class CustomInfoValue(models.Model): class CustomInfoValue(models.Model):
_name = "custom.info.value" _name = "custom.info.value"
_description = "Values of properties"
_rec_name = 'value' _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( custom_info_name_id = fields.Many2one(
comodel_name='custom.info.template.line', comodel_name='custom.info.template.line',
required=True,
string='Property Name') string='Property Name')
name = fields.Char(related='custom_info_name_id.name')
value = fields.Char() value = fields.Char()
class CustomInfo(models.AbstractModel): class CustomInfo(models.AbstractModel):
_name = "custom.info" _name = "custom.info"
_description = "Abstract model from inherit to add info in any model"
custom_info_template_id = fields.Many2one( custom_info_template_id = fields.Many2one(
comodel_name='custom.info.template', comodel_name='custom.info.template',
@ -67,3 +73,11 @@ class CustomInfo(models.AbstractModel):
'model': self._name, 'model': self._name,
'custom_info_name_id': info_name.id, '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

7
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

43
base_custom_info/views/custom_info_template_line_view.xml

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="base_custom_info_template_line_tree" model="ir.ui.view">
<field name="name">base.custom.info.template.line.tree</field>
<field name="model">custom.info.template.line</field>
<field name="arch" type="xml">
<tree string="Custom Info Templates">
<field name="name"/>
<field name="template_id"/>
</tree>
</field>
</record>
<record id="base_custom_info_template_line_form" model="ir.ui.view">
<field name="name">base.custom.info.template.line.form</field>
<field name="model">custom.info.template.line</field>
<field name="arch" type="xml">
<form string="Custom Info Template Lines">
<sheet>
<group>
<field name="name"/>
<field name="template_id"/>
</group>
<group>
<field name="info_value_ids"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="custom_info_template_line_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.info.template.line</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
</data>
</openerp>

76
base_custom_info/views/custom_info_template_view.xml

@ -2,8 +2,6 @@
<openerp> <openerp>
<data> <data>
<!--base.custom.info.template-->
<record id="base_custom_info_template_tree" model="ir.ui.view"> <record id="base_custom_info_template_tree" model="ir.ui.view">
<field name="name">base.custom.info.template.tree</field> <field name="name">base.custom.info.template.tree</field>
<field name="model">custom.info.template</field> <field name="model">custom.info.template</field>
@ -56,79 +54,5 @@
</field> </field>
</record> </record>
<menuitem id="menu_base_custom_info" name="Custom Info"
parent="base.menu_administration" sequence="45"/>
<menuitem id="menu_base_custom_info_template" action="custom_info_template_action"
parent="menu_base_custom_info" sequence="5"/>
<!--base.custom.info.template.line-->
<record id="base_custom_info_template_line_tree" model="ir.ui.view">
<field name="name">base.custom.info.template.line.tree</field>
<field name="model">custom.info.template.line</field>
<field name="arch" type="xml">
<tree string="Custom Info Templates">
<field name="name"/>
<field name="template_id"/>
</tree>
</field>
</record>
<record id="base_custom_info_template_line_form" model="ir.ui.view">
<field name="name">base.custom.info.template.line.form</field>
<field name="model">custom.info.template.line</field>
<field name="arch" type="xml">
<form string="Custom Info Template Lines">
<sheet>
<group>
<field name="name"/>
<field name="template_id"/>
</group>
<group>
<field name="info_value_ids"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="custom_info_template_line_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.info.template.line</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
<menuitem id="menu_base_custom_info_template_line" action="custom_info_template_line_action"
parent="menu_base_custom_info" sequence="10"/>
<!--base.custom.info.value-->
<record id="base_custom_info_value_tree" model="ir.ui.view">
<field name="name">base.custom.info.value.tree</field>
<field name="model">custom.info.value</field>
<field name="arch" type="xml">
<tree string="Custom Info Values">
<field name="custom_info_name_id"/>
<field name="value"/>
<field name="model"/>
<field name="res_id"/>
</tree>
</field>
</record>
<record id="custom_info_value_action" model="ir.actions.act_window">
<field name="name">Values</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.info.value</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
<menuitem id="menu_base_custom_info_value" action="custom_info_value_action"
parent="menu_base_custom_info" sequence="15"/>
</data> </data>
</openerp> </openerp>

27
base_custom_info/views/custom_info_value_view.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="base_custom_info_value_tree" model="ir.ui.view">
<field name="name">base.custom.info.value.tree</field>
<field name="model">custom.info.value</field>
<field name="arch" type="xml">
<tree string="Custom Info Values">
<field name="custom_info_name_id"/>
<field name="value"/>
<field name="model"/>
<field name="res_id"/>
</tree>
</field>
</record>
<record id="custom_info_value_action" model="ir.actions.act_window">
<field name="name">Values</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.info.value</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
</data>
</openerp>

22
base_custom_info/views/menu.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--Parent Custom Info in Settings-->
<menuitem id="menu_base_custom_info" name="Custom Info"
parent="base.menu_administration" sequence="45"/>
<!--base.custom.info.template-->
<menuitem id="menu_base_custom_info_template" action="custom_info_template_action"
parent="menu_base_custom_info" sequence="5"/>
<!--base.custom.info.template.line-->
<menuitem id="menu_base_custom_info_template_line" action="custom_info_template_line_action"
parent="menu_base_custom_info" sequence="10"/>
<!--base.custom.info.value-->
<menuitem id="menu_base_custom_info_value" action="custom_info_value_action"
parent="menu_base_custom_info" sequence="15"/>
</data>
</openerp>
Loading…
Cancel
Save