diff --git a/web_widget_x2many_2d_matrix_example/README.rst b/web_widget_x2many_2d_matrix_example/README.rst new file mode 100644 index 000000000..67843ee97 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/README.rst @@ -0,0 +1,74 @@ +=================================== +web_widget_x2many_2d_matrix example +=================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/13.0/web_widget_x2many_2d_matrix_example + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_x2many_2d_matrix_example + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Install it and click on the menu item `Demo x2m matrix widget`. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Simone Orsi +* Anand Kansagra + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_x2many_2d_matrix_example/__init__.py b/web_widget_x2many_2d_matrix_example/__init__.py new file mode 100644 index 000000000..d6c56a95f --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models +from . import wizard diff --git a/web_widget_x2many_2d_matrix_example/__manifest__.py b/web_widget_x2many_2d_matrix_example/__manifest__.py new file mode 100644 index 000000000..df95e5e9a --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/__manifest__.py @@ -0,0 +1,18 @@ +# 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": "13.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, +} diff --git a/web_widget_x2many_2d_matrix_example/demo/x2m.demo.csv b/web_widget_x2many_2d_matrix_example/demo/x2m.demo.csv new file mode 100644 index 000000000..9a8b5aa11 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/demo/x2m.demo.csv @@ -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 diff --git a/web_widget_x2many_2d_matrix_example/i18n/web_widget_x2many_2d_matrix_example.pot b/web_widget_x2many_2d_matrix_example/i18n/web_widget_x2many_2d_matrix_example.pot new file mode 100644 index 000000000..2a35dc195 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/i18n/web_widget_x2many_2d_matrix_example.pot @@ -0,0 +1,147 @@ +# 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__write_uid +#: 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_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__write_date +#: 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_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__name +#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line__name +msgid "Name" +msgstr "" + +#. module: web_widget_x2many_2d_matrix_example +#: model_terms: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_terms:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form +msgid "Try x2m 2d matrix (many2one)" +msgstr "" + +#. module: web_widget_x2many_2d_matrix_example +#: model_terms:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form +msgid "Try x2m 2d matrix (selection)" +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 +#: selection:x2m.demo.line,value_selection:0 +msgid "Value 1" +msgstr "" + +#. module: web_widget_x2many_2d_matrix_example +#: selection:x2m.demo.line,value_selection:0 +msgid "Value 2" +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_many2one +msgid "Value Many2One" +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_selection +msgid "Value Selection" +msgstr "" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo +msgid "X2Many Demo" +msgstr "" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo_line +msgid "X2Many 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 "X2Many Matrix Demo Wizard" +msgstr "" + diff --git a/web_widget_x2many_2d_matrix_example/i18n/zh_CN.po b/web_widget_x2many_2d_matrix_example/i18n/zh_CN.po new file mode 100644 index 000000000..db6dcf62e --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/i18n/zh_CN.po @@ -0,0 +1,149 @@ +# 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" +"PO-Revision-Date: 2019-09-17 19:24+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\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 "演示x2m矩阵小部件" + +#. 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 "ID" + +#. 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__write_uid +#: 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_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__write_date +#: 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_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__name +#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line__name +msgid "Name" +msgstr "名称" + +#. module: web_widget_x2many_2d_matrix_example +#: model_terms:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form +msgid "Try x2m 2d matrix" +msgstr "试试x2m 2d矩阵" + +#. module: web_widget_x2many_2d_matrix_example +#: model_terms:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form +msgid "Try x2m 2d matrix (many2one)" +msgstr "试试x2m 2d矩阵(many2one)" + +#. module: web_widget_x2many_2d_matrix_example +#: model_terms:ir.ui.view,arch_db:web_widget_x2many_2d_matrix_example.view_x2m_demo_form +msgid "Try x2m 2d matrix (selection)" +msgstr "试试x2m 2d矩阵 (selection)" + +#. 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 +#: selection:x2m.demo.line,value_selection:0 +msgid "Value 1" +msgstr "值1" + +#. module: web_widget_x2many_2d_matrix_example +#: selection:x2m.demo.line,value_selection:0 +msgid "Value 2" +msgstr "值2" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line__value_many2one +msgid "Value Many2One" +msgstr "值 Many2One" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model.fields,field_description:web_widget_x2many_2d_matrix_example.field_x2m_demo_line__value_selection +msgid "Value Selection" +msgstr "值Selection" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo +msgid "X2Many Demo" +msgstr "X2Many演示" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_demo_line +msgid "X2Many Demo Line" +msgstr "X2Many演示行" + +#. module: web_widget_x2many_2d_matrix_example +#: model:ir.model,name:web_widget_x2many_2d_matrix_example.model_x2m_matrix_demo_wiz +msgid "X2Many Matrix Demo Wizard" +msgstr "X2Many Matrix演示向导" diff --git a/web_widget_x2many_2d_matrix_example/models/__init__.py b/web_widget_x2many_2d_matrix_example/models/__init__.py new file mode 100644 index 000000000..bf8b6ac47 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import x2m_demo diff --git a/web_widget_x2many_2d_matrix_example/models/x2m_demo.py b/web_widget_x2many_2d_matrix_example/models/x2m_demo.py new file mode 100644 index 000000000..c8a1dd25c --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/models/x2m_demo.py @@ -0,0 +1,48 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class X2MDemo(models.Model): + _name = "x2m.demo" + _description = "X2Many Demo" + + name = fields.Char() + line_ids = fields.One2many("x2m.demo.line", "demo_id") + + def _open_x2m_matrix(self, view_xmlid): + wiz = self.env["x2m.matrix.demo.wiz"].create({}) + view_id = self.env.ref( + "web_widget_x2many_2d_matrix_example.%s" % view_xmlid, + ).id + 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, + "view_id": view_id, + "context": self.env.context, + } + + def open_x2m_matrix(self): + return self._open_x2m_matrix("x2many_2d_matrix_demo") + + def open_x2m_matrix_selection(self): + return self._open_x2m_matrix("x2many_2d_matrix_demo_selection") + + def open_x2m_matrix_many2one(self): + return self._open_x2m_matrix("x2many_2d_matrix_demo_many2one") + + +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() + value_selection = fields.Selection([("val1", "Value 1"), ("val2", "Value 2")],) + value_many2one = fields.Many2one("res.groups") diff --git a/web_widget_x2many_2d_matrix_example/readme/CONTRIBUTORS.rst b/web_widget_x2many_2d_matrix_example/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..1fee00cb0 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Simone Orsi +* Anand Kansagra diff --git a/web_widget_x2many_2d_matrix_example/readme/DESCRIPTION.rst b/web_widget_x2many_2d_matrix_example/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1af8b59ef --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Install it and click on the menu item `Demo x2m matrix widget`. diff --git a/web_widget_x2many_2d_matrix_example/security/ir.model.access.csv b/web_widget_x2many_2d_matrix_example/security/ir.model.access.csv new file mode 100644 index 000000000..ff2b0388d --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/security/ir.model.access.csv @@ -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 diff --git a/web_widget_x2many_2d_matrix_example/static/description/icon.png b/web_widget_x2many_2d_matrix_example/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_x2many_2d_matrix_example/static/description/icon.png differ diff --git a/web_widget_x2many_2d_matrix_example/static/description/index.html b/web_widget_x2many_2d_matrix_example/static/description/index.html new file mode 100644 index 000000000..59b905f00 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +web_widget_x2many_2d_matrix example + + + +
+

web_widget_x2many_2d_matrix example

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Install it and click on the menu item Demo x2m matrix widget.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_widget_x2many_2d_matrix_example/wizard/__init__.py b/web_widget_x2many_2d_matrix_example/wizard/__init__.py new file mode 100644 index 000000000..e8c3b4552 --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/wizard/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import x2m_matrix diff --git a/web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.py b/web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.py new file mode 100644 index 000000000..0e7477b7f --- /dev/null +++ b/web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.py @@ -0,0 +1,34 @@ +# 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): + """take care that the widget gets records passed for every combination + of x2m.demo and res.users involved""" + recs = self.env["x2m.demo"].search([]) + 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, + }, + ) + # if there isn't a demo line record for the user, create a new one + if not rec.line_ids.filtered(lambda x: x.user_id == usr) else + # otherwise, return the line + (4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id) + for rec in recs + for usr in users + ]