Skip to content

Commit

Permalink
Merge PR #15 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Jul 12, 2023
2 parents 62799a3 + 08b297b commit 44922b0
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions spreadsheet_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet_renderer.esm.js",
"spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet_controlpanel.esm.js",
"spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet_action.esm.js",
"spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js",
],
},
}
76 changes: 76 additions & 0 deletions spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/** @odoo-module */

import {Domain} from "@web/core/domain";
import {Many2OneField} from "@web/views/fields/many2one/many2one_field";
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import {useService} from "@web/core/utils/hooks";

const {chartSidePanelComponentRegistry} = spreadsheet.registries;
const {LineBarPieDesignPanel} = spreadsheet.components;
const {Component} = owl;

export class OdooPanel extends Component {
setup() {
this.menus = useService("menu");
}
get menuId() {
const menu = this.env.model.getters.getChartOdooMenu(this.props.figureId);
if (menu) {
return [menu.id, menu.name];
}
return undefined;
}
updateMenu(menuId) {
if (!menuId) {
this.env.model.dispatch("LINK_ODOO_MENU_TO_CHART", {
chartId: this.props.figureId,
odooMenuId: undefined,
});
return;
}
const menu = this.env.model.getters.getIrMenu(menuId[0]);
this.env.model.dispatch("LINK_ODOO_MENU_TO_CHART", {
chartId: this.props.figureId,
odooMenuId: menu.xmlid || menu.id,
});
}
get record() {
const menus = this.menus
.getAll()
.map((menu) => menu.id)
.filter((menuId) => menuId !== "root");
return {
getFieldDomain: function () {
return new Domain([["id", "in", menus]]);
},
getFieldContext: function () {
return {};
},
};
}
}
OdooPanel.template = "spreadsheet_oca.OdooPanel";
OdooPanel.components = {Many2OneField};

class OdooStackablePanel extends OdooPanel {
onChangeStacked(ev) {
this.props.updateChart(this.props.figureId, {
stacked: ev.target.checked,
});
}
}
OdooStackablePanel.template = "spreadsheet_oca.OdooStackablePanel";

chartSidePanelComponentRegistry
.add("odoo_line", {
configuration: OdooStackablePanel,
design: LineBarPieDesignPanel,
})
.add("odoo_bar", {
configuration: OdooStackablePanel,
design: LineBarPieDesignPanel,
})
.add("odoo_pie", {
configuration: OdooPanel,
design: LineBarPieDesignPanel,
});
36 changes: 36 additions & 0 deletions spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,40 @@
</div>
</div>
</t>
<t t-name="spreadsheet_oca.OdooPanel" owl="1">
<div class="o-section">
<div class="o-section-title">Link to Odoo menu</div>
<div class="o-section-value">
<Many2OneField
value="menuId"
relation="'ir.ui.menu'"
record="record"
update.bind="updateMenu"
canOpen="false"
/>
</div>
</div>
</t>
<t
t-name="spreadsheet_oca.OdooStackablePanel"
t-inherit="spreadsheet_oca.OdooPanel"
t-inherit-mode="primary"
owl="1"
>
<xpath expr="div[hasclass('o-section')]" position="before">
<div class="o-section">
<label>
<div class="o_checkbox">
<input
type="checkbox"
name="stacked"
t-att-checked="props.definition.stacked"
t-on-change="onChangeStacked"
/>
Stacked
</div>
</label>
</div>
</xpath>
</t>
</templates>
5 changes: 5 additions & 0 deletions spreadsheet_oca/static/src/spreadsheet/spreadsheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@
}
}
}
.o-section-value {
.o_field_many2one_selection {
width: 100%;
}
}
}

0 comments on commit 44922b0

Please sign in to comment.