Browse Source

Fix many bugs and styling, and prepare for OCA.

pull/313/head
Jairo Llopis 9 years ago
parent
commit
821a8fd4f8
  1. 55
      base_custom_info/README.rst
  2. 4
      base_custom_info/__init__.py
  3. 7
      base_custom_info/__openerp__.py
  4. 198
      base_custom_info/i18n/es.po
  5. 4
      base_custom_info/models/__init__.py
  6. 64
      base_custom_info/models/custom_info.py
  7. 14
      base_custom_info/security/ir.model.access.csv
  8. 12
      base_custom_info/views/custom_info_property_view.xml
  9. 2
      base_custom_info/views/custom_info_template_view.xml
  10. 4
      base_custom_info/views/custom_info_value_view.xml
  11. 9
      base_custom_info/views/menu.xml

55
base_custom_info/README.rst

@ -6,26 +6,62 @@
Base Custom Info
================
This module allow create custom fields in models without alter models
structures.
This module allows to create custom fields in models without altering model's
structure.
Installation
============
This module serves as a base for other modules that implement this behavior in
concrete models.
This means that you should **not** install this module by itself. If you found
it installed, it means probably that another module that needs it installed it.
Usage
=====
To use this module, you need to:
This module defines *Custom Info Templates* that define what properties are
expected for a given record.
To define a template, you need to:
* Go to *Settings > Custom Info > Templates*.
* Create one.
* Add some *Properties* to it.
All database records with that template enabled will automatically fill those
properties.
To manage the properties, you need to:
* Go to *Settings > Custom Info > Properties*.
To manage their values, you need to:
* Go to *Settings > Custom Info > Values*.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186
:target: https://runbot.odoo-community.org/runbot/135/8.0
Development
===========
To create a module that supports custom information, just depend on this module
and inherit from the ``custom.info`` model.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/project/issues/new?body=module:%20base_custom_info%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/product-attribute/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
product-attribute/issues/new?body=module:%20
base_custom_info%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
@ -36,6 +72,7 @@ Contributors
* Rafael Blasco <rafabn@antiun.com>
* Carlos Dauden <carlos@incaser.es>
* Sergio Teruel <sergio@incaser.es>
* Jairo Llopis <yajo.sk8@gmail.com>
Maintainer
----------
@ -50,4 +87,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

4
base_custom_info/__init__.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Sergio Teruel
# © 2015 Antiun Ingeniería S.L. - Carlos Dauden
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import models

