-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stock_reception_screen_measuring_device: measure smaller packages
When goods are received, triggers measurements also for smaller packagings that weren't ordered or received. This behavior is not triggered when received packagings are not the same as ordered packagings.
- Loading branch information
1 parent
c114af4
commit e75c92e
Showing
9 changed files
with
504 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
25 changes: 25 additions & 0 deletions
25
stock_reception_screen_measuring_device/migrations/14.0.2.0.0/post-migration.py
This file contains 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,25 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def populate_new_field(env): | ||
records_to_update = ( | ||
env["stock.reception.screen"].search([("current_step", "!=", "done")]).exists() | ||
) | ||
_logger.info( | ||
"Set smaller_package_has_missing_dimensions on ongoing reception screens" | ||
) | ||
records_to_update._compute_smaller_package_has_missing_dimensions() | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
populate_new_field(env) |
29 changes: 29 additions & 0 deletions
29
stock_reception_screen_measuring_device/migrations/14.0.2.0.0/pre-migration.py
This file contains 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,29 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def create_and_populate_new_fields(cr): | ||
cr.execute( | ||
""" | ||
ALTER TABLE stock_reception_screen | ||
ADD COLUMN IF NOT EXISTS smaller_package_has_missing_dimensions BOOLEAN; | ||
""" | ||
) | ||
# Set value to False for done reception screens. | ||
# Otherwise, let the ORM do its job in post migration | ||
_logger.info("Set smaller_package_has_missing_dimensions on done reception screens") | ||
cr.execute( | ||
""" | ||
UPDATE stock_reception_screen | ||
SET smaller_package_has_missing_dimensions = FALSE | ||
WHERE current_step = 'done'; | ||
""" | ||
) | ||
|
||
|
||
def migrate(cr, version): | ||
create_and_populate_new_fields(cr) |
This file contains 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 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_reception_screen_measurement |
14 changes: 14 additions & 0 deletions
14
stock_reception_screen_measuring_device/tests/fake_components.py
This file contains 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,14 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class FakeDevice(Component): | ||
_name = "device.component.fake" | ||
_inherit = "measuring.device.base" | ||
_usage = "fake" | ||
|
||
def post_update_packaging_measures(self, measures, packaging, wizard_line): | ||
# Unassign measuring device when measuring is done | ||
packaging._measuring_device_release() |
14 changes: 14 additions & 0 deletions
14
stock_reception_screen_measuring_device/tests/fake_models.py
This file contains 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,14 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class FakeMeasuringDevice(models.Model): | ||
_inherit = "measuring.device" | ||
|
||
device_type = fields.Selection(selection_add=[("fake", "FAKE")]) | ||
|
||
def mocked_measure(self, measurements): | ||
self.ensure_one() | ||
self._update_packaging_measures(measurements) |
Oops, something went wrong.