Files
stock-logistics-warehouse/stock_inventory_discrepancy/wizards/confirm_discrepancy_wiz.py
Ernesto Tejeda 60cbc061df [MIG] stock_inventory_discrepancy: Migration to 15.0
[UPD] Update stock_inventory_discrepancy.pot

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: stock-logistics-warehouse-15.0/stock-logistics-warehouse-15.0-stock_inventory_discrepancy
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_inventory_discrepancy/
2023-09-18 06:36:41 -03:00

42 lines
1.4 KiB
Python

# Copyright 2023 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import Command, _, fields, models
from odoo.exceptions import UserError
class ConfirmDiscrepancyWiz(models.TransientModel):
_name = "confirm.discrepancy.wiz"
_description = "Confim discrepancy wizard"
def _default_discrepancy_quant_ids(self):
return [
Command.set(
self.env["stock.quant"]
.browse(self.env.context.get("discrepancy_quant_ids"))
.ids
)
]
discrepancy_quant_ids = fields.Many2many(
comodel_name="stock.quant",
readonly=True,
default=_default_discrepancy_quant_ids,
)
def button_apply(self):
self.ensure_one()
if not self.user_has_groups(
"stock_inventory_discrepancy.group_stock_inventory_validation_always"
):
raise UserError(
_(
"You cannot apply inventory adjustments "
"if there are products that exceed the discrepancy threshold. "
"Only users with rights to apply them can proceed."
)
)
self.env["stock.quant"].browse(self.env.context.get("active_ids")).with_context(
skip_exceeded_discrepancy=True
).action_apply_inventory()