Add force draft shipment in return

This commit is contained in:
Oscar 2022-01-19 11:10:01 -05:00
parent 21f92eee34
commit 8f76885b87
3 changed files with 47 additions and 0 deletions

View file

@ -38,6 +38,7 @@ def register():
shipment.Assign,
inventory.CreateInventories,
shipment.ShipmentInForceDraft,
shipment.ShipmentInReturnForceDraft,
shipment.ShipmentInternalLoadStock,
module='stock_co', type_='wizard')
Pool.register(

View file

@ -311,6 +311,42 @@ class ShipmentInForceDraft(Wizard):
return 'end'
class ShipmentInReturnForceDraft(Wizard):
'Shipment In Return Force Draft'
__name__ = 'stock.shipment.in.return.force_draft'
start_state = 'force_draft'
force_draft = StateTransition()
def transition_force_draft(self):
shipment = Table('stock_shipment_in_return')
move = Table('stock_move')
id_shipment = Transaction().context['active_id']
cursor = Transaction().connection.cursor()
if not id_shipment:
return 'end'
cursor.execute(*shipment.update(
columns=[shipment.state],
values=['draft'],
where=shipment.id == id_shipment)
)
pool = Pool()
ShipmentIn = pool.get('stock.shipment.in.return')
shipment_in = ShipmentIn(id_shipment)
# moves_ids = [m.id for m in shipment_in.moves]
# if moves_ids:
# cursor.execute(*move.delete(
# where=move.id.in_(moves_ids))
# )
moves_ids = [m.id for m in shipment_in.moves]
if moves_ids:
cursor.execute(*move.update(
columns=[move.state],
values=['draft'],
where=move.id.in_(moves_ids))
)
return 'end'
class ShipmentDetailedStart(ModelView):
'Shipment Detailed Start'
__name__ = 'stock.shipment.shipment_detailed.start'

View file

@ -86,6 +86,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="action" ref="shipment_in_force_draft"/>
</record>
<record model="ir.action.wizard" id="shipment_in_return_force_draft">
<field name="name">Force Draft</field>
<field name="wiz_name">stock.shipment.in.return.force_draft</field>
</record>
<record model="ir.action.keyword" id="action_shipment_in_return_force_draft_keyword">
<field name="keyword">form_action</field>
<field name="model">stock.shipment.in.return,-1</field>
<field name="action" ref="shipment_in_return_force_draft"/>
</record>
<record model="ir.action.wizard" id="wizard_shipment_internal_load_stock">
<field name="name">Load Current Stock</field>
<field name="wiz_name">stock_co.shipment_internal_load_stock</field>