Planned
This commit is contained in:
@@ -3235,61 +3235,65 @@ class LotPlanTransport(Wizard):
|
||||
def default_plan(self, fields):
|
||||
if not self.records:
|
||||
return {}
|
||||
record = self.records[0]
|
||||
quantity = record.r_lot_quantity or record.r_lot_matched or 0
|
||||
values = {
|
||||
'quantity': quantity,
|
||||
'unit': record.r_lot_unit_line.id if record.r_lot_unit_line else None,
|
||||
'cancel_plan': bool(
|
||||
record.r_planned_from_location
|
||||
or record.r_planned_to_location
|
||||
or record.r_planned_transport_type
|
||||
or record.r_planned_from_date
|
||||
or record.r_planned_to_date
|
||||
or record.r_planned_note),
|
||||
'planned_from_location': (
|
||||
record.r_planned_from_location.id
|
||||
if record.r_planned_from_location else None),
|
||||
'planned_to_location': (
|
||||
record.r_planned_to_location.id
|
||||
if record.r_planned_to_location else None),
|
||||
'planned_transport_type': record.r_planned_transport_type,
|
||||
'planned_from_date': record.r_planned_from_date,
|
||||
'planned_to_date': record.r_planned_to_date,
|
||||
'planned_note': record.r_planned_note,
|
||||
}
|
||||
return values
|
||||
lines = []
|
||||
for record in self.records:
|
||||
quantity = record.r_lot_quantity or record.r_lot_matched or 0
|
||||
if record.id < 10000000:
|
||||
raise UserError(
|
||||
"Only open quantity lines can be planned.")
|
||||
lines.append({
|
||||
'lotqt': record.id - 10000000,
|
||||
'quantity': quantity,
|
||||
'unit': (
|
||||
record.r_lot_unit_line.id
|
||||
if record.r_lot_unit_line else None),
|
||||
'cancel_plan': bool(
|
||||
record.r_planned_from_location
|
||||
or record.r_planned_to_location
|
||||
or record.r_planned_transport_type
|
||||
or record.r_planned_from_date
|
||||
or record.r_planned_to_date
|
||||
or record.r_planned_note),
|
||||
'planned_from_location': (
|
||||
record.r_planned_from_location.id
|
||||
if record.r_planned_from_location else None),
|
||||
'planned_to_location': (
|
||||
record.r_planned_to_location.id
|
||||
if record.r_planned_to_location else None),
|
||||
'planned_transport_type': record.r_planned_transport_type,
|
||||
'planned_from_date': record.r_planned_from_date,
|
||||
'planned_to_date': record.r_planned_to_date,
|
||||
'planned_note': record.r_planned_note,
|
||||
})
|
||||
return {'lines': lines}
|
||||
|
||||
def transition_planning(self):
|
||||
Lot = Pool().get('lot.lot')
|
||||
LotQt = Pool().get('lot.qt')
|
||||
affected_lines = []
|
||||
if len(self.records) != 1:
|
||||
raise UserError("Please select exactly one quantity line to plan.")
|
||||
plan_values = {
|
||||
'planned_from_location': (
|
||||
self.plan.planned_from_location.id
|
||||
if self.plan.planned_from_location else None),
|
||||
'planned_to_location': (
|
||||
self.plan.planned_to_location.id
|
||||
if self.plan.planned_to_location else None),
|
||||
'planned_transport_type': self.plan.planned_transport_type,
|
||||
'planned_from_date': self.plan.planned_from_date,
|
||||
'planned_to_date': self.plan.planned_to_date,
|
||||
'planned_note': self.plan.planned_note,
|
||||
}
|
||||
if not self.plan.lines:
|
||||
raise UserError("Please select at least one quantity line to plan.")
|
||||
with Lot.skip_quantity_consistency():
|
||||
for record in self.records:
|
||||
if record.id < 10000000:
|
||||
raise UserError(
|
||||
"Only open quantity lines can be planned.")
|
||||
lotqt = LotQt(record.id - 10000000)
|
||||
for line in self.plan.lines:
|
||||
lotqt = line.lotqt
|
||||
plan_values = {
|
||||
'planned_from_location': (
|
||||
line.planned_from_location.id
|
||||
if line.planned_from_location else None),
|
||||
'planned_to_location': (
|
||||
line.planned_to_location.id
|
||||
if line.planned_to_location else None),
|
||||
'planned_transport_type': line.planned_transport_type,
|
||||
'planned_from_date': line.planned_from_date,
|
||||
'planned_to_date': line.planned_to_date,
|
||||
'planned_note': line.planned_note,
|
||||
}
|
||||
self._append_lotqt_affected_lines(lotqt, affected_lines)
|
||||
if self.plan.cancel_plan:
|
||||
if line.cancel_plan:
|
||||
LotQt.cancel_transport_plan(lotqt)
|
||||
else:
|
||||
LotQt.plan_to_transport(
|
||||
lotqt, self.plan.quantity, plan_values)
|
||||
lotqt, line.quantity, plan_values)
|
||||
Lot.assert_lines_quantity_consistency(affected_lines)
|
||||
return 'end'
|
||||
|
||||
@@ -3301,6 +3305,16 @@ class LotPlanTransportStart(ModelView):
|
||||
"Plan lot to transport"
|
||||
__name__ = "lot.plan_transport.start"
|
||||
|
||||
lines = fields.One2Many(
|
||||
'lot.plan_transport.line', 'plan', "Planning lines")
|
||||
|
||||
|
||||
class LotPlanTransportLine(ModelView):
|
||||
"Plan lot to transport line"
|
||||
__name__ = "lot.plan_transport.line"
|
||||
|
||||
plan = fields.Many2One('lot.plan_transport.start', "Plan")
|
||||
lotqt = fields.Many2One('lot.qt', "Quantity line", readonly=True)
|
||||
cancel_plan = fields.Boolean("Cancel existing plan")
|
||||
planned_from_location = fields.Many2One(
|
||||
'stock.location', "Planned From",
|
||||
|
||||
Reference in New Issue
Block a user