mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
Merge pull request #427 from Tecnativa/9.0-web_widget_x2many_2d_matrix
[9.0][MIG] web_widget_x2many_2d_matrix: Migration and enhancement
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
.. 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
|
||||
===========================
|
||||
|
||||
This module allows to show an x2many field with 3-tuples
|
||||
($x_value, $y_value, $value) in a table
|
||||
|
||||
$x_value1 $x_value2
|
||||
========= =========== ===========
|
||||
\ $x_value1 $x_value2
|
||||
========= =========== ===========
|
||||
$y_value1 $value(1/1) $value(2/1)
|
||||
$y_value2 $value(1/2) $value(2/2)
|
||||
@@ -19,7 +25,9 @@ result could look like this:
|
||||
.. image:: /web_widget_x2many_2d_matrix/static/description/screenshot.png
|
||||
:alt: Screenshot
|
||||
|
||||
The beauty of this is that you have an arbitrary amount of columns with this widget, trying to get this in standard x2many lists involves some quite agly hacks.
|
||||
The beauty of this is that you have an arbitrary amount of columns with this
|
||||
widget, trying to get this in standard x2many lists involves some quite ugly
|
||||
hacks.
|
||||
|
||||
Usage
|
||||
=====
|
||||
@@ -44,27 +52,91 @@ field_label_x_axis
|
||||
Use another field to display in the table header
|
||||
field_label_y_axis
|
||||
Use another field to display in the table header
|
||||
x_axis_clickable
|
||||
It indicates if the X axis allows to be clicked for navigating to the field
|
||||
(if it's a many2one field). True by default
|
||||
y_axis_clickable
|
||||
It indicates if the Y axis allows to be clicked for navigating to the field
|
||||
(if it's a many2one field). True by default
|
||||
field_value
|
||||
Show this field as value
|
||||
show_row_totals
|
||||
If field_value is a numeric field, calculate row totals
|
||||
If field_value is a numeric field, it indicates if you want to calculate
|
||||
row totals. True by default
|
||||
show_column_totals
|
||||
If field_value is a numeric field, calculate column totals
|
||||
If field_value is a numeric field, it indicates if you want to calculate
|
||||
column totals. True by default
|
||||
field_att_<name>
|
||||
Declare as many options prefixed with this string as you need for binding
|
||||
a field value with an HTML node attribute (disabled, class, style...)
|
||||
called as the `<name>` passed in the option.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/162/8.0
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
You need a data structure already filled with values. Let's assume we want to
|
||||
use this widget in a wizard that lets the user fill in planned hours for one
|
||||
task per project per user. In this case, we can use ``project.task`` as our
|
||||
data model and point to it from our wizard. The crucial part is that we fill
|
||||
the field in the default function::
|
||||
|
||||
class MyWizard(models.TransientModel):
|
||||
_name = 'my.wizard'
|
||||
|
||||
def _default_task_ids(self):
|
||||
# your list of project should come from the context, some selection
|
||||
# in a previous wizard or wherever else
|
||||
projects = self.env['project.project'].browse([1, 2, 3])
|
||||
# same with users
|
||||
users = self.env['res.users'].browse([1, 2, 3])
|
||||
return [
|
||||
(0, 0, {'project_id': p.id, 'user_id': u.id, 'planned_hours': 0})
|
||||
# if the project doesn't have a task for the user, create a new one
|
||||
if not p.task_ids.filtered(lambda x: x.user_id == u) else
|
||||
# otherwise, return the task
|
||||
(4, p.task_ids.filtered(lambda x: x.user_id == u)[0].id)
|
||||
for p in projects
|
||||
for u in users
|
||||
]
|
||||
|
||||
task_ids = fields.Many2many('project.task', default=_default_task_ids)
|
||||
|
||||
Now in our wizard, we can use::
|
||||
|
||||
<field name="task_ids" widget="x2many_2d_matrix" field_x_axis="project_id" field_y_axis="user_id" field_value="planned_hours" />
|
||||
|
||||
Note that all values in the matrix must exist, so you need to create them
|
||||
previously if not present, but you can control visually the editability of
|
||||
the fields in the matrix through `field_att_disabled` option with a control
|
||||
field.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* it would be worth trying to instantiate the proper field widget and let it render the input
|
||||
* It would be worth trying to instantiate the proper field widget and let it render the input
|
||||
* Let the widget deal with the missing values of the full Cartesian product,
|
||||
instead of being forced to pre-fill all the possible values.
|
||||
* If you pass values with an onchange, you need to overwrite the model's method
|
||||
`onchange` for making the widget work::
|
||||
|
||||
@api.multi
|
||||
def onchange(self, values, field_name, field_onchange):
|
||||
if "one2many_field" in field_onchange:
|
||||
for sub in [<field_list>]:
|
||||
field_onchange.setdefault("one2many_field." + sub, u"")
|
||||
return super(model, self).onchange(values, field_name, field_onchange)
|
||||
|
||||
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 smashing it by providing a detailed and welcomed feedback
|
||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_widget_x2many_2d_matrix%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/web/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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
@@ -73,16 +145,19 @@ Contributors
|
||||
------------
|
||||
|
||||
* Holger Brunn <hbrunn@therp.nl>
|
||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://odoo-community.org
|
||||
.. 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.
|
||||
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.
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# Copyright 2015 Holger Brunn <hbrunn@therp.nl>
|
||||
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "2D matrix for x2many fields",
|
||||
"version": "8.0.1.0.0",
|
||||
"version": "9.0.1.0.0",
|
||||
"author": "Therp BV, "
|
||||
"Tecnativa,"
|
||||
"Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "Hidden/Dependency",
|
||||
@@ -35,12 +21,5 @@
|
||||
"qweb": [
|
||||
'static/src/xml/web_widget_x2many_2d_matrix.xml',
|
||||
],
|
||||
"test": [
|
||||
],
|
||||
"auto_install": False,
|
||||
'installable': False,
|
||||
"application": False,
|
||||
"external_dependencies": {
|
||||
'python': [],
|
||||
},
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
27
web_widget_x2many_2d_matrix/i18n/ar.po
Normal file
27
web_widget_x2many_2d_matrix/i18n/ar.po
Normal file
@@ -0,0 +1,27 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
# SaFi J. <safi2266@gmail.com>, 2015
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-12-16 07:41+0000\n"
|
||||
"PO-Revision-Date: 2015-12-16 17:24+0000\n"
|
||||
"Last-Translator: SaFi J. <safi2266@gmail.com>\n"
|
||||
"Language-Team: Arabic (http://www.transifex.com/oca/OCA-web-8-0/language/ar/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: ar\n"
|
||||
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "المجموع الاجمالي"
|
||||
27
web_widget_x2many_2d_matrix/i18n/de.po
Normal file
27
web_widget_x2many_2d_matrix/i18n/de.po
Normal file
@@ -0,0 +1,27 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
# Rudolf Schnapka <rs@techno-flex.de>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-10 07:31+0000\n"
|
||||
"PO-Revision-Date: 2016-01-18 20:15+0000\n"
|
||||
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
|
||||
"Language-Team: German (http://www.transifex.com/oca/OCA-web-8-0/language/de/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: de\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Gesamt"
|
||||
26
web_widget_x2many_2d_matrix/i18n/es.po
Normal file
26
web_widget_x2many_2d_matrix/i18n/es.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-11-23 13:46+0000\n"
|
||||
"PO-Revision-Date: 2015-11-07 11:29+0000\n"
|
||||
"Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>\n"
|
||||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-web-8-0/language/es/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: es\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Total"
|
||||
27
web_widget_x2many_2d_matrix/i18n/fi.po
Normal file
27
web_widget_x2many_2d_matrix/i18n/fi.po
Normal file
@@ -0,0 +1,27 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
# Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-10 07:31+0000\n"
|
||||
"PO-Revision-Date: 2016-02-01 09:54+0000\n"
|
||||
"Last-Translator: Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>\n"
|
||||
"Language-Team: Finnish (http://www.transifex.com/oca/OCA-web-8-0/language/fi/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: fi\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Yhteensä"
|
||||
26
web_widget_x2many_2d_matrix/i18n/fr.po
Normal file
26
web_widget_x2many_2d_matrix/i18n/fr.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-05-06 15:50+0000\n"
|
||||
"PO-Revision-Date: 2015-11-07 11:22+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: French (http://www.transifex.com/oca/OCA-web-8-0/language/fr/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: fr\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Total"
|
||||
27
web_widget_x2many_2d_matrix/i18n/hr.po
Normal file
27
web_widget_x2many_2d_matrix/i18n/hr.po
Normal file
@@ -0,0 +1,27 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
# Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-08-25 00:51+0000\n"
|
||||
"PO-Revision-Date: 2016-08-19 11:47+0000\n"
|
||||
"Last-Translator: Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>\n"
|
||||
"Language-Team: Croatian (http://www.transifex.com/oca/OCA-web-8-0/language/hr/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: hr\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Ukupno"
|
||||
26
web_widget_x2many_2d_matrix/i18n/it.po
Normal file
26
web_widget_x2many_2d_matrix/i18n/it.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-03-17 07:30+0000\n"
|
||||
"PO-Revision-Date: 2015-11-07 11:22+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: Italian (http://www.transifex.com/oca/OCA-web-8-0/language/it/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: it\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Totale"
|
||||
26
web_widget_x2many_2d_matrix/i18n/pt_BR.po
Normal file
26
web_widget_x2many_2d_matrix/i18n/pt_BR.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-03-11 02:18+0000\n"
|
||||
"PO-Revision-Date: 2016-03-05 16:20+0000\n"
|
||||
"Last-Translator: danimaribeiro <danimaribeiro@gmail.com>\n"
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-web-8-0/language/pt_BR/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: pt_BR\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Total"
|
||||
26
web_widget_x2many_2d_matrix/i18n/sl.po
Normal file
26
web_widget_x2many_2d_matrix/i18n/sl.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-11-23 13:46+0000\n"
|
||||
"PO-Revision-Date: 2015-11-08 05:48+0000\n"
|
||||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
|
||||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-web-8-0/language/sl/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: sl\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Skupaj"
|
||||
27
web_widget_x2many_2d_matrix/i18n/tr.po
Normal file
27
web_widget_x2many_2d_matrix/i18n/tr.po
Normal file
@@ -0,0 +1,27 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_widget_x2many_2d_matrix
|
||||
#
|
||||
# Translators:
|
||||
# Ahmet Altınışık <aaltinisik@altinkaya.com.tr>, 2015
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: web (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-08 21:34+0000\n"
|
||||
"PO-Revision-Date: 2015-12-30 22:00+0000\n"
|
||||
"Last-Translator: Ahmet Altınışık <aaltinisik@altinkaya.com.tr>\n"
|
||||
"Language-Team: Turkish (http://www.transifex.com/oca/OCA-web-8-0/language/tr/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: tr\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: web_widget_x2many_2d_matrix
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:11
|
||||
#: code:addons/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml:28
|
||||
#, python-format
|
||||
msgid "Total"
|
||||
msgstr "Toplam"
|
||||
@@ -1,47 +1,50 @@
|
||||
//-*- coding: utf-8 -*-
|
||||
//############################################################################
|
||||
//
|
||||
// OpenERP, Open Source Management Solution
|
||||
// This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//############################################################################
|
||||
/* Copyright 2015 Holger Brunn <hbrunn@therp.nl>
|
||||
* Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
||||
openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
{
|
||||
instance.web.form.widgets.add(
|
||||
'x2many_2d_matrix',
|
||||
'instance.web_widget_x2many_2d_matrix.FieldX2Many2dMatrix');
|
||||
instance.web_widget_x2many_2d_matrix.FieldX2Many2dMatrix = instance.web.form.FieldOne2Many.extend({
|
||||
odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var formats = require('web.formats');
|
||||
var FieldOne2Many = core.form_widget_registry.get('one2many');
|
||||
var Model = require('web.Model');
|
||||
var data = require('web.data');
|
||||
var _ = require('_');
|
||||
var $ = require('$');
|
||||
|
||||
var WidgetX2Many2dMatrix = FieldOne2Many.extend({
|
||||
template: 'FieldX2Many2dMatrix',
|
||||
widget_class: 'oe_form_field_x2many_2d_matrix',
|
||||
|
||||
// those will be filled with rows from the dataset
|
||||
by_x_axis: {},
|
||||
by_y_axis: {},
|
||||
by_id: {},
|
||||
// configuration values
|
||||
field_x_axis: 'x',
|
||||
field_label_x_axis: 'x',
|
||||
field_y_axis: 'y',
|
||||
field_label_y_axis: 'y',
|
||||
field_value: 'value',
|
||||
x_axis_clickable: true,
|
||||
y_axis_clickable: true,
|
||||
// information about our datatype
|
||||
is_numeric: false,
|
||||
show_row_totals: true,
|
||||
show_column_totals: true,
|
||||
// this will be filled with the model's fields_get
|
||||
fields: {},
|
||||
// Store fields used to fill HTML attributes
|
||||
fields_att: {},
|
||||
|
||||
parse_boolean: function(val)
|
||||
{
|
||||
if (val.toLowerCase() === 'true' || val === '1') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// read parameters
|
||||
init: function(field_manager, node)
|
||||
@@ -50,10 +53,18 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
this.field_y_axis = node.attrs.field_y_axis || this.field_y_axis;
|
||||
this.field_label_x_axis = node.attrs.field_label_x_axis || this.field_x_axis;
|
||||
this.field_label_y_axis = node.attrs.field_label_y_axis || this.field_y_axis;
|
||||
this.x_axis_clickable = this.parse_boolean(node.attrs.x_axis_clickable || '1');
|
||||
this.y_axis_clickable = this.parse_boolean(node.attrs.y_axis_clickable || '1');
|
||||
this.field_value = node.attrs.field_value || this.field_value;
|
||||
this.show_row_totals = node.attrs.show_row_totals || this.show_row_totals;
|
||||
this.show_column_totals = node.attrs.show_column_totals || this.show_column_totals;
|
||||
return this._super.apply(this, arguments);
|
||||
for (var property in node.attrs) {
|
||||
if (property.startsWith("field_att_")) {
|
||||
this.fields_att[property.substring(10)] = node.attrs[property];
|
||||
}
|
||||
}
|
||||
this.field_editability = node.attrs.field_editability || this.field_editability;
|
||||
this.show_row_totals = this.parse_boolean(node.attrs.show_row_totals || '1');
|
||||
this.show_column_totals = this.parse_boolean(node.attrs.show_column_totals || '1');
|
||||
return this._super(field_manager, node);
|
||||
},
|
||||
|
||||
// return a field's value, id in case it's a one2many field
|
||||
@@ -74,15 +85,16 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
},
|
||||
|
||||
// setup our datastructure for simple access in the template
|
||||
set_value: function()
|
||||
set_value: function(value_)
|
||||
{
|
||||
var self = this,
|
||||
result = this._super.apply(this, arguments);
|
||||
result = this._super(value_);
|
||||
|
||||
self.by_x_axis = {};
|
||||
self.by_y_axis = {};
|
||||
|
||||
return jQuery.when(result).then(function()
|
||||
self.by_id = {};
|
||||
|
||||
return $.when(result).then(function()
|
||||
{
|
||||
return self.dataset._model.call('fields_get').then(function(fields)
|
||||
{
|
||||
@@ -90,83 +102,82 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
self.is_numeric = fields[self.field_value].type == 'float';
|
||||
self.show_row_totals &= self.is_numeric;
|
||||
self.show_column_totals &= self.is_numeric;
|
||||
}).then(function()
|
||||
})
|
||||
// if there are cached writes on the parent dataset, read below
|
||||
// only returns the written data, which is not enough to properly
|
||||
// set up our data structure. Read those ids here and patch the
|
||||
// cache
|
||||
.then(function()
|
||||
{
|
||||
var ids_written = _.map(
|
||||
self.dataset.to_write, function(x) { return x.id });
|
||||
if(!ids_written.length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return (new data.Query(self.dataset._model))
|
||||
.filter([['id', 'in', ids_written]])
|
||||
.all()
|
||||
.then(function(rows)
|
||||
{
|
||||
_.each(rows, function(row)
|
||||
{
|
||||
var cache = _.find(
|
||||
self.dataset.cache,
|
||||
function(x) { return x.id == row.id }
|
||||
);
|
||||
_.extend(cache.values, row, _.clone(cache.values));
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(function()
|
||||
{
|
||||
return self.dataset.read_ids(self.dataset.ids).then(function(rows)
|
||||
{
|
||||
var read_many2one = {},
|
||||
many2one_fields = [
|
||||
self.field_x_axis, self.field_y_axis,
|
||||
self.field_label_x_axis, self.field_label_y_axis
|
||||
];
|
||||
// prepare to read many2one names if necessary (we can get (id, name) or just id as value)
|
||||
_.each(many2one_fields, function(field)
|
||||
{
|
||||
if(self.fields[field].type == 'many2one')
|
||||
{
|
||||
read_many2one[field] = {};
|
||||
}
|
||||
});
|
||||
// setup data structure
|
||||
_.each(rows, function(row)
|
||||
{
|
||||
self.add_xy_row(row);
|
||||
_.each(read_many2one, function(rows, field)
|
||||
{
|
||||
if(!_.isArray(row[field]))
|
||||
{
|
||||
rows[row[field]] = rows[row[field]] || []
|
||||
rows[row[field]].push(row);
|
||||
}
|
||||
});
|
||||
});
|
||||
// read many2one fields if necessary
|
||||
var deferrends = [];
|
||||
_.each(read_many2one, function(rows, field)
|
||||
{
|
||||
if(_.isEmpty(rows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var model = new instance.web.Model(self.fields[field].relation);
|
||||
deferrends.push(model.call(
|
||||
'name_get',
|
||||
[_.map(_.keys(rows), function(key) {return parseInt(key)})])
|
||||
.then(function(names)
|
||||
{
|
||||
_.each(names, function(name)
|
||||
{
|
||||
_.each(rows[name[0]], function(row)
|
||||
{
|
||||
row[field] = name;
|
||||
});
|
||||
});
|
||||
}));
|
||||
})
|
||||
if(self.is_started && !self.no_rerender)
|
||||
{
|
||||
self.renderElement();
|
||||
self.compute_totals();
|
||||
self.setup_many2one_axes();
|
||||
self.$el.find('.edit').on(
|
||||
'change', self.proxy(self.xy_value_change));
|
||||
'change', self.proxy(self.xy_value_change));
|
||||
self.effective_readonly_change();
|
||||
}
|
||||
return jQuery.when.apply(jQuery, deferrends);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// to whatever needed to setup internal data structure
|
||||
// do whatever needed to setup internal data structure
|
||||
add_xy_row: function(row)
|
||||
{
|
||||
var x = this.get_field_value(row, this.field_x_axis),
|
||||
y = this.get_field_value(row, this.field_y_axis);
|
||||
// row is a *copy* of a row in dataset.cache, fetch
|
||||
// a reference to this row in order to have the
|
||||
// internal data structure point to the same data
|
||||
// the dataset manipulates
|
||||
_.every(this.dataset.cache, function(cached_row)
|
||||
{
|
||||
if(cached_row.id == row.id)
|
||||
{
|
||||
row = cached_row.values;
|
||||
// new rows don't have that
|
||||
row.id = cached_row.id;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
this.by_x_axis[x] = this.by_x_axis[x] || {};
|
||||
this.by_y_axis[y] = this.by_y_axis[y] || {};
|
||||
this.by_x_axis[x][y] = row;
|
||||
this.by_y_axis[y][x] = row;
|
||||
this.by_id[row.id] = row;
|
||||
},
|
||||
|
||||
// get x axis values in the correct order
|
||||
@@ -214,6 +225,20 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
return this.by_x_axis[x][y]['id'];
|
||||
},
|
||||
|
||||
get_xy_att: function(x, y)
|
||||
{
|
||||
var vals = {};
|
||||
for (var att in this.fields_att) {
|
||||
var val = this.get_field_value(
|
||||
this.by_x_axis[x][y], this.fields_att[att]);
|
||||
// Discard empty values
|
||||
if (val) {
|
||||
vals[att] = val;
|
||||
}
|
||||
}
|
||||
return vals;
|
||||
},
|
||||
|
||||
// return the value of a coordinate
|
||||
get_xy_value: function(x, y)
|
||||
{
|
||||
@@ -238,14 +263,14 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
// parse a value from user input
|
||||
parse_xy_value: function(val)
|
||||
{
|
||||
return instance.web.parse_value(
|
||||
return formats.parse_value(
|
||||
val, {'type': this.fields[this.field_value].type});
|
||||
},
|
||||
|
||||
// format a value from the database for display
|
||||
format_xy_value: function(val)
|
||||
{
|
||||
return instance.web.format_value(
|
||||
return formats.format_value(
|
||||
val, {'type': this.fields[this.field_value].type});
|
||||
},
|
||||
|
||||
@@ -255,51 +280,50 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
var self = this,
|
||||
grand_total = 0,
|
||||
totals_x = {},
|
||||
totals_y = {};
|
||||
return self.dataset.read_ids(self.dataset.ids).then(function(rows)
|
||||
totals_y = {},
|
||||
rows = this.by_id,
|
||||
deferred = $.Deferred();
|
||||
_.each(rows, function(row)
|
||||
{
|
||||
_.each(rows, function(row)
|
||||
{
|
||||
var key_x = self.get_field_value(row, self.field_x_axis),
|
||||
key_y = self.get_field_value(row, self.field_y_axis);
|
||||
totals_x[key_x] = (totals_x[key_x] || 0) + self.get_field_value(row, self.field_value);
|
||||
totals_y[key_y] = (totals_y[key_y] || 0) + self.get_field_value(row, self.field_value);
|
||||
grand_total += self.get_field_value(row, self.field_value);
|
||||
});
|
||||
}).then(function()
|
||||
{
|
||||
_.each(totals_y, function(total, y)
|
||||
{
|
||||
self.$el.find(
|
||||
_.str.sprintf('td.row_total[data-y="%s"]', y)).text(
|
||||
self.format_xy_value(total));
|
||||
});
|
||||
_.each(totals_x, function(total, x)
|
||||
{
|
||||
self.$el.find(
|
||||
_.str.sprintf('td.column_total[data-x="%s"]', x)).text(
|
||||
self.format_xy_value(total));
|
||||
});
|
||||
self.$el.find('.grand_total').text(
|
||||
self.format_xy_value(grand_total))
|
||||
return {
|
||||
totals_x: totals_x,
|
||||
totals_y: totals_y,
|
||||
grand_total: grand_total,
|
||||
};
|
||||
var key_x = self.get_field_value(row, self.field_x_axis),
|
||||
key_y = self.get_field_value(row, self.field_y_axis);
|
||||
totals_x[key_x] = (totals_x[key_x] || 0) + self.get_field_value(row, self.field_value);
|
||||
totals_y[key_y] = (totals_y[key_y] || 0) + self.get_field_value(row, self.field_value);
|
||||
grand_total += self.get_field_value(row, self.field_value);
|
||||
});
|
||||
_.each(totals_y, function(total, y)
|
||||
{
|
||||
self.$el.find(
|
||||
_.str.sprintf('td.row_total[data-y="%s"]', y)).text(
|
||||
self.format_xy_value(total));
|
||||
});
|
||||
_.each(totals_x, function(total, x)
|
||||
{
|
||||
self.$el.find(
|
||||
_.str.sprintf('td.column_total[data-x="%s"]', x)).text(
|
||||
self.format_xy_value(total));
|
||||
});
|
||||
self.$el.find('.grand_total').text(
|
||||
self.format_xy_value(grand_total))
|
||||
deferred.resolve({
|
||||
totals_x: totals_x,
|
||||
totals_y: totals_y,
|
||||
grand_total: grand_total,
|
||||
rows: rows,
|
||||
});
|
||||
return deferred;
|
||||
},
|
||||
|
||||
setup_many2one_axes: function()
|
||||
{
|
||||
if(this.fields[this.field_x_axis].type == 'many2one')
|
||||
if(this.fields[this.field_x_axis].type == 'many2one' && this.x_axis_clickable)
|
||||
{
|
||||
this.$el.find('th[data-x]').addClass('oe_link')
|
||||
.click(_.partial(
|
||||
this.proxy(this.many2one_axis_click),
|
||||
this.field_x_axis, 'x'));
|
||||
}
|
||||
if(this.fields[this.field_y_axis].type == 'many2one')
|
||||
if(this.fields[this.field_y_axis].type == 'many2one' && this.y_axis_clickable)
|
||||
{
|
||||
this.$el.find('tr[data-y] th').addClass('oe_link')
|
||||
.click(_.partial(
|
||||
@@ -314,7 +338,7 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
type: 'ir.actions.act_window',
|
||||
name: this.fields[field].string,
|
||||
res_model: this.fields[field].relation,
|
||||
res_id: jQuery(e.currentTarget).data(id_attribute),
|
||||
res_id: $(e.currentTarget).data(id_attribute),
|
||||
views: [[false, 'form']],
|
||||
target: 'current',
|
||||
})
|
||||
@@ -330,12 +354,12 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
this.on("change:effective_readonly",
|
||||
this, this.proxy(this.effective_readonly_change));
|
||||
this.effective_readonly_change();
|
||||
return this._super.apply(this, arguments);
|
||||
return this._super();
|
||||
},
|
||||
|
||||
xy_value_change: function(e)
|
||||
{
|
||||
var $this = jQuery(e.currentTarget),
|
||||
var $this = $(e.currentTarget),
|
||||
val = $this.val();
|
||||
if(this.validate_xy_value(val))
|
||||
{
|
||||
@@ -372,9 +396,20 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||
return this.$el.find('.oe_form_invalid').length == 0;
|
||||
},
|
||||
|
||||
// deactivate view related functions
|
||||
load_views: function() {},
|
||||
reload_current_view: function() {},
|
||||
get_active_view: function() {},
|
||||
load_views: function() {
|
||||
// Needed for removing the initial empty tree view when the widget
|
||||
// is loaded
|
||||
var self = this,
|
||||
result = this._super();
|
||||
|
||||
return $.when(result).then(function()
|
||||
{
|
||||
self.renderElement();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
core.form_widget_registry.add('x2many_2d_matrix', WidgetX2Many2dMatrix);
|
||||
|
||||
return WidgetX2Many2dMatrix;
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<th><t t-esc="widget.get_y_axis_label(y)" /></th>
|
||||
<td t-foreach="widget.get_x_axis_values()" t-as="x" t-att-class="'oe_list_field_cell' + (widget.is_numeric ? ' oe_number' : '')" t-att-data-x="x">
|
||||
<span t-att-class="widget.get_xy_value_class()">
|
||||
<input class="edit" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" />
|
||||
<input class="edit" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" t-att="widget.get_xy_att(x, y)"/>
|
||||
<span class="read"><t t-esc="widget.format_xy_value(widget.get_xy_value(x, y))" /></span>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user