[FIX] stock: correct incomplete work
bzr revid: hmo@tinyerp.com-20100331065102-lkawbyzxkh9mvndv
This commit is contained in:
parent
dbcbd1185b
commit
101b96a591
|
@ -48,10 +48,11 @@ Thanks to the double entry management, the inventory controlling is powerful and
|
|||
"wizard/stock_inventory_set_stock_zero_view.xml",
|
||||
"wizard/stock_fill_inventory_view.xml",
|
||||
"wizard/stock_invoice_onshipping_view.xml",
|
||||
"wizard/stock_inventory_merge_view.xml",
|
||||
"wizard/stock_location_product_view.xml",
|
||||
"wizard/stock_inventory_line_split_view.xml",
|
||||
"wizard/stock_change_standard_price_view.xml",
|
||||
|
||||
"wizard/stock_picking_make_view.xml",
|
||||
"wizard/stock_traceability_view.xml",
|
||||
"stock_workflow.xml",
|
||||
"stock_incoterms.xml",
|
||||
|
|
|
@ -23,18 +23,17 @@ import stock_traceability
|
|||
import stock_move
|
||||
import stock_partial_picking
|
||||
import stock_partial_move
|
||||
import wizard_picking_make
|
||||
import stock_picking_make
|
||||
import wizard_replacement
|
||||
import wizard_return
|
||||
import wizard_split_lot_line
|
||||
import wizard_ups
|
||||
import inventory_merge
|
||||
import stock_inventory_merge
|
||||
import stock_inventory_set_stock_zero
|
||||
import stock_fill_inventory
|
||||
import stock_inventory_line_split
|
||||
import stock_invoice_onshipping
|
||||
import stock_location_product
|
||||
import stock_change_standard_price
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -36,7 +36,18 @@ class stock_inventory_merge(osv.osv_memory):
|
|||
}
|
||||
|
||||
def do_merge(self, cr, uid, ids, context):
|
||||
|
||||
"""
|
||||
To merge selected Inventories.
|
||||
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: List of IDs selected
|
||||
@param context: A standard dictionary
|
||||
|
||||
@return:
|
||||
|
||||
"""
|
||||
invent_obj = self.pool.get('stock.inventory')
|
||||
invent_line_obj = self.pool.get('stock.inventory.line')
|
||||
|
||||
|
@ -46,10 +57,7 @@ class stock_inventory_merge(osv.osv_memory):
|
|||
raise osv.except_osv(_('Warning'),
|
||||
_('Please select at least two inventories.'))
|
||||
|
||||
|
||||
|
||||
for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context):
|
||||
print"-------active-ids----",context['active_ids']
|
||||
if inventory.state == "done":
|
||||
raise osv.except_osv(_('Warning'),
|
||||
_('Merging is only allowed on draft inventories.'))
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="name_form" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.merge.form</field>
|
||||
<field name="model">stock.inventory.merge</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Merge inventories">
|
||||
<separator colspan="4" string="Merge inventories" />
|
||||
<label string="Do you want to merge theses inventories ?"/>
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="do_merge" string="Yes" type="object" icon="gtk-apply"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<act_window name="Merge inventories"
|
||||
res_model="stock.inventory.merge"
|
||||
src_model="stock.inventory"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="action_view_stock_merge_inventories"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -20,83 +20,60 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from service import web_services
|
||||
from tools.misc import UpdateableStr, UpdateableDict
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
import wizard
|
||||
|
||||
class stock_picking_make(osv.osv_memory):
|
||||
_name = "stock.picking.make"
|
||||
_description = "Make picking"
|
||||
_name = 'stock.picking.make'
|
||||
_description = "Make Picking"
|
||||
|
||||
_columns = {
|
||||
'pickings': fields.many2many('stock.picking', 'Picking', required=True),
|
||||
}
|
||||
|
||||
ARCH = '''<?xml version="1.0"?>
|
||||
<form string="Make picking">
|
||||
<field name="pickings" nolabel="1" colspan="4"
|
||||
width="600" height="300"/>
|
||||
</form>'''
|
||||
|
||||
FIELDS = {
|
||||
'pickings': {
|
||||
'string': 'Picking',
|
||||
'type': 'many2many',
|
||||
'relation': 'stock.picking',
|
||||
'readonly': True,
|
||||
},
|
||||
}
|
||||
|
||||
def _get_value(obj, cursor, user, data, context):
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
picking_obj = pool.get('stock.picking')
|
||||
|
||||
picking_ids = picking_obj.search(cursor, user, [
|
||||
('id', 'in', data['ids']),
|
||||
('state', '<>', 'done'),
|
||||
('state', '<>', 'cancel')], context=context)
|
||||
return {'pickings': picking_ids}
|
||||
|
||||
def _make_packing(obj, cursor, user, data, context):
|
||||
wkf_service = netsvc.LocalService('workflow')
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
picking_obj = pool.get('stock.picking')
|
||||
ids = data['form']['pickings'][0][2]
|
||||
print"-------ids--------",ids
|
||||
picking_obj.force_assign(cursor, user, ids)
|
||||
picking_obj.action_move(cursor, user, ids)
|
||||
for picking_id in ids:
|
||||
wkf_service.trg_validate(user, 'stock.picking', picking_id,
|
||||
'button_done', cursor)
|
||||
return {}
|
||||
|
||||
class stock_picking_make(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_value],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': ARCH,
|
||||
'fields': FIELDS,
|
||||
'state': [
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('make', 'Ok', 'gtk-apply', True)
|
||||
],
|
||||
},
|
||||
},
|
||||
'make': {
|
||||
'actions': [_make_packing],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state':'end',
|
||||
},
|
||||
},
|
||||
'picking_ids': fields.many2many('stock.picking', 'stock_picking_ids', 'parent_id', 'child_id', 'Pickings'),
|
||||
}
|
||||
|
||||
stock_picking_make('stock.picking.make')
|
||||
def default_get(self, cursor, user, fields, context):
|
||||
"""
|
||||
To get default values for the object.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
res = super(stock_picking_make, self).default_get(cursor, user, fields, context=context)
|
||||
record_ids = context and context.get('active_ids',False) or False
|
||||
if record_ids:
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
picking_ids = picking_obj.search(cursor, user, [
|
||||
('id', 'in', record_ids),
|
||||
('state', '<>', 'done'),
|
||||
('state', '<>', 'cancel')], context=context)
|
||||
res['picking_ids'] = picking_ids
|
||||
return res
|
||||
|
||||
def make_packing(self, cursor, user, ids, context):
|
||||
"""
|
||||
Make Picking.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
record_ids = context and context.get('active_ids',False) or False
|
||||
wkf_service = netsvc.LocalService('workflow')
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
data = self.read(cursor, user, ids[0])
|
||||
pick_ids = data['picking_ids']
|
||||
picking_obj.force_assign(cursor, user, pick_ids)
|
||||
picking_obj.action_move(cursor, user, pick_ids)
|
||||
for picking_id in ids:
|
||||
wkf_service.trg_validate(user, 'stock.picking', picking_id,
|
||||
'button_done', cursor)
|
||||
return {}
|
||||
|
||||
stock_picking_make()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_stock_make_picking_wizard" model="ir.ui.view">
|
||||
<field name="name">Make Picking</field>
|
||||
<field name="model">stock.picking.make</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Make Picking">
|
||||
<field name="picking_ids" nolabel="1" colspan="4"
|
||||
width="600" height="300"/>
|
||||
<separator string="" colspan="4" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="make_packing" string="Ok"
|
||||
type="object" icon="gtk-apply" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="act_stock_make_picking_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Make Picking</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.picking.make</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue