Skip to content

Commit 99de437

Browse files
livaiosfda-odoo
authored andcommitted
[FIX] vscode: fix addons detection irrelevant files in odoo path
1 parent ceba17c commit 99de437

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ vscode/.nox
1414
vscode/__pycache__
1515
vscode/requirements.txt
1616
vscode/server
17-
vscode/CHANGELOG.md
17+
vscode/CHANGELOG.md
18+
package-lock.json

vscode/client/extension.ts

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -327,36 +327,40 @@ function deleteOldFiles(context: ExtensionContext, outputChannel: OutputChannel)
327327
async function checkAddons(context: ExtensionContext, odooOutputChannel: OutputChannel) {
328328
let files = await workspace.findFiles('**/__manifest__.py')
329329
let currentConfig = getCurrentConfig(context)
330-
let missingFiles = files.filter(file => {
331-
return !currentConfig.addons.some((addon) => file.fsPath.startsWith(addon))
332-
})
333-
let missingPaths = [...new Set(missingFiles.map(file => {
334-
let filePath = file.fsPath.split(path.sep)
335-
return filePath.slice(0, filePath.length - 2).join(path.sep)
336-
}))]
337-
odooOutputChannel.appendLine("Missing addon paths : " + missingPaths.length)
338-
if (missingPaths.length > 0) {
339-
odooOutputChannel.appendLine("Missing addon paths : " + JSON.stringify(missingPaths))
340-
const selection = await window.showWarningMessage(
341-
`We detected addon paths that weren't added in the current configuration. Would you like to add them?`,
342-
"Update current configuration",
343-
"View Paths",
344-
"Ignore"
345-
);
346-
switch (selection) {
347-
case ("Update current configuration"):
348-
ConfigurationWebView.render(context, currentConfig.id);
349-
break
350-
case ("View Paths"):
351-
odooOutputChannel.show();
352-
break
330+
if (currentConfig) {
331+
let missingFiles = files.filter(file => {
332+
return (
333+
!currentConfig.addons.some((addon) => file.fsPath.startsWith(addon)) ||
334+
!file.fsPath.startsWith(currentConfig.odooPath)
335+
)
336+
})
337+
let missingPaths = [...new Set(missingFiles.map(file => {
338+
let filePath = file.fsPath.split(path.sep)
339+
return filePath.slice(0, filePath.length - 2).join(path.sep)
340+
}))]
341+
if (missingPaths.length > 0) {
342+
odooOutputChannel.appendLine("Missing addon paths : " + JSON.stringify(missingPaths))
343+
const selection = await window.showWarningMessage(
344+
`We detected addon paths that weren't added in the current configuration. Would you like to add them?`,
345+
"Update current configuration",
346+
"View Paths",
347+
"Ignore"
348+
);
349+
switch (selection) {
350+
case ("Update current configuration"):
351+
ConfigurationWebView.render(context, currentConfig.id);
352+
break
353+
case ("View Paths"):
354+
odooOutputChannel.show();
355+
break
356+
}
353357
}
354358
}
355359
}
356360

357361
async function checkOdooPath(context: ExtensionContext) {
358362
let currentConfig = getCurrentConfig(context)
359-
let odooFound = workspace.getWorkspaceFolder(Uri.parse(currentConfig.odooPath))
363+
let odooFound = currentConfig ? workspace.getWorkspaceFolder(Uri.parse(currentConfig.odooPath)) : true
360364
if (!odooFound) {
361365
let invalidPath = false
362366
for (const f of workspace.workspaceFolders) {

0 commit comments

Comments
 (0)