Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] spreadsheet_oca: Avoid to show dynamic cols when no cols selected #48

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export class PivotPanelDisplay extends Component {
{
title: this.env._t("Select the quantity of rows"),
resModel: "spreadsheet.select.row.number",
context: {
default_can_have_dynamic_cols: Boolean(
cols[0][0].fields.length
),
},
onRecordSaved: async (record) => {
resolve({
dynamic_rows: record.data.dynamic_rows,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ patch(
);
return Boolean(colGroupBys.intersection(rowGroupBys).size);
},
containsColGroupBys() {
const colGroupBys = new Set(
this.model.metaData.colGroupBys
.concat(this.model.metaData.expandedColGroupBys)
.map((el) => el.split(":")[0])
);
return Boolean(colGroupBys.size);
},
disableSpreadsheetInsertion() {
return (
!this.model.hasData() ||
Expand All @@ -50,6 +58,7 @@ patch(
default_name: this.model.metaData.title,
default_datasource_name: this.model.metaData.title,
default_can_be_dynamic: true,
default_can_have_dynamic_cols: this.containsColGroupBys(),
default_import_data: {
mode: "pivot",
metaData: JSON.parse(JSON.stringify(this.model.metaData)),
Expand Down
1 change: 1 addition & 0 deletions spreadsheet_oca/wizards/spreadsheet_select_row_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class SpreadsheetSelectRowNumber(models.TransientModel):

dynamic_rows = fields.Boolean()
number_of_rows = fields.Integer()
can_have_dynamic_cols = fields.Boolean()
dynamic_cols = fields.Boolean()
number_of_cols = fields.Integer()
6 changes: 5 additions & 1 deletion spreadsheet_oca/wizards/spreadsheet_select_row_number.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
name="number_of_rows"
attrs="{'invisible': [('dynamic_rows', '=', False)]}"
/>
<field name="dynamic_cols" />
<field name="can_have_dynamic_cols" invisible="1" />
<field
name="dynamic_cols"
attrs="{'invisible': [('can_have_dynamic_cols', '=', False)]}"
/>
<field
name="number_of_cols"
attrs="{'invisible': [('dynamic_cols', '=', False)]}"
Expand Down
1 change: 1 addition & 0 deletions spreadsheet_oca/wizards/spreadsheet_spreadsheet_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _default_mode_id(self):
import_data = fields.Serialized()
spreadsheet_id = fields.Many2one("spreadsheet.spreadsheet")
can_be_dynamic = fields.Boolean()
can_have_dynamic_cols = fields.Boolean()
is_tree = fields.Boolean()
dynamic = fields.Boolean(
"Dynamic Rows",
Expand Down
3 changes: 2 additions & 1 deletion spreadsheet_oca/wizards/spreadsheet_spreadsheet_import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
options="{'no_create': True}"
/>
<field name="can_be_dynamic" invisible="1" />
<field name="can_have_dynamic_cols" invisible="1" />
<field name="is_tree" invisible="1" />
<field
name="dynamic"
Expand All @@ -40,7 +41,7 @@
<field
name="dynamic_cols"
force_save="1"
attrs="{'invisible': ['|', ('can_be_dynamic', '=', False), ('is_tree', '=', True)]}"
attrs="{'invisible': ['|', ('can_have_dynamic_cols', '=', False), ('is_tree', '=', True)]}"
/>
<field
name="number_of_cols"
Expand Down
Loading