mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot_merge: update freeze wizard widget for 17.0
It was all borken and the web client couldn't even load. The logic is basically the same, except the new client doesn't support forcing onchanges maybe, so we need to `read()` the entire thing if the form is not modified.
This commit is contained in:
parent
36786d51c8
commit
99ae369d69
@ -26,7 +26,7 @@
|
|||||||
],
|
],
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'runbot_merge/static/scss/runbot_merge_backend.scss',
|
'runbot_merge/static/scss/runbot_merge_backend.scss',
|
||||||
'runbot_merge/static/project_freeze/index.js',
|
'runbot_merge/static/src/project_freeze/index.js',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'post_load': 'enable_sentry',
|
'post_load': 'enable_sentry',
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
odoo.define('runbot_merge.index', function (require) {
|
|
||||||
"use strict";
|
|
||||||
const FormController = require('web.FormController');
|
|
||||||
const FormView = require('web.FormView');
|
|
||||||
const viewRegistry = require('web.view_registry');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attept at a "smart" controller for the freeze wizard: keeps triggering
|
|
||||||
* onchange() on the form in order to try and update the error information, as
|
|
||||||
* some of the "errors" are not under direct operator control. Hopefully this
|
|
||||||
* allows the operator to just keep the wizard open and wait until the error
|
|
||||||
* messages disappear so they can proceed.
|
|
||||||
*/
|
|
||||||
const FreezeController = FormController.extend({
|
|
||||||
async _checkState() {
|
|
||||||
const record = this.model.get(this.handle)
|
|
||||||
const requiredPrIds = record.data.required_pr_ids;
|
|
||||||
|
|
||||||
// we're inside the form's mutex, so can use `_applyChange` directly
|
|
||||||
const changed = await this.model._applyChange(this.handle, {
|
|
||||||
required_pr_ids: {
|
|
||||||
operation: 'REPLACE_WITH',
|
|
||||||
ids: requiredPrIds.res_ids,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// not sure why we need to wait for the round *after* the error update
|
|
||||||
// notification, but even debouncing the rest of the method is not
|
|
||||||
// sufficient (so it's not just a problem of being behind the mutex,
|
|
||||||
// there's something wonky going on)
|
|
||||||
if (!this._updateNext) {
|
|
||||||
this._updateNext = changed.includes('errors');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._updateNext = false;
|
|
||||||
for(const p of requiredPrIds.data) {
|
|
||||||
this.renderer.updateState(p.id, {fieldNames: ['state_color']});
|
|
||||||
}
|
|
||||||
this.renderer.updateState(record, {fieldNames: ['errors', 'required_pr_ids']});
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
*/
|
|
||||||
async start(...args) {
|
|
||||||
const checker = async () => {
|
|
||||||
if (this.isDestroyed()) { return; }
|
|
||||||
await this.model.mutex.exec(() => this._checkState());
|
|
||||||
setTimeout(checker, 1000);
|
|
||||||
};
|
|
||||||
const started = await this._super(...args);
|
|
||||||
const _ = checker();
|
|
||||||
return started;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
viewRegistry.add('freeze_wizard', FormView.extend({
|
|
||||||
config: Object.assign({}, FormView.prototype.config, {
|
|
||||||
Controller: FreezeController,
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
36
runbot_merge/static/src/project_freeze/index.js
Normal file
36
runbot_merge/static/src/project_freeze/index.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/** @odoo-module */
|
||||||
|
|
||||||
|
import {useEffect} from "@odoo/owl";
|
||||||
|
import {x2ManyCommands} from "@web/core/orm_service";
|
||||||
|
import {registry} from "@web/core/registry";
|
||||||
|
import {FormController} from "@web/views/form/form_controller";
|
||||||
|
import {formView} from "@web/views/form/form_view";
|
||||||
|
|
||||||
|
class FreezeController extends FormController {
|
||||||
|
setup() {
|
||||||
|
super.setup();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(async () => {
|
||||||
|
const root = this.model.root;
|
||||||
|
if (await root.isDirty()) {
|
||||||
|
root.update({
|
||||||
|
required_pr_ids: x2ManyCommands.set(
|
||||||
|
root.data.required_pr_ids.currentIds,
|
||||||
|
),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
root.load();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
};
|
||||||
|
}, () => []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registry.category("views").add('freeze_wizard', {
|
||||||
|
...formView,
|
||||||
|
Controller: FreezeController,
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user