Skip to content

Commit

Permalink
[MIG] mgmtsystem_indicators_report: Finish migration
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Feb 16, 2025
1 parent 9d105f0 commit 2c4726e
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 19 deletions.
3 changes: 2 additions & 1 deletion mgmtsystem_indicators_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"demo": [],
"assets": {
"web.assets_backend": [
"mgmtsystem_nonconformity/static/src/js/*,js",
"mgmtsystem_indicators_report/static/src/components/**/*.esm.js",
"mgmtsystem_indicators_report/static/src/components/**/*.xml",
],
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @odoo-module **/

import {SelectionField} from "@web/views/fields/selection/selection_field";
import {registry} from "@web/core/registry";

export class DynamicSelectionIndicatorsReportField extends SelectionField {
get options() {
return this.props.record.data.selection_options.split(",").map((value) => {
return [value, value];
});
}

get string() {
console.log(this.props.value, this.options);
return this.props.value;
}

onChange(ev) {
const value = JSON.parse(ev.target.value);

this.props.update(value);
}
}

DynamicSelectionIndicatorsReportField.supportedTypes = ["char"];
DynamicSelectionIndicatorsReportField.legacySpecialData = undefined;

registry
.category("fields")
.add("dynamic_selection_indicators_report", DynamicSelectionIndicatorsReportField);
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** @odoo-module **/

const {Component} = owl;

import {Field} from "@web/views/fields/field";
import {registry} from "@web/core/registry";

export class IndicatorsReportValueField extends Component {
get field_props() {
var result = {
name: "value_" + this.props.record.data.value_type,
type: this.props.record.fields["value_" + this.props.record.data.value_type]
.type,
record: this.props.record,
};
if (this.props.record.data.value_type === "selection") {
result.fieldInfo = {
widget: "dynamic_selection_indicators_report",
FieldComponent: registry
.category("fields")
.get("dynamic_selection_indicators_report"),
};
}
return result;
}
}

IndicatorsReportValueField.components = {Field};
IndicatorsReportValueField.template =
"mgmtsystem_indicators_report.IndicatorsReportValueField";

console.log("HI!!!");
registry
.category("fields")
.add("mgmtsystem_indicators_report_value", IndicatorsReportValueField);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">


<t t-name="mgmtsystem_indicators_report.IndicatorsReportValueField" owl="1">

<Field t-props="field_props" t-if="props.record.data.value_type" />

</t>
</templates>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
/>
</group>
</sheet>
<div class="oe_chatter" />
</form>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,11 @@
widget="section_and_note_text"
attrs="{'readonly': ['|', ('concept_id', '!=', False), ('item_blocked', '=', True)]}"
/>
<field name="value_type" invisible="1" />
<field
string="Value"
name="value"
widget="mgmtsystem_indicator_report"
decoration-danger="interpretation == 'invalid'"
>
<field name="value_bool" />
<field name="value_str" />
<field
name="value_selection"
widget="dynamic_selection_indicators_report"
context="{'options': selection_options}"
/>
<field name="value_int" force_save="1" />
<field name="value_float" force_save="1" />
</field>
widget="mgmtsystem_indicators_report_value"
/>
<field name="value_type" invisible="1" />
<field name="value_bool" invisible="1" />
<field name="value_str" invisible="1" />
<field name="value_selection" invisible="1" />
Expand Down Expand Up @@ -167,7 +155,6 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter" />
</form>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter" />
</form>
</field>
</record>
Expand Down
6 changes: 6 additions & 0 deletions setup/mgmtsystem_indicators_report/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 2c4726e

Please sign in to comment.