7
base_custom_info/__openerp__.py

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Sergio Teruel
# © 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
@ -13,7 +14,7 @@
],
'data': [
'views/custom_info_template_view.xml',
'views/custom_info_template_line_view.xml',
'views/custom_info_property_view.xml',
'views/custom_info_value_view.xml',
'views/menu.xml',
'security/ir.model.access.csv',

198
base_custom_info/i18n/es.po

@ -0,0 +1,198 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_custom_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-15 17:10+0100\n"
"PO-Revision-Date: 2015-12-15 17:12+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.5\n"
#. module: base_custom_info
#: model:ir.actions.act_window,help:base_custom_info.custom_info_template_action
msgid ""
"<p class=\"oe_view_nocontent_create\">\n"
" Click to define a new custom info template.\n"
" </p><p>\n"
" You must define a custom info template for each\n"
" product properties group.\n"
" </p>\n"
" "
msgstr ""
"<p class=\"oe_view_nocontent_create\">\n"
"Pulsa para definir una nueva plantilla de información personalizada.\n"
"</p><p>\n"
"Debe definir una plantilla de información personalizada para cada diferente grupo de propiedades.\n"
"</p>"
#. module: base_custom_info
#: sql_constraint:custom.info.value:0
msgid "Another property with that name exists for that resource."
msgstr "Ya existe otra propiedad con ese nombre para ese recurso."
#. module: base_custom_info
#: sql_constraint:custom.info.property:0
msgid "Another property with that name exists for that template."
msgstr "Ya existe otra propiedad con ese nombre en esa plantilla."
#. module: base_custom_info
#: sql_constraint:custom.info.template:0
msgid "Another template with that name exists for that model."
msgstr "Ya existe otra plantilla con ese nombre para ese modelo."
#. module: base_custom_info
#: field:custom.info.property,create_uid:0
#: field:custom.info.template,create_uid:0
#: field:custom.info.value,create_uid:0
msgid "Created by"
msgstr "Creado por"
#. module: base_custom_info
#: field:custom.info.property,create_date:0
#: field:custom.info.template,create_date:0
#: field:custom.info.value,create_date:0
msgid "Created on"
msgstr "Creado el"
#. module: base_custom_info
#: model:ir.ui.menu,name:base_custom_info.menu_base_custom_info
msgid "Custom Info"
msgstr "Información personalizada"
#. module: base_custom_info
#: view:custom.info.template:base_custom_info.base_custom_info_template_form
msgid "Custom Info Template"
msgstr "Plantilla de información personalizada"
#. module: base_custom_info
#: view:custom.info.property:base_custom_info.base_custom_info_template_line_form
msgid "Custom Info Template Properties"
msgstr "Propiedades de la plantilla de información personalizada"
#. module: base_custom_info
#: view:custom.info.property:base_custom_info.base_custom_info_template_line_tree
#: view:custom.info.template:base_custom_info.base_custom_info_template_tree
msgid "Custom Info Templates"
msgstr "Plantillas de información personalizada"
#. module: base_custom_info
#: field:custom.info,custom_info_template_id:0
msgid "Custom Information Template"
msgstr "Plantilla de información personalizada"
#. module: base_custom_info
#: field:custom.info,custom_info_ids:0
msgid "Custom Properties"
msgstr "Propiedades personalizadas"
#. module: base_custom_info
#: view:custom.info.value:base_custom_info.base_custom_info_value_tree
msgid "Custom Property Values"
msgstr "Valores de las propiedades personalizadas"
#. module: base_custom_info
#: model:ir.model,name:base_custom_info.model_custom_info_property
msgid "Custom information property"
msgstr "Propiedad de información personalizada"
#. module: base_custom_info
#: model:ir.model,name:base_custom_info.model_custom_info_template
msgid "Custom information template"
msgstr "Plantilla de información personalizada"
#. module: base_custom_info
#: model:ir.model,name:base_custom_info.model_custom_info_value
msgid "Custom information value"
msgstr "Valor de información personalizada"
#. module: base_custom_info
#: field:custom.info,id:0 field:custom.info.property,id:0
#: field:custom.info.template,id:0 field:custom.info.value,id:0
msgid "ID"
msgstr "ID"
#. module: base_custom_info
#: view:custom.info.template:base_custom_info.base_custom_info_template_form
msgid "Info Lines"
msgstr "Líneas de información"
#. module: base_custom_info
#: model:ir.model,name:base_custom_info.model_custom_info
msgid "Inheritable abstract model to add custom info in any model"
msgstr "Modelo abstracto que se puede heredar para añadir información personalizada a cualquier modelo"
#. module: base_custom_info
#: field:custom.info.property,write_uid:0
#: field:custom.info.template,write_uid:0 field:custom.info.value,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"
#. module: base_custom_info
#: field:custom.info.property,write_date:0
#: field:custom.info.template,write_date:0
#: field:custom.info.value,write_date:0
msgid "Last Updated on"
msgstr "Última actualización el"
#. module: base_custom_info
#: field:custom.info.template,model_id:0 field:custom.info.value,model:0
msgid "Model"
msgstr "Modelo"
#. module: base_custom_info
#: field:custom.info.property,name:0 field:custom.info.template,name:0
msgid "Name"
msgstr "Nombre"
#. module: base_custom_info
#: field:custom.info.template,info_ids:0
#: model:ir.actions.act_window,name:base_custom_info.custom_info_template_line_action
#: model:ir.ui.menu,name:base_custom_info.menu_base_custom_info_template_line
msgid "Properties"
msgstr "Propiedades"
#. module: base_custom_info
#: field:custom.info.value,property_id:0
msgid "Property"
msgstr "Propiedad"
#. module: base_custom_info
#: field:custom.info.property,info_value_ids:0
msgid "Property Values"
msgstr "Valor de la propiedad"
#. module: base_custom_info
#: field:custom.info.value,res_id:0
msgid "Resource ID"
msgstr "ID del recurso"
#. module: base_custom_info
#: field:custom.info.property,template_id:0
msgid "Template"
msgstr "Plantilla"
#. module: base_custom_info
#: model:ir.actions.act_window,name:base_custom_info.custom_info_template_action
#: model:ir.ui.menu,name:base_custom_info.menu_base_custom_info_template
msgid "Templates"
msgstr "Plantillas"
#. module: base_custom_info
#: field:custom.info.value,value:0
msgid "Value"
msgstr "Valor"
#. module: base_custom_info
#: model:ir.actions.act_window,name:base_custom_info.custom_info_value_action
#: model:ir.ui.menu,name:base_custom_info.menu_base_custom_info_value
msgid "Values"
msgstr "Valores"

4
base_custom_info/models/__init__.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Sergio Teruel
# © 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

64
base_custom_info/models/custom_info.py

@ -1,59 +1,77 @@
# -*- coding: utf-8 -*-
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Sergio Teruel
# © 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import api, fields, models, _
from openerp import api, fields, models
class CustomInfoTemplate(models.Model):
"""Defines custom properties expected for a given database object."""
_name = "custom.info.template"
_description = "Template of properties"
_description = "Custom information template"
_sql_constraints = [
("name_model",
"UNIQUE (name, model_id)",
"Another template with that name exists for that model."),
]
name = fields.Char()
model_id = fields.Many2one(comodel_name='ir.model', string='Data Model')
name = fields.Char(translate=True)
model_id = fields.Many2one(comodel_name='ir.model', string='Model')
info_ids = fields.One2many(
comodel_name='custom.info.template.line',
comodel_name='custom.info.property',
inverse_name='template_id',
string='Properties')
class CustomInfoTemplateLine(models.Model):
_name = "custom.info.template.line"
_description = "Properties"
class CustomInfoProperty(models.Model):
"""Name of the custom information property."""
_name = "custom.info.property"
_description = "Custom information property"
_sql_constraints = [
("name_template",
"UNIQUE (name, template_id)",
"Another property with that name exists for that template."),
]
name = fields.Char()
name = fields.Char(translate=True)
template_id = fields.Many2one(
comodel_name='custom.info.template',
string='Template')
info_value_ids = fields.One2many(
comodel_name="custom.info.value",
inverse_name="custom_info_name_id",
inverse_name="property_id",
string="Property Values")
class CustomInfoValue(models.Model):
_name = "custom.info.value"
_description = "Values of properties"
_description = "Custom information value"
_rec_name = 'value'
_sql_constraints = [
("property_model_res",
"UNIQUE (property_id, model, res_id)",
"Another property with that name exists for that resource."),
]
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',
res_id = fields.Integer("Resource ID", index=True, required=True)
property_id = fields.Many2one(
comodel_name='custom.info.property',
required=True,
string='Property Name')
name = fields.Char(related='custom_info_name_id.name')
value = fields.Char()
string='Property')
name = fields.Char(related='property_id.name')
value = fields.Char(translate=True)
class CustomInfo(models.AbstractModel):
_name = "custom.info"
_description = "Abstract model from inherit to add info in any model"
_description = "Inheritable abstract model to add custom info in any model"
custom_info_template_id = fields.Many2one(
comodel_name='custom.info.template',
string='Property Template')
string='Custom Information Template')
custom_info_ids = fields.One2many(
comodel_name='custom.info.value',
inverse_name='res_id',
@ -66,12 +84,12 @@ class CustomInfo(models.AbstractModel):
if not self.custom_info_template_id:
self.custom_info_ids = False
else:
info_list = self.custom_info_ids.mapped('custom_info_name_id')
info_list = self.custom_info_ids.mapped('property_id')
for info_name in self.custom_info_template_id.info_ids:
if info_name not in info_list:
self.custom_info_ids |= self.custom_info_ids.new({
'model': self._name,
'custom_info_name_id': info_name.id,
'property_id': info_name.id,
})
@api.multi

14
base_custom_info/security/ir.model.access.csv

@ -1,7 +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
"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_property_user","custom.info.template.line.user","model_custom_info_property","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_system",1,1,1,1
"access_custom_info_property_sale_manager","custom.info.template.line.salemanager","model_custom_info_property","base.group_system",1,1,1,1
"access_custom_info_value_sale_manager","custom.info.value.salemanager","model_custom_info_value","base.group_system",1,1,1,1

12
base_custom_info/views/custom_info_template_line_view.xml → base_custom_info/views/custom_info_property_view.xml

@ -3,8 +3,8 @@
<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="name">base.custom.info.property.tree</field>
<field name="model">custom.info.property</field>
<field name="arch" type="xml">
<tree string="Custom Info Templates">
<field name="name"/>
@ -14,10 +14,10 @@
</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="name">base.custom.info.property.form</field>
<field name="model">custom.info.property</field>
<field name="arch" type="xml">
<form string="Custom Info Template Lines">
<form string="Custom Info Template Properties">
<sheet>
<group>
<field name="name"/>
@ -34,7 +34,7 @@
<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="res_model">custom.info.property</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>

2
base_custom_info/views/custom_info_template_view.xml

@ -48,7 +48,7 @@
<p class="oe_view_nocontent_create">
Click to define a new custom info template.
</p><p>
You must define a custom info template for every different
You must define a custom info template for each
product properties group.
</p>
</field>

4
base_custom_info/views/custom_info_value_view.xml

@ -6,8 +6,8 @@
<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"/>
<tree string="Custom Property Values">
<field name="property_id"/>
<field name="value"/>
<field name="model"/>
<field name="res_id"/>

9
base_custom_info/views/menu.xml

@ -7,15 +7,18 @@
parent="base.menu_administration" sequence="45"/>
<!--base.custom.info.template-->
<menuitem id="menu_base_custom_info_template" action="custom_info_template_action"
<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"
<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"
<menuitem id="menu_base_custom_info_value"
action="custom_info_value_action"
parent="menu_base_custom_info" sequence="15"/>
</data>

Loading…
Cancel
Save