mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_pull_list: Add server action for generating pull list
This commit is contained in:
1
stock_pull_list/models/__init__.py
Normal file
1
stock_pull_list/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import stock_picking
|
||||
30
stock_pull_list/models/stock_picking.py
Normal file
30
stock_pull_list/models/stock_picking.py
Normal 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
|
||||
)
|
||||
Reference in New Issue
Block a user