[IMP] stock_pull_list: Add server action for generating pull list

This commit is contained in:
Andrey Solodovnikov
2023-10-03 17:47:16 +03:00
parent 2babf9c462
commit a3f5a9eec5
8 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import stock_picking

View File

@@ -0,0 +1,30 @@
from odoo import _, fields, models
from odoo.exceptions import UserError
class StockPicking(models.Model):
_inherit = "stock.picking"
def action_create_pull_list(self):
source_location = fields.first(self).location_id
for record in self:
if source_location != record.location_id:
raise UserError(_("Choose transfers with same source location"))
if not record.picking_type_id.allow_pull_list_server_action:
raise UserError(
f"Operation type of {record.name} transfer did not handle server action"
)
pull_wizard = self.env["stock.pull.list.wizard"].create(
{"location_id": source_location.id}
)
res = pull_wizard.action_prepare()
return res
class StockPickingType(models.Model):
_inherit = "stock.picking.type"
allow_pull_list_server_action = fields.Boolean(
string="Allow pull list server action", default=False
)