Browse Source
Merge pull request #1146 from anandkansagra/12.0-mig-web_widget_x2many_2d_matrix_example
Merge pull request #1146 from anandkansagra/12.0-mig-web_widget_x2many_2d_matrix_example
[12.0] [MIG] web_widget_x2many_2d_matrix_examplepull/1179/head
Simone Orsi
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 352 additions and 0 deletions
-
41web_widget_x2many_2d_matrix_example/README.rst
-
3web_widget_x2many_2d_matrix_example/__init__.py
-
21web_widget_x2many_2d_matrix_example/__manifest__.py
-
20web_widget_x2many_2d_matrix_example/demo/x2m.demo.csv
-
117web_widget_x2many_2d_matrix_example/i18n/web_widget_x2many_2d_matrix_example.pot
-
2web_widget_x2many_2d_matrix_example/models/__init__.py
-
34web_widget_x2many_2d_matrix_example/models/x2m_demo.py
-
2web_widget_x2many_2d_matrix_example/readme/CONTRIBUTORS.rst
-
1web_widget_x2many_2d_matrix_example/readme/DESCRIPTION.rst
-
5web_widget_x2many_2d_matrix_example/security/ir.model.access.csv
-
BINweb_widget_x2many_2d_matrix_example/static/description/icon.png
-
53web_widget_x2many_2d_matrix_example/views/x2m_demo.xml
-
2web_widget_x2many_2d_matrix_example/wizard/__init__.py
-
29web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.py
-
22web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.xml
@ -0,0 +1,41 @@ |
|||
.. 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 |
|||
|
|||
=================================== |
|||
2D matrix for x2many fields example |
|||
=================================== |
|||
|
|||
Install it and click on the menu item `Demo x2m matrix widget`. |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/web/issues>`_. In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smash it by providing a detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Simone Orsi <simone.orsi@camptocamp.com> |
|||
* Anand Kansagra <kansagraanand@hotmail.com> |
|||
|
|||
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 https://odoo-community.org. |
@ -0,0 +1,3 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from . import models |
|||
from . import wizard |
@ -0,0 +1,21 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
{ |
|||
'name': 'web_widget_x2many_2d_matrix example', |
|||
'summary': "A small example on how to use `web_widget_x2many_2d_matrix`.", |
|||
"version": "12.0.1.0.0", |
|||
"author": "Camptocamp, " |
|||
"Odoo Community Association (OCA)", |
|||
"website": "https://github.com/OCA/web", |
|||
"license": "AGPL-3", |
|||
"category": "Hidden/Dependency", |
|||
"depends": [ |
|||
'web_widget_x2many_2d_matrix', |
|||
], |
|||
"data": [ |
|||
'security/ir.model.access.csv', |
|||
'demo/x2m.demo.csv', |
|||
'views/x2m_demo.xml', |
|||
'wizard/x2m_matrix.xml', |
|||
], |
|||
"installable": True, |
|||
} |
@ -0,0 +1,20 @@ |
|||
id,name,line_ids/user_id/id,line_ids/name,line_ids/value |
|||
web_widget_x2many_2d_matrix_example.x2m_demo_5,One,,, |
|||
,,base.user_demo,A,1 |
|||
,,base.user_demo,B,2 |
|||
,,base.user_demo,C,3 |
|||
web_widget_x2many_2d_matrix_example.x2m_demo_3,Two,,, |
|||
,,base.user_demo,E,5 |
|||
,,base.user_demo,F,6 |
|||
web_widget_x2many_2d_matrix_example.x2m_demo_2,Three,,, |
|||
,,base.user_root,G,8 |
|||
,,base.user_demo,H,9 |
|||
,,base.user_root,I,10 |
|||
web_widget_x2many_2d_matrix_example.x2m_demo_1,Four,,, |
|||
,,base.user_root,L,12 |
|||
,,base.user_demo,M,13 |
|||
,,base.user_demo,N,14 |
|||
,,base.user_demo,O,15 |
|||
,,base.user_root,P,16 |
|||
web_widget_x2many_2d_matrix_example.x2m_demo_4,Five,,, |
|||
,,base.user_demo,Q,18 |
@ -0,0 +1,117 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * web_widget_x2many_2d_matrix_example |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 12.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_create_uid |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_create_uid |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_create_uid |
|||
msgid "Created by" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_create_date |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_create_date |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_create_date |
|||
msgid "Created on" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.actions.act_window,name:web_widget_x2many_2d_matrix_example.action_x2m_demo |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_demo_id |
|||
msgid "Demo" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.ui.menu,name:web_widget_x2many_2d_matrix_example.base_matrix_widget_menu |
|||
msgid "Demo x2m matrix widget" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_display_name |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_display_name |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_display_name |
|||
msgid "Display Name" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_id |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_id |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_id |
|||
msgid "ID" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo___last_update |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line___last_update |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz___last_update |
|||
msgid "Last Modified on" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_write_uid |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_write_uid |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_write_uid |
|||
msgid "Last Updated by" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_write_date |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_write_date |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_write_date |
|||
msgid "Last Updated on" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_ids |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_matrix_demo_wiz_line_ids |
|||
msgid "Line" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_name |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_name |
|||
msgid "Name" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form |
|||
msgid "Try x2m 2d matrix" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_user_id |
|||
msgid "User" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line_value |
|||
msgid "Value" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo |
|||
msgid "x2m.demo" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo_line |
|||
msgid "x2m.demo.line" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_x2many_2d_matrix_example |
|||
#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_matrix_demo_wiz |
|||
msgid "x2m.matrix.demo.wiz" |
|||
msgstr "" |
|||
|
@ -0,0 +1,2 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from . import x2m_demo |
@ -0,0 +1,34 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import models, api, fields |
|||
|
|||
|
|||
class X2MDemo(models.Model): |
|||
_name = 'x2m.demo' |
|||
_description = 'X2Many Demo' |
|||
|
|||
name = fields.Char() |
|||
line_ids = fields.One2many('x2m.demo.line', 'demo_id') |
|||
|
|||
@api.multi |
|||
def open_x2m_matrix(self): |
|||
wiz = self.env['x2m.matrix.demo.wiz'].create({}) |
|||
return { |
|||
'name': 'Try x2many 2D matrix widget', |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
'res_model': 'x2m.matrix.demo.wiz', |
|||
'target': 'new', |
|||
'res_id': wiz.id, |
|||
'context': self.env.context, |
|||
} |
|||
|
|||
|
|||
class X2MDemoLine(models.Model): |
|||
_name = 'x2m.demo.line' |
|||
_description = 'X2Many Demo Line' |
|||
|
|||
name = fields.Char() |
|||
demo_id = fields.Many2one('x2m.demo') |
|||
user_id = fields.Many2one('res.users') |
|||
value = fields.Integer() |
@ -0,0 +1,2 @@ |
|||
* Simone Orsi <simone.orsi@camptocamp.com> |
|||
* Anand Kansagra <kansagraanand@hotmail.com> |
@ -0,0 +1 @@ |
|||
Install it and click on the menu item `Demo x2m matrix widget`. |
@ -0,0 +1,5 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_x2m_demo_line,access_x2m_demo_line,model_x2m_demo_line,base.group_user,1,0,0,0 |
|||
access_x2m_demo_line_admin,access_x2m_demo_line_admin,model_x2m_demo_line,base.group_system,1,1,1,1 |
|||
access_x2m_demo,access_x2m_demo,model_x2m_demo,base.group_user,1,0,0,0 |
|||
access_x2m_demo_admin,access_x2m_demo_admin,model_x2m_demo,base.group_system,1,1,1,1 |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1,53 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="view_x2m_demo_form" model="ir.ui.view"> |
|||
<field name="name">x2m.demo.form</field> |
|||
<field name="model">x2m.demo</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<sheet> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="line_ids"> |
|||
<tree> |
|||
<field name="name"/> |
|||
<field name="value"/> |
|||
<field name="user_id"/> |
|||
</tree> |
|||
</field> |
|||
</group> |
|||
<footer> |
|||
<button name="open_x2m_matrix" type="object" |
|||
string="Try x2m 2d matrix" |
|||
class="oe_stat_button" icon="fa-edit"/> |
|||
</footer> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.view" id="view_x2m_demo_tree"> |
|||
<field name="name">Demo - Tree</field> |
|||
<field name="model">x2m.demo</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="name"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_x2m_demo" model="ir.actions.act_window"> |
|||
<field name="name">Demo</field> |
|||
<field name="res_model">x2m.demo</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="view_id" ref="view_x2m_demo_tree"/> |
|||
</record> |
|||
|
|||
<menuitem |
|||
id="base_matrix_widget_menu" |
|||
name="Demo x2m matrix widget" |
|||
action="action_x2m_demo"/> |
|||
|
|||
</odoo> |
@ -0,0 +1,2 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from . import x2m_matrix |
@ -0,0 +1,29 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class X2mMatrixDemoWiz(models.TransientModel): |
|||
_name = 'x2m.matrix.demo.wiz' |
|||
_description = 'X2Many Matrix Demo Wizard' |
|||
|
|||
line_ids = fields.Many2many( |
|||
'x2m.demo.line', default=lambda self: self._default_line_ids()) |
|||
|
|||
def _default_line_ids(self): |
|||
recs = self.env['x2m.demo'].search([]) |
|||
# same with users |
|||
users = self.env['x2m.demo.line'].search([]).mapped('user_id') |
|||
return [ |
|||
(0, 0, { |
|||
'name': "{}'s task on {}".format(usr.name, rec.name), |
|||
'demo_id': rec.id, |
|||
'user_id': usr.id, |
|||
'value': 0, |
|||
}) |
|||
# if the project doesn't have a task for the user, create a new one |
|||
if not rec.line_ids.filtered(lambda x: x.user_id == usr) else |
|||
# otherwise, return the task |
|||
(4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id) |
|||
for rec in recs |
|||
for usr in users |
|||
] |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="x2many_2d_matrix_demo" model="ir.ui.view"> |
|||
<field name="name">x2m.matrix.demo.wiz</field> |
|||
<field name="model">x2m.matrix.demo.wiz</field> |
|||
<field name="type">form</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<field name="line_ids" widget="x2many_2d_matrix" |
|||
field_x_axis="demo_id" field_y_axis="user_id" field_value="value"> |
|||
<tree> |
|||
<field name="demo_id"/> |
|||
<field name="user_id"/> |
|||
<field name="value"/> |
|||
</tree> |
|||
</field> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue