Carlos Incaser
9 years ago
committed by
Alexandre Díaz
6 changed files with 226 additions and 0 deletions
-
53base_custom_info/README.rst
-
6base_custom_info/__init__.py
-
21base_custom_info/__openerp__.py
-
6base_custom_info/models/__init__.py
-
69base_custom_info/models/custom_info_template.py
-
71base_custom_info/views/custom_info_template_view.xml
@ -0,0 +1,53 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
================ |
|||
Base Custom Info |
|||
================ |
|||
|
|||
This module allow create custom fields in models without alter models |
|||
structures. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
|
|||
.. 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 |
|||
|
|||
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**>`_. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Rafael Blasco <rafabn@antiun.com> |
|||
* Carlos Dauden <carlos@incaser.es> |
|||
* Sergio Teruel <sergio@incaser.es> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
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. |
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel |
|||
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden |
|||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|||
|
|||
from . import models |
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel |
|||
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden |
|||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|||
|
|||
{ |
|||
'name': "Base Custom Info", |
|||
'summary': "Add custom field in models", |
|||
'category': 'Customize', |
|||
'version': '8.0.1.0.0', |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'data': [ |
|||
], |
|||
'author': 'Antiun Ingeniería S.L., ' |
|||
'Incaser Informatica S.L., ', |
|||
'website': 'http://www.antiun.com', |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
} |
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel |
|||
# (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 |
@ -0,0 +1,69 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel |
|||
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden |
|||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|||
|
|||
from openerp import api, fields, models, _ |
|||
|
|||
|
|||
class CustomInfoTemplate(models.Model): |
|||
_name = "custom.info.template" |
|||
|
|||
name = fields.Char() |
|||
model_id = fields.Many2one(comodel_name='ir.model', string='Data Model') |
|||
info_ids = fields.One2many( |
|||
comodel_name='custom.info.template.line', |
|||
inverse_name='template_id', |
|||
string='Info') |
|||
|
|||
|
|||
class CustomInfoTemplateLine(models.Model): |
|||
_name = "custom.info.template.line" |
|||
|
|||
name = fields.Char() |
|||
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", |
|||
string="Info Values") |
|||
|
|||
|
|||
class CustomInfoValue(models.Model): |
|||
_name = "custom.info.value" |
|||
_rec_name = 'value' |
|||
|
|||
model = fields.Char(select=True) |
|||
res_id = fields.Integer(select=True) |
|||
custom_info_name_id = fields.Many2one( |
|||
comodel_name='custom.info.template.line', |
|||
string='Info Name') |
|||
value = fields.Char() |
|||
|
|||
|
|||
class CustomInfo(models.AbstractModel): |
|||
_name = "custom.info" |
|||
|
|||
custom_info_template_id = fields.Many2one( |
|||
comodel_name='custom.info.template', |
|||
string='Info Template') |
|||
custom_info_ids = fields.One2many( |
|||
comodel_name='custom.info.value', |
|||
inverse_name='res_id', |
|||
domain=lambda self: [('model', '=', self._name)], |
|||
auto_join=True, |
|||
string='Custom Info') |
|||
|
|||
@api.onchange('custom_info_template_id') |
|||
def _onchange_custom_info_template_id(self): |
|||
if not self.custom_info_template_id: |
|||
self.custom_info_ids = False |
|||
else: |
|||
info_list = self.custom_info_ids.mapped('custom_info_name_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, |
|||
}) |
@ -0,0 +1,71 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<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> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue