Repository navigation
[19.0][MIG] base_geoengine_demo: Migration to 19.0 #9
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
Open
weinni2000
wants to merge
1
commit into
19.0-mig-base_geoengine_demo-base
Choose a base branch
from
19.0-mig-base_geoengine_demo
base: 19.0-mig-base_geoengine_demo-base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import test_retail_machine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo.exceptions import ValidationError | ||
| from odoo.tests.common import TransactionCase | ||
|
|
||
|
|
||
| class TestRetailMachine(TransactionCase): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.zip_a_id = cls.env["dummy.zip"].create( | ||
| { | ||
| "name": "9991", | ||
| "city": "Square A", | ||
| "the_geom": "MULTIPOLYGON (((0 0, 1000 0, 1000 1000, 0 1000, 0 0)))", | ||
| } | ||
| ) | ||
| cls.zip_b_id = cls.env["dummy.zip"].create( | ||
| { | ||
| "name": "9992", | ||
| "city": "Square B", | ||
| "the_geom": "MULTIPOLYGON (((2000 0, 3000 0, 3000 1000, 2000 1000, " | ||
| "2000 0)))", | ||
| } | ||
| ) | ||
| cls.machine_model = cls.env["geoengine.demo.automatic.retailing.machine"] | ||
|
|
||
| def test_compute_zip_from_point(self): | ||
| machine_id = self.machine_model.create( | ||
| {"name": "M-1", "the_point": "POINT (500 500)", "total_sales": 10.0} | ||
| ) | ||
| self.assertEqual(machine_id.zip_id, self.zip_a_id) | ||
| machine_id.the_point = "POINT (2500 500)" | ||
| self.assertEqual(machine_id.zip_id, self.zip_b_id) | ||
|
|
||
| def test_compute_zip_without_point(self): | ||
| machine_id = self.machine_model.create( | ||
| {"name": "M-7", "the_point": "POINT (500 500)"} | ||
| ) | ||
| self.assertEqual(machine_id.zip_id, self.zip_a_id) | ||
| machine_id.the_point = False | ||
| self.assertFalse(machine_id.zip_id) | ||
|
|
||
| def test_compute_zip_point_outside_zips(self): | ||
| machine_id = self.machine_model.create( | ||
| {"name": "M-8", "the_point": "POINT (5000 5000)"} | ||
| ) | ||
| self.assertFalse(machine_id.zip_id) | ||
|
|
||
| def test_zip_total_sales(self): | ||
| self.machine_model.create( | ||
| [ | ||
| {"name": "M-2", "the_point": "POINT (100 100)", "total_sales": 10.0}, | ||
| {"name": "M-3", "the_point": "POINT (900 900)", "total_sales": 5.5}, | ||
| ] | ||
| ) | ||
| self.assertAlmostEqual(self.zip_a_id.total_sales, 15.5) | ||
| self.assertAlmostEqual(self.zip_b_id.total_sales, 0.0) | ||
|
|
||
| def test_point_outside_zip_raises(self): | ||
| with self.assertRaises(ValidationError): | ||
| self.machine_model.create( | ||
| { | ||
| "name": "M-4", | ||
| "the_point": "POINT (500 500)", | ||
| "zip_id": self.zip_b_id.id, | ||
| } | ||
| ) | ||
|
|
||
| def test_constraint_multi_records(self): | ||
| machine_ids = self.machine_model.create( | ||
| [ | ||
| {"name": "M-5", "the_point": "POINT (500 500)"}, | ||
| {"name": "M-6", "the_point": "POINT (2500 500)"}, | ||
| ] | ||
| ) | ||
| self.assertEqual(machine_ids.zip_id, self.zip_a_id | self.zip_b_id) | ||
| with self.assertRaises(ValidationError): | ||
| machine_ids.write({"zip_id": self.zip_a_id.id}) | ||
|
|
||
| def test_display_name(self): | ||
| self.assertEqual(self.zip_a_id.display_name, "9991 Square A") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| odoo-addon-base_geoengine @ git+https://github.com/OCA/geospatial@refs/pull/465/head#subdirectory=base_geoengine |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Edited areas leave invalid assignments
When a ZIP geometry is edited so it no longer contains a machine assigned to that ZIP, editing a ZIP polygon does not invoke
_check_the_pointon its retail machines, so machines whose points are no longer inside their assigned ZIP remain stored with invalid assignments; a concurrent polygon edit after this search can produce the same state.Validate linked machines when ZIP geometry changes, and make that validation safe against concurrent geometry and machine updates.
Prompt for AI agents