-
-
Notifications
You must be signed in to change notification settings - Fork 198
[18.0][FWPORT] company_sanitary_registry: Forward port non-migrated commits #266
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
Merged
OCA-git-bot
merged 2 commits into
OCA:18.0
from
Tecnativa:18.0-FWP-company_sanitary_registry
Mar 26, 2026
+382
−36
Merged
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| test-requirements.txt merge=union |
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
47 changes: 47 additions & 0 deletions
47
company_sanitary_registry/migrations/18.0.1.1.0/pre_migration.py
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,47 @@ | ||
| # Copyright 2025 Tecnativa - Carlos Roca | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from openupgradelib import openupgrade | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| CREATE TABLE IF NOT EXISTS sanitary_registry | ||
| ( | ||
| id serial primary key, | ||
| name varchar | ||
| ) | ||
| """, | ||
| ) | ||
| # Create sanitary.registry records for values set on company | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| INSERT INTO sanitary_registry (name) | ||
| SELECT sanitary_registry | ||
| FROM res_company | ||
| WHERE sanitary_registry IS NOT NULL | ||
| AND NOT EXISTS ( | ||
| SELECT 1 FROM sanitary_registry LIMIT 1 | ||
| ) | ||
CarlosRoca13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """, | ||
| ) | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| ALTER TABLE res_company | ||
| ADD COLUMN IF NOT EXISTS sanitary_registry_id integer | ||
| """, | ||
| ) | ||
| # Assign the sanitary.registry record to res.company | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| UPDATE res_company rc | ||
| SET sanitary_registry_id = sr.id FROM sanitary_registry sr | ||
| WHERE sr.name = rc.sanitary_registry | ||
| """, | ||
| ) | ||
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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # Copyright 2023 Tecnativa - Carlos Roca | ||
| # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html | ||
| from . import res_company | ||
| from . import sanitary_registry | ||
| from . import sanitary_registry_warehouse_category |
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,24 @@ | ||
| # Copyright 2025 Tecnativa - Carlos Roca | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl | ||
| from odoo import _, api, fields, models | ||
| from odoo.exceptions import ValidationError | ||
|
|
||
|
|
||
| class SanitaryRegistry(models.Model): | ||
| _name = "sanitary.registry" | ||
| _description = "Sanitary Registry" | ||
|
|
||
| name = fields.Char() | ||
|
|
||
| @api.constrains("name") | ||
| def _check_name(self): | ||
| other_regs = self.env["sanitary.registry"].search( | ||
| [("id", "not in", self.ids), ("name", "in", self.mapped("name"))] | ||
| ) | ||
| if other_regs: | ||
| raise ValidationError( | ||
| _( | ||
| "There are already sanitary registrations with values %s.", | ||
| other_regs.mapped("name"), | ||
| ) | ||
| ) |
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.
Uh oh!
There was an error while loading. Please reload this page.