Skip to content

Commit 2e82e56

Browse files
committed
[IMP] test for OLS03023
1 parent 5dda37c commit 2e82e56

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

server/src/core/diagnostic_codes_list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ OLS03021, DiagnosticSetting::Error, "Inverse field {0} does not exist on comodel
168168
*/
169169
OLS03022, DiagnosticSetting::Error, "Inverse field is not a Many2one field",
170170
/**
171-
* On a One2many field, the inverse_name should be a field on the comodel that is a Many2one to the current model.
171+
* On a One2many field, the inverse_name should be a field on the comodel that is a Many2one to the current model
172+
* -> current_model is not right
172173
*/
173174
OLS03023, DiagnosticSetting::Error, "Inverse field {0} is not pointing to the current model {1}, but rather to {2}",
174175
/**

server/src/core/python_validator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,7 @@ impl PythonValidator {
552552
let symbols: Vec<_> = main_syms.iter().flat_map(|main_sym|
553553
main_sym.clone().borrow().get_member_symbol(session, &inverse_name, Some(module.clone()), false, true, false, true, false).0
554554
).collect();
555-
let method_found = !symbols.is_empty();
556-
if !method_found{
555+
if symbols.is_empty() {
557556
let Some(arg_range) = eval_weak.as_weak().context.get(&format!("inverse_name_arg_range")).map(|ctx_val| ctx_val.as_text_range()) else {
558557
continue;
559558
};

server/tests/data/addons/module_1/models/base_test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class BaseTestModel(models.Model):
1010
partner_id = fields.Many2one("res.partner")
1111
partner_country_phone_code = fields.Integer(related="partner_id.country_id.phone_code", store=True)
1212
diagnostics_id = fields.Many2one("module_1.diagnostics_model")
13+
same_name_id = fields.Many2one(comodel_name="module_1.same_name_model")
1314

1415
def get_test_int(self):
1516
self.ensure_one()

server/tests/data/addons/module_1/models/diagnostics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class ModelWithDiagnostics(models.Model):
2020
test_models = fields.One2many("pygls.tests.base_test_model", inverse_name="test_int_vdsqcedfc") # OLS03021
2121
test_models = fields.One2many("pygls.tests.base_test_model", inverse_name="test_int") # OLS03022
2222

23+
test_models = fields.One2many("pygls.tests.base_test_model", inverse_name="same_name_id") # OLS03023
24+
25+
2326
test_method_search_1 = fields.Integer(search="_search_1")
2427
test_method_search_2 = fields.Integer(search="_search_2") # OLS03018
2528
test_method_search_3 = fields.Integer(compute="_compute_1")

0 commit comments

Comments
 (0)