Browse Source

[ADD][8.0] base_custom_info: Views

pull/435/head
Carlos Incaser 9 years ago
committed by Jairo Llopis
parent
commit
808c11bd15
  1. 17
      base_custom_info/models/custom_info_template.py
  2. 65
      base_custom_info/views/custom_info_template_view.xml

17
base_custom_info/models/custom_info_template.py

@ -10,9 +10,7 @@ class CustomInfoTemplate(models.Model):
_name = "custom.info.template" _name = "custom.info.template"
name = fields.Char() name = fields.Char()
model_id = fields.Many2one(
comodel_name='ir.model',
default=lambda self: self._name) #TODO:Fix integer
model_id = fields.Many2one(comodel_name='ir.model', string='Data Model')
info_ids = fields.One2many( info_ids = fields.One2many(
comodel_name='custom.info.template.line', comodel_name='custom.info.template.line',
inverse_name='template_id', inverse_name='template_id',
@ -24,7 +22,12 @@ class CustomInfoTemplateLine(models.Model):
name = fields.Char() name = fields.Char()
template_id = fields.Many2one( template_id = fields.Many2one(
comodel_name='custom.info.template')
comodel_name='custom.info.template',
string='Template')
info_value_ids = fields.One2many(
comodel_name="custom.info.value",
inverse_name="custom_info_name_id",
string="Info Values")
class CustomInfoValue(models.Model): class CustomInfoValue(models.Model):
@ -34,7 +37,8 @@ class CustomInfoValue(models.Model):
model = fields.Char(select=True) model = fields.Char(select=True)
res_id = fields.Integer(select=True) res_id = fields.Integer(select=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',
string='Info Name')
value = fields.Char() value = fields.Char()
@ -49,7 +53,7 @@ class CustomInfo(models.AbstractModel):
inverse_name='res_id', inverse_name='res_id',
domain=lambda self: [('model', '=', self._name)], domain=lambda self: [('model', '=', self._name)],
auto_join=True, auto_join=True,
string='Info')
string='Custom Info')
@api.onchange('custom_info_template_id') @api.onchange('custom_info_template_id')
def _onchange_custom_info_template_id(self): def _onchange_custom_info_template_id(self):
@ -61,6 +65,5 @@ class CustomInfo(models.AbstractModel):
if info_name not in info_list: if info_name not in info_list:
self.custom_info_ids |= self.custom_info_ids.new({ self.custom_info_ids |= self.custom_info_ids.new({
'model': self._name, 'model': self._name,
# 'res_id': self.id,
'custom_info_name_id': info_name.id, 'custom_info_name_id': info_name.id,
}) })

65
base_custom_info/views/custom_info_template_view.xml

@ -2,5 +2,70 @@
<openerp> <openerp>
<data> <data>
<record id="base_custom_info_template_form" model="ir.ui.view">
<field name="name">base.custom.info.template.form</field>
<field name="model">base.custom.info.template</field>
<field name="arch" type="xml">
<form string="Custom Info Template">
<sheet>
<group>
<field name="name"/>
<field name="model"/>
</group>
<group>
<field name="info_ids">
<tree string="Info Lines" editable="bottom">
<field name="name"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record id="base_custom_info_template_tree" model="ir.ui.view">
<field name="name">base.custom.info.template.tree</field>
<field name="model">base.custom.info.template</field>
<field name="arch" type="xml">
<tree string="Custom Info Templates">
<field name="name"/>
<field name="model_id"/>
<field name="info_ids"/>
</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">base.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="base_custom_info_value_tree" model="ir.ui.view">
<field name="name">base.custom.info.value.tree</field>
<field name="model">base.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>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save