diff --git a/web_widget_x2many_2d_matrix/README.rst b/web_widget_x2many_2d_matrix/README.rst index d81d100c..6fb555b9 100644 --- a/web_widget_x2many_2d_matrix/README.rst +++ b/web_widget_x2many_2d_matrix/README.rst @@ -80,7 +80,7 @@ field_att_ .. 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 + :target: https://runbot.odoo-community.org/runbot/162/11.0 Example ======= @@ -104,6 +104,7 @@ the field in the default function:: users = self.env['res.users'].browse([1, 2, 3]) return [ (0, 0, { + 'name': 'Sample task name', 'project_id': p.id, 'user_id': u.id, 'planned_hours': 0, @@ -158,7 +159,7 @@ 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. +help us smash it by providing a detailed and welcomed feedback. Credits ======= @@ -168,6 +169,7 @@ Contributors * Holger Brunn * Pedro M. Baeza +* Artem Kostyuk Maintainer ---------- diff --git a/web_widget_x2many_2d_matrix/__init__.py b/web_widget_x2many_2d_matrix/__init__.py index faef9dac..919541c6 100644 --- a/web_widget_x2many_2d_matrix/__init__.py +++ b/web_widget_x2many_2d_matrix/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution diff --git a/web_widget_x2many_2d_matrix/__manifest__.py b/web_widget_x2many_2d_matrix/__manifest__.py index 69b703cd..41f69a75 100644 --- a/web_widget_x2many_2d_matrix/__manifest__.py +++ b/web_widget_x2many_2d_matrix/__manifest__.py @@ -1,14 +1,13 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Holger Brunn # Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - { "name": "2D matrix for x2many fields", - "version": "10.0.1.0.1", + "version": "11.0.1.0.0", "author": "Therp BV, " - "Tecnativa," + "Tecnativa, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", "license": "AGPL-3", "category": "Hidden/Dependency", "summary": "Show list fields as a matrix", diff --git a/web_widget_x2many_2d_matrix/i18n/lt.po b/web_widget_x2many_2d_matrix/i18n/lt.po index d9620d98..57a65fc5 100644 --- a/web_widget_x2many_2d_matrix/i18n/lt.po +++ b/web_widget_x2many_2d_matrix/i18n/lt.po @@ -6,10 +6,10 @@ # Viktoras Norkus , 2018 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \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 , 2018\n" "Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n" "MIME-Version: 1.0\n" diff --git a/web_widget_x2many_2d_matrix/i18n/nl_NL.po b/web_widget_x2many_2d_matrix/i18n/nl_NL.po index 27efab7f..e1fde063 100644 --- a/web_widget_x2many_2d_matrix/i18n/nl_NL.po +++ b/web_widget_x2many_2d_matrix/i18n/nl_NL.po @@ -6,10 +6,10 @@ # Peter Hageman , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \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 , 2017\n" "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" "MIME-Version: 1.0\n" diff --git a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js index ec88f1ea..2c0a0cd9 100644 --- a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js +++ b/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"; 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 $ = require('jquery'); - var WidgetX2Many2dMatrix = FieldOne2Many.extend({ + var WidgetX2Many2dMatrix = widgetOne2Many.extend(FieldManagerMixin, { template: 'FieldX2Many2dMatrix', widget_class: 'oe_form_field_x2many_2d_matrix', @@ -46,28 +48,39 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) { }, // 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_")) { - 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 get_field_value: function(row, field, many2one_as_name) + // FIXME looks silly { 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_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_xy_value: function(val) { - return formats.format_value( - val, {'type': this.fields[this.field_value].type}); + return val; }, // 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 + }; });