Browse Source

[11][MIG] web_widget_x2many_2d_matrix WIP

pull/1106/head
Artem Kostyuk 7 years ago
committed by Jairo Llopis
parent
commit
48f1dc3a6f
  1. 6
      web_widget_x2many_2d_matrix/README.rst
  2. 1
      web_widget_x2many_2d_matrix/__init__.py
  3. 5
      web_widget_x2many_2d_matrix/__manifest__.py
  4. 4
      web_widget_x2many_2d_matrix/i18n/lt.po
  5. 4
      web_widget_x2many_2d_matrix/i18n/nl_NL.po
  6. 65
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

6
web_widget_x2many_2d_matrix/README.rst

@ -80,7 +80,7 @@ field_att_<name>
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/8.0
:target: https://runbot.odoo-community.org/runbot/162/11.0
Example Example
======= =======
@ -104,6 +104,7 @@ the field in the default function::
users = self.env['res.users'].browse([1, 2, 3]) users = self.env['res.users'].browse([1, 2, 3])
return [ return [
(0, 0, { (0, 0, {
'name': 'Sample task name',
'project_id': p.id, 'project_id': p.id,
'user_id': u.id, 'user_id': u.id,
'planned_hours': 0, 'planned_hours': 0,
@ -158,7 +159,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues>`_. In case of trouble, please <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, 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.
help us smash it by providing a detailed and welcomed feedback.
Credits Credits
======= =======
@ -168,6 +169,7 @@ Contributors
* Holger Brunn <hbrunn@therp.nl> * Holger Brunn <hbrunn@therp.nl>
* Pedro M. Baeza <pedro.baeza@tecnativa.com> * Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Artem Kostyuk <a.kostyuk@mobilunity.com>
Maintainer Maintainer
---------- ----------

1
web_widget_x2many_2d_matrix/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution

5
web_widget_x2many_2d_matrix/__manifest__.py

@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Holger Brunn <hbrunn@therp.nl> # Copyright 2015 Holger Brunn <hbrunn@therp.nl>
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> # Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "2D matrix for x2many fields", "name": "2D matrix for x2many fields",
"version": "10.0.1.0.1",
"version": "11.0.1.0.0",
"author": "Therp BV, " "author": "Therp BV, "
"Tecnativa, " "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3", "license": "AGPL-3",
"category": "Hidden/Dependency", "category": "Hidden/Dependency",
"summary": "Show list fields as a matrix", "summary": "Show list fields as a matrix",

4
web_widget_x2many_2d_matrix/i18n/lt.po

@ -6,10 +6,10 @@
# Viktoras Norkus <viktoras@bmx.lt>, 2018 # Viktoras Norkus <viktoras@bmx.lt>, 2018
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-25 01:58+0000\n" "POT-Creation-Date: 2018-01-25 01:58+0000\n"
"PO-Revision-Date: 2018-01-25 01:58+0000\n"
"PO-Revision-Date: 2018-02-15 12:40+0200\n"
"Last-Translator: Viktoras Norkus <viktoras@bmx.lt>, 2018\n" "Last-Translator: Viktoras Norkus <viktoras@bmx.lt>, 2018\n"
"Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n" "Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

4
web_widget_x2many_2d_matrix/i18n/nl_NL.po

@ -6,10 +6,10 @@
# Peter Hageman <hageman.p@gmail.com>, 2017 # Peter Hageman <hageman.p@gmail.com>, 2017
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-03 03:50+0000\n" "POT-Creation-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2018-02-15 12:39+0200\n"
"Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n" "Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n"
"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

65
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -6,13 +6,15 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
"use strict"; "use strict";
var core = require('web.core'); var core = require('web.core');
var formats = require('web.formats');
var FieldOne2Many = core.form_widget_registry.get('one2many');
var Model = require('web.Model');
var FieldManagerMixin = require('web.FieldManagerMixin');
var Widget = require('web.Widget');
var fieldRegistry = require('web.field_registry');
var widgetRegistry = require('web.widget_registry');
var widgetOne2many = widgetRegistry.get('one2many');
var data = require('web.data'); var data = require('web.data');
var $ = require('jquery'); var $ = require('jquery');
var WidgetX2Many2dMatrix = FieldOne2Many.extend({
var WidgetX2Many2dMatrix = widgetOne2Many.extend(FieldManagerMixin, {
template: 'FieldX2Many2dMatrix', template: 'FieldX2Many2dMatrix',
widget_class: 'oe_form_field_x2many_2d_matrix', widget_class: 'oe_form_field_x2many_2d_matrix',
@ -46,28 +48,39 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
}, },
// read parameters // read parameters
init: function(field_manager, node)
{
this.field_x_axis = node.attrs.field_x_axis || this.field_x_axis;
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;
for (var property in node.attrs) {
init: function (parent, fieldname, record, therest) {
var res = this._super(parent, fieldname, record, therest);
FieldManagerMixin.init.call(this);
var node = record.fieldsInfo[therest.viewType][fieldname];
this.field_x_axis = node.field_x_axis || this.field_x_axis;
this.field_y_axis = node.field_y_axis || this.field_y_axis;
this.field_label_x_axis = node.field_label_x_axis || this.field_x_axis;
this.field_label_y_axis = node.field_label_y_axis || this.field_y_axis;
this.x_axis_clickable = this.parse_boolean(node.x_axis_clickable || '1');
this.y_axis_clickable = this.parse_boolean(node.y_axis_clickable || '1');
this.field_value = node.field_value || this.field_value;
for (var property in node) {
if (property.startsWith("field_att_")) { if (property.startsWith("field_att_")) {
this.fields_att[property.substring(10)] = node.attrs[property];
this.fields_att[property.substring(10)] = node[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);
this.field_editability = node.field_editability || this.field_editability;
this.show_row_totals = this.parse_boolean(node.show_row_totals || '1');
this.show_column_totals = this.parse_boolean(node.show_column_totals || '1');
this.init_fields();
// this.set_value(undefined);
return res;
},
init_fields: function() {
return;
}, },
// return a field's value, id in case it's a one2many field // return a field's value, id in case it's a one2many field
get_field_value: function(row, field, many2one_as_name) get_field_value: function(row, field, many2one_as_name)
// FIXME looks silly
{ {
if(this.fields[field].type == 'many2one' && _.isArray(row[field])) if(this.fields[field].type == 'many2one' && _.isArray(row[field]))
{ {
@ -262,15 +275,13 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
// parse a value from user input // parse a value from user input
parse_xy_value: function(val) parse_xy_value: function(val)
{ {
return formats.parse_value(
val, {'type': this.fields[this.field_value].type});
return val;
}, },
// format a value from the database for display // format a value from the database for display
format_xy_value: function(val) format_xy_value: function(val)
{ {
return formats.format_value(
val, {'type': this.fields[this.field_value].type});
return val;
}, },
// compute totals // compute totals
@ -412,7 +423,11 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
}, },
}); });
core.form_widget_registry.add('x2many_2d_matrix', WidgetX2Many2dMatrix);
fieldRegistry.add(
'x2many_2d_matrix', WidgetX2Many2dMatrix
);
return WidgetX2Many2dMatrix;
return {
WidgetX2Many2dMatrix: WidgetX2Many2dMatrix
};
}); });
Loading…
Cancel
Save