add new buttons for transfer
This commit is contained in:
parent
b7d2c88664
commit
abe3c44213
|
@ -1275,14 +1275,14 @@ class TransferForm(FlaskForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._type = kwargs.get('type')
|
self._type = kwargs.get('type')
|
||||||
lot_id = kwargs.pop('lot_id', None)
|
lot_id = kwargs.pop('lot_id', None)
|
||||||
|
self._tmp_lot = None
|
||||||
|
if lot_id:
|
||||||
self._tmp_lot = Lot.query.filter(Lot.id == lot_id).one()
|
self._tmp_lot = Lot.query.filter(Lot.id == lot_id).one()
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._obj = None
|
self._obj = None
|
||||||
|
|
||||||
def validate(self, extra_validators=None):
|
def validate(self, extra_validators=None):
|
||||||
is_valid = super().validate(extra_validators)
|
is_valid = super().validate(extra_validators)
|
||||||
if not self._tmp_lot:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self._type and self.type.data not in ['incoming', 'outgoing']:
|
if self._type and self.type.data not in ['incoming', 'outgoing']:
|
||||||
return False
|
return False
|
||||||
|
@ -1303,7 +1303,11 @@ class TransferForm(FlaskForm):
|
||||||
return self._obj
|
return self._obj
|
||||||
|
|
||||||
def set_obj(self):
|
def set_obj(self):
|
||||||
self.newlot = Lot(name=self._tmp_lot.name)
|
name = self.code.data
|
||||||
|
if self._tmp_lot:
|
||||||
|
name = self._tmp_lot.name
|
||||||
|
self.newlot = Lot(name=name)
|
||||||
|
if self._tmp_lot:
|
||||||
self.newlot.devices = self._tmp_lot.devices
|
self.newlot.devices = self._tmp_lot.devices
|
||||||
db.session.add(self.newlot)
|
db.session.add(self.newlot)
|
||||||
|
|
||||||
|
|
|
@ -753,7 +753,7 @@ class NewTransferView(GenericMixin):
|
||||||
form_class = TransferForm
|
form_class = TransferForm
|
||||||
title = "Add new transfer"
|
title = "Add new transfer"
|
||||||
|
|
||||||
def dispatch_request(self, lot_id, type_id):
|
def dispatch_request(self, type_id, lot_id=None):
|
||||||
self.form = self.form_class(lot_id=lot_id, type=type_id)
|
self.form = self.form_class(lot_id=lot_id, type=type_id)
|
||||||
self.get_context()
|
self.get_context()
|
||||||
|
|
||||||
|
@ -1355,6 +1355,10 @@ devices.add_url_rule(
|
||||||
)
|
)
|
||||||
devices.add_url_rule(
|
devices.add_url_rule(
|
||||||
'/lot/<string:lot_id>/transfer/<string:type_id>/',
|
'/lot/<string:lot_id>/transfer/<string:type_id>/',
|
||||||
|
view_func=NewTransferView.as_view('lot_new_transfer'),
|
||||||
|
)
|
||||||
|
devices.add_url_rule(
|
||||||
|
'/lot/transfer/<string:type_id>/',
|
||||||
view_func=NewTransferView.as_view('new_transfer'),
|
view_func=NewTransferView.as_view('new_transfer'),
|
||||||
)
|
)
|
||||||
devices.add_url_rule(
|
devices.add_url_rule(
|
||||||
|
|
|
@ -194,6 +194,11 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
|
<ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('inventory.new_transfer', type_id='incoming') }}">
|
||||||
|
<i class="bi bi-plus" style="font-size: larger;"></i><span>New Incoming lot</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
{% for lot in lots %}
|
{% for lot in lots %}
|
||||||
{% if lot.is_incoming %}
|
{% if lot.is_incoming %}
|
||||||
<li>
|
<li>
|
||||||
|
@ -219,6 +224,11 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
|
<ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('inventory.new_transfer', type_id='outgoing') }}">
|
||||||
|
<i class="bi bi-plus" style="font-size: larger;"></i><span>New Outgoing lot</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
{% for lot in lots %}
|
{% for lot in lots %}
|
||||||
{% if lot.is_outgoing %}
|
{% if lot.is_outgoing %}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -47,10 +47,10 @@
|
||||||
{% if lot.is_temporary or not lot.transfer.closed %}
|
{% if lot.is_temporary or not lot.transfer.closed %}
|
||||||
|
|
||||||
{% if lot and lot.is_temporary %}
|
{% if lot and lot.is_temporary %}
|
||||||
<a type="button" href="{{ url_for('inventory.new_transfer', lot_id=lot.id, type_id='outgoing') }}" class="btn btn-primary doTransfer" >
|
<a type="button" href="{{ url_for('inventory.lot_new_transfer', lot_id=lot.id, type_id='outgoing') }}" class="btn btn-primary doTransfer" >
|
||||||
Create Outgoing Lot
|
Create Outgoing Lot
|
||||||
</a>
|
</a>
|
||||||
<a type="button" href="{{ url_for('inventory.new_transfer', lot_id=lot.id, type_id='incoming') }}" class="btn btn-primary doTransfer">
|
<a type="button" href="{{ url_for('inventory.lot_new_transfer', lot_id=lot.id, type_id='incoming') }}" class="btn btn-primary doTransfer">
|
||||||
Create Incoming Lot
|
Create Incoming Lot
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Reference in New Issue