Skip to content

Commit 75f7975

Browse files
Artem Kostyuksimahawk
authored andcommitted
[11][MIG] web_widget_x2many_2d_matrix WIP
1 parent df0bca0 commit 75f7975

File tree

6 files changed

+51
-36
lines changed

6 files changed

+51
-36
lines changed

web_widget_x2many_2d_matrix/README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ field_att_<name>
8080

8181
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
8282
:alt: Try me on Runbot
83-
:target: https://runbot.odoo-community.org/runbot/162/8.0
83+
:target: https://runbot.odoo-community.org/runbot/162/11.0
8484

8585
Example
8686
=======
@@ -104,6 +104,7 @@ the field in the default function::
104104
users = self.env['res.users'].browse([1, 2, 3])
105105
return [
106106
(0, 0, {
107+
'name': 'Sample task name',
107108
'project_id': p.id,
108109
'user_id': u.id,
109110
'planned_hours': 0,
@@ -158,7 +159,7 @@ Bug Tracker
158159
Bugs are tracked on `GitHub Issues
159160
<https://github.com/OCA/web/issues>`_. In case of trouble, please
160161
check there if your issue has already been reported. If you spotted it first,
161-
help us smashing it by providing a detailed and welcomed feedback.
162+
help us smash it by providing a detailed and welcomed feedback.
162163

163164
Credits
164165
=======
@@ -168,6 +169,7 @@ Contributors
168169

169170
* Holger Brunn <hbrunn@therp.nl>
170171
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
172+
* Artem Kostyuk <a.kostyuk@mobilunity.com>
171173

172174
Maintainer
173175
----------

web_widget_x2many_2d_matrix/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
##############################################################################
32
#
43
# OpenERP, Open Source Management Solution

web_widget_x2many_2d_matrix/__manifest__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2015 Holger Brunn <hbrunn@therp.nl>
32
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
43
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5-
64
{
75
"name": "2D matrix for x2many fields",
8-
"version": "10.0.1.0.1",
6+
"version": "11.0.1.0.0",
97
"author": "Therp BV, "
10-
"Tecnativa,"
8+
"Tecnativa, "
119
"Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/web",
1211
"license": "AGPL-3",
1312
"category": "Hidden/Dependency",
1413
"summary": "Show list fields as a matrix",

web_widget_x2many_2d_matrix/i18n/lt.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# Viktoras Norkus <viktoras@bmx.lt>, 2018
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: Odoo Server 10.0\n"
9+
"Project-Id-Version: Odoo Server 11.0\n"
1010
"Report-Msgid-Bugs-To: \n"
1111
"POT-Creation-Date: 2018-01-25 01:58+0000\n"
12-
"PO-Revision-Date: 2018-01-25 01:58+0000\n"
12+
"PO-Revision-Date: 2018-02-15 12:40+0200\n"
1313
"Last-Translator: Viktoras Norkus <viktoras@bmx.lt>, 2018\n"
1414
"Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n"
1515
"MIME-Version: 1.0\n"

web_widget_x2many_2d_matrix/i18n/nl_NL.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# Peter Hageman <hageman.p@gmail.com>, 2017
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: Odoo Server 10.0\n"
9+
"Project-Id-Version: Odoo Server 11.0\n"
1010
"Report-Msgid-Bugs-To: \n"
1111
"POT-Creation-Date: 2018-01-03 03:50+0000\n"
12-
"PO-Revision-Date: 2018-01-03 03:50+0000\n"
12+
"PO-Revision-Date: 2018-02-15 12:39+0200\n"
1313
"Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n"
1414
"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n"
1515
"MIME-Version: 1.0\n"

web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
66
"use strict";
77

88
var core = require('web.core');
9-
var formats = require('web.formats');
10-
var FieldOne2Many = core.form_widget_registry.get('one2many');
11-
var Model = require('web.Model');
9+
var FieldManagerMixin = require('web.FieldManagerMixin');
10+
var Widget = require('web.Widget');
11+
var fieldRegistry = require('web.field_registry');
12+
var widgetRegistry = require('web.widget_registry');
13+
var widgetOne2many = widgetRegistry.get('one2many');
1214
var data = require('web.data');
1315
var $ = require('jquery');
1416

15-
var WidgetX2Many2dMatrix = FieldOne2Many.extend({
17+
var WidgetX2Many2dMatrix = widgetOne2Many.extend(FieldManagerMixin, {
1618
template: 'FieldX2Many2dMatrix',
1719
widget_class: 'oe_form_field_x2many_2d_matrix',
1820

@@ -46,28 +48,39 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
4648
},
4749

4850
// read parameters
49-
init: function(field_manager, node)
50-
{
51-
this.field_x_axis = node.attrs.field_x_axis || this.field_x_axis;
52-
this.field_y_axis = node.attrs.field_y_axis || this.field_y_axis;
53-
this.field_label_x_axis = node.attrs.field_label_x_axis || this.field_x_axis;
54-
this.field_label_y_axis = node.attrs.field_label_y_axis || this.field_y_axis;
55-
this.x_axis_clickable = this.parse_boolean(node.attrs.x_axis_clickable || '1');
56-
this.y_axis_clickable = this.parse_boolean(node.attrs.y_axis_clickable || '1');
57-
this.field_value = node.attrs.field_value || this.field_value;
58-
for (var property in node.attrs) {
51+
init: function (parent, fieldname, record, therest) {
52+
var res = this._super(parent, fieldname, record, therest);
53+
FieldManagerMixin.init.call(this);
54+
var node = record.fieldsInfo[therest.viewType][fieldname];
55+
56+
this.field_x_axis = node.field_x_axis || this.field_x_axis;
57+
this.field_y_axis = node.field_y_axis || this.field_y_axis;
58+
this.field_label_x_axis = node.field_label_x_axis || this.field_x_axis;
59+
this.field_label_y_axis = node.field_label_y_axis || this.field_y_axis;
60+
this.x_axis_clickable = this.parse_boolean(node.x_axis_clickable || '1');
61+
this.y_axis_clickable = this.parse_boolean(node.y_axis_clickable || '1');
62+
this.field_value = node.field_value || this.field_value;
63+
for (var property in node) {
5964
if (property.startsWith("field_att_")) {
60-
this.fields_att[property.substring(10)] = node.attrs[property];
65+
this.fields_att[property.substring(10)] = node[property];
6166
}
6267
}
63-
this.field_editability = node.attrs.field_editability || this.field_editability;
64-
this.show_row_totals = this.parse_boolean(node.attrs.show_row_totals || '1');
65-
this.show_column_totals = this.parse_boolean(node.attrs.show_column_totals || '1');
66-
return this._super(field_manager, node);
68+
this.field_editability = node.field_editability || this.field_editability;
69+
this.show_row_totals = this.parse_boolean(node.show_row_totals || '1');
70+
this.show_column_totals = this.parse_boolean(node.show_column_totals || '1');
71+
this.init_fields();
72+
// this.set_value(undefined);
73+
74+
return res;
75+
},
76+
77+
init_fields: function() {
78+
return;
6779
},
6880

6981
// return a field's value, id in case it's a one2many field
7082
get_field_value: function(row, field, many2one_as_name)
83+
// FIXME looks silly
7184
{
7285
if(this.fields[field].type == 'many2one' && _.isArray(row[field]))
7386
{
@@ -262,15 +275,13 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
262275
// parse a value from user input
263276
parse_xy_value: function(val)
264277
{
265-
return formats.parse_value(
266-
val, {'type': this.fields[this.field_value].type});
278+
return val;
267279
},
268280

269281
// format a value from the database for display
270282
format_xy_value: function(val)
271283
{
272-
return formats.format_value(
273-
val, {'type': this.fields[this.field_value].type});
284+
return val;
274285
},
275286

276287
// compute totals
@@ -412,7 +423,11 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
412423
},
413424
});
414425

415-
core.form_widget_registry.add('x2many_2d_matrix', WidgetX2Many2dMatrix);
426+
fieldRegistry.add(
427+
'x2many_2d_matrix', WidgetX2Many2dMatrix
428+
);
416429

417-
return WidgetX2Many2dMatrix;
430+
return {
431+
WidgetX2Many2dMatrix: WidgetX2Many2dMatrix
432+
};
418433
});

0 commit comments

Comments
 (0)