-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
8 changed files
with
282 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Adding new lines on pivot tables | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
When we add a pivot table, the number of rows is predefined according to the current data. | ||
|
||
In order to add new rows, we need to reinsert the pivot table. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
spreadsheet_oca/static/src/spreadsheet/bundle/chart_panel.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** @odoo-module */ | ||
|
||
import {patch} from "@web/core/utils/patch"; | ||
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; | ||
const {chartRegistry} = spreadsheet.registries; | ||
|
||
const {ChartPanel} = spreadsheet.components; | ||
export function isOdooKey(code) { | ||
return code.startsWith("odoo_"); | ||
} | ||
|
||
patch(ChartPanel.prototype, "spreadsheet_oca.ChartPanel", { | ||
get chartTypes() { | ||
return this.filterChartTypes(isOdooKey(this.getChartDefinition().type)); | ||
}, | ||
|
||
filterChartTypes(isOdoo) { | ||
var result = {}; | ||
for (const key of chartRegistry.getKeys()) { | ||
if ((isOdoo && isOdooKey(key)) || (!isOdoo && !isOdooKey(key))) { | ||
result[key] = chartRegistry.get(key).name; | ||
} | ||
} | ||
return result; | ||
}, | ||
onTypeChange(type) { | ||
if (isOdooKey(this.getChartDefinition().type)) { | ||
const definition = { | ||
stacked: false, | ||
verticalAxisPosition: "left", | ||
...this.env.model.getters.getChartDefinition(this.figureId), | ||
type, | ||
}; | ||
this.env.model.dispatch("UPDATE_CHART", { | ||
definition, | ||
id: this.figureId, | ||
sheetId: this.env.model.getters.getActiveSheetId(), | ||
}); | ||
} else { | ||
this._super(type); | ||
} | ||
}, | ||
}); |
82 changes: 82 additions & 0 deletions
82
spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** @odoo-module */ | ||
|
||
import {Domain} from "@web/core/domain"; | ||
import {Many2OneField} from "@web/views/fields/many2one/many2one_field"; | ||
import {patch} from "@web/core/utils/patch"; | ||
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
const {LineBarPieConfigPanel, ScorecardChartConfigPanel, GaugeChartConfigPanel} = | ||
spreadsheet.components; | ||
|
||
const menuChartProps = { | ||
setup() { | ||
this._super.apply(this, arguments); | ||
this.menus = useService("menu"); | ||
}, | ||
get menuId() { | ||
const menu = this.env.model.getters.getChartOdooMenu(this.props.figureId); | ||
if (menu) { | ||
return [menu.id, menu.name]; | ||
} | ||
return false; | ||
}, | ||
updateMenu(menuId) { | ||
if (!menuId) { | ||
this.env.model.dispatch("LINK_ODOO_MENU_TO_CHART", { | ||
chartId: this.props.figureId, | ||
odooMenuId: false, | ||
}); | ||
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 {}; | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
patch( | ||
LineBarPieConfigPanel.prototype, | ||
"spreadsheet_oca.LineBarPieConfigPanel", | ||
menuChartProps | ||
); | ||
LineBarPieConfigPanel.components = { | ||
...LineBarPieConfigPanel.components, | ||
Many2OneField, | ||
}; | ||
|
||
patch( | ||
ScorecardChartConfigPanel.prototype, | ||
"spreadsheet_oca.ScorecardChartConfigPanel", | ||
menuChartProps | ||
); | ||
ScorecardChartConfigPanel.components = { | ||
...ScorecardChartConfigPanel.components, | ||
Many2OneField, | ||
}; | ||
|
||
patch( | ||
GaugeChartConfigPanel.prototype, | ||
"spreadsheet_oca.GaugeChartConfigPanel", | ||
menuChartProps | ||
); | ||
GaugeChartConfigPanel.components = { | ||
...GaugeChartConfigPanel.components, | ||
Many2OneField, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters