Skip to content
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

[15][FIX] stock_weighing_auto_package: Store stock_weighing_auto_package with sudo #20

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions stock_weighing_auto_package/wizards/weighing_wizard.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# Copyright 2024 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import fields, models
from odoo import api, fields, models


class WeighingWizard(models.TransientModel):
_inherit = "weighing.wizard"

stock_weighing_auto_package = fields.Boolean(
related="product_id.stock_weighing_auto_package",
readonly=False,
compute="_compute_stock_weighing_auto_package",
inverse="_inverse_stock_weighing_auto_package",
string="Auto package",
)

@api.depends("product_id")
def _compute_stock_weighing_auto_package(self):
for wiz in self:
wiz.stock_weighing_auto_package = wiz.product_id.stock_weighing_auto_package

Check warning on line 18 in stock_weighing_auto_package/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing_auto_package/wizards/weighing_wizard.py#L18

Added line #L18 was not covered by tests

def _inverse_stock_weighing_auto_package(self):
for wiz in self:
wiz.product_id.sudo().stock_weighing_auto_package = (

Check warning on line 22 in stock_weighing_auto_package/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing_auto_package/wizards/weighing_wizard.py#L22

Added line #L22 was not covered by tests
wiz.stock_weighing_auto_package
)

def _post_add_detailed_operation(self):
res = super(WeighingWizard, self)._post_add_detailed_operation()
if self.result_package_id:
Expand Down
Loading