add option force draft shipment in
This commit is contained in:
parent
fe0b72237d
commit
0b7911f058
|
@ -35,6 +35,7 @@ def register():
|
|||
shipment.ShipmentInternalForceDraft,
|
||||
shipment.Assign,
|
||||
inventory.CreateInventories,
|
||||
shipment.ShipmentInForceDraft,
|
||||
module='stock_co', type_='wizard')
|
||||
Pool.register(
|
||||
stock.MoveByProduct,
|
||||
|
|
|
@ -337,3 +337,7 @@ msgstr "Cancelar"
|
|||
msgctxt "wizard_button:stock_co.warehouse_stock_detailed,start,print_:"
|
||||
msgid "Print"
|
||||
msgstr "Imprimir"
|
||||
|
||||
msgctxt "model:ir.action,name:shipment_in_force_draft"
|
||||
msgid "Force Draft"
|
||||
msgstr "Forzar a Borrador"
|
||||
|
|
38
shipment.py
38
shipment.py
|
@ -309,6 +309,40 @@ class ShipmentInternalForceDraft(Wizard):
|
|||
return 'end'
|
||||
|
||||
|
||||
class ShipmentInForceDraft(Wizard):
|
||||
'Shipment In Force Draft'
|
||||
__name__ = 'stock.shipment.in.force_draft'
|
||||
start_state = 'force_draft'
|
||||
force_draft = StateTransition()
|
||||
|
||||
def transition_force_draft(self):
|
||||
shipment = Table('stock_shipment_in')
|
||||
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')
|
||||
shipmentin = ShipmentIn(id_shipment)
|
||||
moves_ids = [m.id for m in shipmentin.inventory_moves]
|
||||
cursor.execute(*move.delete(
|
||||
where=move.id.in_(moves_ids))
|
||||
)
|
||||
moves_ids = [m.id for m in shipmentin.incoming_moves]
|
||||
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'
|
||||
|
@ -379,7 +413,7 @@ class ShipmentDetailedReport(Report):
|
|||
shipments_id = [model + ',' + str(sh['id']) for sh in shipments]
|
||||
fields_names = [
|
||||
'product.account_category.name', 'product.name', 'product.cost_price',
|
||||
'quantity', 'to_location.name'
|
||||
'quantity', 'to_location.name', 'from_location.name'
|
||||
]
|
||||
fields = ModelShipment.fields_get(fields_names=['operation_center'])
|
||||
if 'operation_center' in fields.keys():
|
||||
|
@ -415,7 +449,7 @@ class ShipmentDetailedReport(Report):
|
|||
'cost_price': cost_price,
|
||||
'category': category,
|
||||
'category_ad': category_ad,
|
||||
'cost_base': float(cost_price) * quantity,
|
||||
'cost_base': Decimal(str(round(float(cost_price) * quantity, 2))),
|
||||
|
||||
}
|
||||
try:
|
||||
|
|
12
shipment.xml
12
shipment.xml
|
@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<data>
|
||||
<menuitem parent="stock.menu_stock" sequence="200"
|
||||
name="Reports" id="menu_reports" icon="tryton-folder"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="create_internal_shipment_start_view_form">
|
||||
<field name="model">stock_co.create_internal_shipment.start</field>
|
||||
<field name="type">form</field>
|
||||
|
@ -75,5 +75,15 @@ this repository contains the full copyright notices and license terms. -->
|
|||
|
||||
<menuitem parent="menu_reports" sequence="100" action="wizard_shipment_detailed"
|
||||
id="menu_print_shipment_detailed" icon="tryton-print"/>
|
||||
|
||||
<record model="ir.action.wizard" id="shipment_in_force_draft">
|
||||
<field name="name">Force Draft</field>
|
||||
<field name="wiz_name">stock.shipment.in.force_draft</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="action_shipment_in_force_draft_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">stock.shipment.in,-1</field>
|
||||
<field name="action" ref="shipment_in_force_draft"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
Binary file not shown.
9
stock.py
9
stock.py
|
@ -31,12 +31,21 @@ class Move(metaclass=PoolMeta):
|
|||
description = fields.Char('Description', select=True, states=STATES_MOVE)
|
||||
current_stock = fields.Function(fields.Float('Current Stock',
|
||||
depends=['product']), 'on_change_with_current_stock')
|
||||
reference = fields.Function(fields.Char('Reference',
|
||||
depends=['product'], help='reference of product'), 'get_reference')
|
||||
|
||||
@fields.depends('current_stock')
|
||||
def on_change_product(self, name=None):
|
||||
super(Move, self).on_change_product()
|
||||
self.current_stock = self.on_change_with_current_stock()
|
||||
|
||||
@fields.depends('product')
|
||||
def get_reference(self, name=None):
|
||||
reference = None
|
||||
if self.product and hasattr(self.product, 'reference') and self.product.reference:
|
||||
reference = self.product.reference
|
||||
return reference
|
||||
|
||||
@fields.depends('product', 'from_location', 'to_location')
|
||||
def on_change_with_current_stock(self, name=None):
|
||||
res = 0
|
||||
|
|
|
@ -7,6 +7,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<newline/>
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3"/>
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
<label name="current_stock"/>
|
||||
<field name="current_stock"/>
|
||||
</xpath>
|
||||
|
|
Loading…
Reference in New Issue