|
1 |
| -use std::{cell::RefCell, collections::HashMap, hash::Hash, path::PathBuf, rc::Rc}; |
| 1 | +use std::{cell::RefCell, cmp::Ordering, collections::HashMap, hash::Hash, path::PathBuf, rc::Rc}; |
2 | 2 |
|
3 | 3 | use lsp_types::{Diagnostic, Position, Range};
|
4 | 4 | use tracing::{info, trace};
|
5 | 5 |
|
6 |
| -use crate::{constants::{BuildSteps, OYarn, SymType, DEBUG_STEPS, EXTENSION_NAME}, core::{diagnostics::{create_diagnostic, DiagnosticCode}, entry_point::{EntryPoint, EntryPointType}, evaluation::ContextValue, file_mgr::FileInfo, model::Model, odoo::SyncOdoo, symbols::symbol::Symbol, xml_data::{XmlData, XmlDataDelete, XmlDataMenuItem, XmlDataRecord, XmlDataTemplate}}, threads::SessionInfo, Sy, S}; |
| 6 | +use crate::{constants::{BuildSteps, OYarn, SymType, DEBUG_STEPS, EXTENSION_NAME}, core::{diagnostics::{create_diagnostic, DiagnosticCode}, entry_point::{EntryPoint, EntryPointType}, evaluation::ContextValue, file_mgr::FileInfo, model::Model, odoo::SyncOdoo, symbols::symbol::Symbol, xml_data::{XmlData, XmlDataDelete, XmlDataMenuItem, XmlDataRecord, XmlDataTemplate}}, threads::SessionInfo, utils::compare_semver, Sy, S}; |
7 | 7 |
|
8 | 8 |
|
9 | 9 |
|
@@ -111,6 +111,16 @@ impl XmlValidator {
|
111 | 111 | }
|
112 | 112 | //check each field in the record
|
113 | 113 | for field in &xml_data_record.fields {
|
| 114 | + let mut field_name = field.name.clone(); |
| 115 | + let mut has_translation = false; |
| 116 | + if compare_semver(&session.sync_odoo.full_version, "18.2.0") >= Ordering::Equal { |
| 117 | + let translation = field.name.split("@").collect::<Vec<&str>>(); |
| 118 | + if translation.len() > 1 { |
| 119 | + field_name = translation[0].to_string(); |
| 120 | + has_translation = true; |
| 121 | + //TODO check that the language exists |
| 122 | + } |
| 123 | + } |
114 | 124 | //Check that the field belong to the model
|
115 | 125 | let declared_field = all_fields.get(&field.name);
|
116 | 126 | if let Some(_declared_field) = declared_field {
|
@@ -140,6 +150,9 @@ impl XmlValidator {
|
140 | 150 | }
|
141 | 151 | //TODO check type
|
142 | 152 | } else {
|
| 153 | + if has_translation { |
| 154 | + continue; |
| 155 | + } |
143 | 156 | if let Some(diagnostic) = create_diagnostic(session, DiagnosticCode::OLS05057, &[&field.name, &xml_data_record.model.0]) {
|
144 | 157 | diagnostics.push(Diagnostic {
|
145 | 158 | range: Range { start: Position::new(field.range.start.try_into().unwrap(), 0), end: Position::new(field.range.end.try_into().unwrap(), 0) },
|
|
0 commit comments