mirror of https://github.com/OCA/web.git
[IMP] web_widget_one2many_tree_line_duplicate: black, isort, prettier
parent
7d26b76227
commit
4699632736
|
@ -0,0 +1 @@
|
|||
../../../../web_widget_one2many_tree_line_duplicate
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -1,24 +1,20 @@
|
|||
/* Copyright 2021 Tecnativa - Alexandre Díaz
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(require) {
|
||||
odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function (require) {
|
||||
"use strict";
|
||||
|
||||
const BasicModel = require("web.BasicModel");
|
||||
|
||||
function dateToServer(date) {
|
||||
return date
|
||||
.clone()
|
||||
.utc()
|
||||
.locale("en")
|
||||
.format("YYYY-MM-DD HH:mm:ss");
|
||||
return date.clone().utc().locale("en").format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
||||
BasicModel.include({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_applyChange: function(recordID, changes) {
|
||||
_applyChange: function (recordID, changes) {
|
||||
// The normal way is to have only one change with the 'CLONE' operation
|
||||
// but to ensure that "omitOnchange" is used we check that almost one change
|
||||
// is a 'CLONE' operation.
|
||||
|
@ -39,7 +35,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
*
|
||||
* @override
|
||||
*/
|
||||
_applyX2ManyChange: function(record, fieldName, command) {
|
||||
_applyX2ManyChange: function (record, fieldName, command) {
|
||||
if (command.operation === "CLONE") {
|
||||
return this._applyX2ManyChangeOmitOnchange.apply(this, arguments);
|
||||
}
|
||||
|
@ -55,7 +51,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
* @param {Object} options
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_applyX2ManyChangeOmitOnchange: function(record, fieldName, command, options) {
|
||||
_applyX2ManyChangeOmitOnchange: function (record, fieldName, command, options) {
|
||||
var localID =
|
||||
(record._changes && record._changes[fieldName]) ||
|
||||
record.data[fieldName];
|
||||
|
@ -85,7 +81,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
const record_state = this.get(command.id);
|
||||
const clone_values = this._getValuesToClone(record_state);
|
||||
return this._makeDefaultRecordOmitOnchange(list.model, params, clone_values)
|
||||
.then(id => {
|
||||
.then((id) => {
|
||||
var ids = [id];
|
||||
list._changes = list._changes || [];
|
||||
list._changes.push({
|
||||
|
@ -104,7 +100,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
}
|
||||
return ids;
|
||||
})
|
||||
.then(ids => {
|
||||
.then((ids) => {
|
||||
this._readUngroupedList(list).then(() => {
|
||||
var x2ManysDef = this._fetchX2ManysBatched(list);
|
||||
var referencesDef = this._fetchReferencesBatched(list);
|
||||
|
@ -122,7 +118,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
* @param {Object} options
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_applyChangeOmitOnchange: function(recordID, changes, options) {
|
||||
_applyChangeOmitOnchange: function (recordID, changes, options) {
|
||||
var record = this.localData[recordID];
|
||||
var field = false;
|
||||
var defs = [];
|
||||
|
@ -169,7 +165,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
* @param {Object} values
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_makeDefaultRecordOmitOnchange: function(modelName, params, values) {
|
||||
_makeDefaultRecordOmitOnchange: function (modelName, params, values) {
|
||||
const targetView = params.viewType;
|
||||
let fields = params.fields;
|
||||
const fieldsInfo = params.fieldsInfo;
|
||||
|
@ -238,7 +234,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
* @param {Object} line_state
|
||||
* @returns {Object}
|
||||
*/
|
||||
_getValuesToClone: function(line_state) {
|
||||
_getValuesToClone: function (line_state) {
|
||||
const values_to_clone = {};
|
||||
const line_data = line_state.data;
|
||||
for (const field_name in line_data) {
|
||||
|
@ -259,7 +255,7 @@ odoo.define("web_widget_one2many_tree_line_duplicate.BasicModel", function(requi
|
|||
field_info.type === "many2many" ||
|
||||
field_info.type === "one2many"
|
||||
) {
|
||||
values_to_clone[field_name] = _.map(value.data || [], item => {
|
||||
values_to_clone[field_name] = _.map(value.data || [], (item) => {
|
||||
return item.data.id;
|
||||
});
|
||||
} else if (
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
odoo.define(
|
||||
"web_widget_one2many_tree_line_duplicate.One2manyTreeLineDuplicate",
|
||||
function(require) {
|
||||
function (require) {
|
||||
"use strict";
|
||||
|
||||
const core = require("web.core");
|
||||
|
@ -20,7 +20,7 @@ odoo.define(
|
|||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function(parent) {
|
||||
init: function (parent) {
|
||||
this._super.apply(this, arguments);
|
||||
let allow_clone =
|
||||
parent.attrs &&
|
||||
|
@ -38,7 +38,7 @@ odoo.define(
|
|||
* @private
|
||||
* @override
|
||||
*/
|
||||
_renderHeader: function() {
|
||||
_renderHeader: function () {
|
||||
var $thead = this._super.apply(this, arguments);
|
||||
if (this.addCloneIcon) {
|
||||
$thead
|
||||
|
@ -52,7 +52,7 @@ odoo.define(
|
|||
* @override
|
||||
* @private
|
||||
*/
|
||||
_renderFooter: function() {
|
||||
_renderFooter: function () {
|
||||
const $footer = this._super.apply(this, arguments);
|
||||
if (this.addCloneIcon) {
|
||||
$footer.find("tr").append($("<td>"));
|
||||
|
@ -66,7 +66,7 @@ odoo.define(
|
|||
* @private
|
||||
* @override
|
||||
*/
|
||||
_renderRow: function(record, index) {
|
||||
_renderRow: function (record, index) {
|
||||
const $row = this._super.apply(this, arguments);
|
||||
if (this.addCloneIcon) {
|
||||
const $icon = $("<button>", {
|
||||
|
@ -84,7 +84,7 @@ odoo.define(
|
|||
* @private
|
||||
* @override
|
||||
*/
|
||||
_getNumberOfCols: function() {
|
||||
_getNumberOfCols: function () {
|
||||
var n = this._super();
|
||||
if (this.addCloneIcon) {
|
||||
n++;
|
||||
|
@ -97,7 +97,7 @@ odoo.define(
|
|||
*
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onCloneIconClick: function(ev) {
|
||||
_onCloneIconClick: function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var $row = $(ev.target).closest("tr");
|
||||
|
@ -121,7 +121,7 @@ odoo.define(
|
|||
/**
|
||||
* @param {CustomEvent} ev
|
||||
*/
|
||||
_onCloneRecord: function(ev) {
|
||||
_onCloneRecord: function (ev) {
|
||||
const data = ev.data || {};
|
||||
ev.stopPropagation();
|
||||
if (!this.cloningRecord && this.activeActions.create) {
|
||||
|
|
Loading…
Reference in New Issue