Skip to content

Commit

Permalink
[MIG] base_export_manager: Migration to 16.0
Browse files Browse the repository at this point in the history
Co-authored-by: rjpathan <rjpathan19@gmail.com>
Co-authored-by: stefan.ungureanu <stefan.ungureanu@tecnativa.com>
  • Loading branch information
rjpathan authored and stefan-tecnativa committed Aug 4, 2023
1 parent 30ad949 commit fb5050d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 82 deletions.
6 changes: 3 additions & 3 deletions base_export_manager/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Manage model export profiles",
"category": "Personalization",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"depends": ["web"],
"data": [
"views/ir_exports.xml",
Expand All @@ -25,9 +25,9 @@
"license": "AGPL-3",
"assets": {
"web.assets_backend": [
"base_export_manager/static/src/js/base_export_manager.js",
"base_export_manager/static/src/views/list/list_controller.esm.js",
"base_export_manager/static/src/xml/base.xml",
],
"web.assets_qweb": ["base_export_manager/static/src/xml/base.xml"],
},
"installable": True,
"application": False,
Expand Down
3 changes: 2 additions & 1 deletion base_export_manager/models/ir_exports_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def _inverse_name(self):
if any(parts):
# invalidate_cache -> in order to get actual value of field 'label'
# in function '_check_name'
self.invalidate_cache(ids=one.ids)
# self.env["ir.exports.line"].invalidate_cache(ids=one.ids)
self.browse(one.ids).invalidate_recordset()
one._check_name()

@api.constrains("field1_id", "field2_id", "field3_id", "field4_id")
Expand Down
27 changes: 0 additions & 27 deletions base_export_manager/static/src/js/base_export_manager.js

This file was deleted.

21 changes: 21 additions & 0 deletions base_export_manager/static/src/views/list/list_controller.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @odoo-module **/

import {ListController} from "@web/views/list/list_controller";
const {onWillRender} = owl;
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

patch(ListController.prototype, "base_export_manager", {
setup() {
this._super(...arguments);
onWillRender(async () => {
if (this.isExportEnable) {
const is_export_enabled =
session.export_models.indexOf(this.model.root.resModel) !== -1;
if (!session.is_system && !is_export_enabled) {
this.isExportEnable = false;
}
}
});
},
});
21 changes: 10 additions & 11 deletions base_export_manager/tests/test_ir_exports_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@


class TestIrExportsLineCase(TransactionCase):
def setUp(self):
super(TestIrExportsLineCase, self).setUp()
m_ir_exports = self.env["ir.exports"]
self.export = m_ir_exports.create(
@classmethod
def setUpClass(cls):
super().setUpClass()
m_ir_exports = cls.env["ir.exports"]
cls.export = m_ir_exports.create(
{"name": "Partner Test", "resource": "res.partner"}
)
self.partner_model = self.env["ir.model"].search(
[("model", "=", "res.partner")]
cls.partner_model = cls.env["ir.model"].search([("model", "=", "res.partner")])
cls.field_parent_id = cls.env["ir.model.fields"].search(
[("name", "=", "parent_id"), ("model_id", "=", cls.partner_model.id)]
)
self.field_parent_id = self.env["ir.model.fields"].search(
[("name", "=", "parent_id"), ("model_id", "=", self.partner_model.id)]
)
self.field_name = self.env["ir.model.fields"].search(
[("name", "=", "name"), ("model_id", "=", self.partner_model.id)]
cls.field_name = cls.env["ir.model.fields"].search(
[("name", "=", "name"), ("model_id", "=", cls.partner_model.id)]
)

def _record_create(self, field_name):
Expand Down
85 changes: 45 additions & 40 deletions base_export_manager/views/ir_exports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,52 @@
<field name="model">ir.exports</field>
<field name="arch" type="xml">
<form string="Export Profile">
<group>
<field name="name" />
<field name="model_id" options="{'no_create': True}" />
</group>
<group>
<field
name="export_fields"
nolabel="1"
context="{'default_model1_id': model_id}"
>
<tree editable="bottom">
<field name="sequence" widget="handle" />
<field name="model1_id" invisible="True" />
<field name="model2_id" invisible="True" />
<field name="model3_id" invisible="True" />
<field name="model4_id" invisible="True" />
<field name="label" />
<field name="name" readonly="1" />
<sheet>
<group col="4">
<field name="name" />
<field name="model_id" options="{'no_create': True}" />
</group>
<notebook>
<page string="Export Fields">
<field
name="field1_id"
required="True"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field2_id"
attrs="{'readonly': [('model2_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field3_id"
attrs="{'readonly': [('model3_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field4_id"
attrs="{'readonly': [('model3_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
</tree>
</field>
</group>
name="export_fields"
nolabel="1"
colspan="4"
context="{'default_model1_id': model_id}"
>
<tree editable="bottom">
<field name="sequence" widget="handle" />
<field name="model1_id" invisible="True" />
<field name="model2_id" invisible="True" />
<field name="model3_id" invisible="True" />
<field name="model4_id" invisible="True" />
<field name="label" />
<field name="name" readonly="1" />
<field
name="field1_id"
required="True"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field2_id"
attrs="{'readonly': [('model2_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field3_id"
attrs="{'readonly': [('model3_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
<field
name="field4_id"
attrs="{'readonly': [('model3_id', '=', False)]}"
options="{'no_open': True, 'no_create': True}"
/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
Expand Down

0 comments on commit fb5050d

Please sign in to comment.