[IMP]stock : added a new filed type for set a location in or out and make a onchane & default method for it and set action of moves for its view
bzr revid: mma@tinyerp.com-20120830065255-ogmp9xytwd3kr8f8
This commit is contained in:
parent
64423a44d9
commit
b185760c7b
|
@ -1653,6 +1653,7 @@ class stock_move(osv.osv):
|
|||
|
||||
# used for colors in tree views:
|
||||
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
|
||||
'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."),
|
||||
}
|
||||
def _check_location(self, cr, uid, ids, context=None):
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -1732,10 +1733,27 @@ class stock_move(osv.osv):
|
|||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
return user.company_id.partner_id.id
|
||||
|
||||
def _default_move_type(self, cr, uid, context=None):
|
||||
""" Gets default type of move
|
||||
@return: type
|
||||
"""
|
||||
picking_type = context.get('picking_type')
|
||||
type = False
|
||||
if context is None:
|
||||
context = {}
|
||||
if picking_type == 'in':
|
||||
type = 'in'
|
||||
elif picking_type == 'out':
|
||||
type = 'out'
|
||||
else:
|
||||
type = 'internal'
|
||||
return type
|
||||
|
||||
_defaults = {
|
||||
'location_id': _default_location_source,
|
||||
'location_dest_id': _default_location_destination,
|
||||
'partner_id': _default_destination_address,
|
||||
'type': _default_move_type,
|
||||
'state': 'draft',
|
||||
'priority': '1',
|
||||
'product_qty': 1.0,
|
||||
|
@ -1889,6 +1907,26 @@ class stock_move(osv.osv):
|
|||
result['location_dest_id'] = loc_dest_id
|
||||
return {'value': result}
|
||||
|
||||
def onchange_move_type(self, cr, uid, ids, type, context=None):
|
||||
""" On change of move type gives sorce and destination location.
|
||||
@param type: Move Type
|
||||
@return: Dictionary of values
|
||||
"""
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
location_source_id = False
|
||||
location_dest_id = False
|
||||
if type == 'in':
|
||||
location_source_id = 'stock_location_suppliers'
|
||||
location_dest_id = 'stock_location_stock'
|
||||
elif type == 'out':
|
||||
location_source_id = 'stock_location_stock'
|
||||
location_dest_id = 'stock_location_customers'
|
||||
if location_source_id:
|
||||
location_model, location_source_id = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id)
|
||||
if location_dest_id:
|
||||
location_model, location_dest_id = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id)
|
||||
return {'value':{'location_id': location_source_id, 'location_dest_id': location_dest_id}}
|
||||
|
||||
def onchange_date(self, cr, uid, ids, date, date_expected, context=None):
|
||||
""" On change of Scheduled Date gives a Move date.
|
||||
@param date_expected: Scheduled Date
|
||||
|
|
|
@ -1126,6 +1126,7 @@
|
|||
<field name="name"/>
|
||||
<field name="picking_id" string="Reference"/>
|
||||
<field name="origin"/>
|
||||
<field name="type" on_change="onchange_move_type(type)"/>
|
||||
<field name="create_date" invisible="1" groups="base.group_no_one"/>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
|
||||
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
|
||||
|
@ -1239,6 +1240,7 @@
|
|||
</group>
|
||||
<group name="origin_grp" string="Origin">
|
||||
<field name="picking_id"/>
|
||||
<field name="type" on_change="onchange_move_type(type)"/>
|
||||
<field name="location_id" groups="stock.group_locations"/>
|
||||
<field name="create_date" groups="base.group_no_one"/>
|
||||
</group>
|
||||
|
@ -1279,7 +1281,7 @@
|
|||
<record id="view_move_picking_form" model="ir.ui.view">
|
||||
<field name="name">stock.move.form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field eval="4" name="priority"/>
|
||||
<field eval="2" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock Moves" version="7.0">
|
||||
<header>
|
||||
|
@ -1294,6 +1296,7 @@
|
|||
<group>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, parent.partner_id)"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<label for="product_qty"/>
|
||||
<div>
|
||||
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)" class="oe_inline"/>
|
||||
|
@ -1400,6 +1403,21 @@
|
|||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="action_stock_move_tree_all">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_move_tree"/>
|
||||
<field name="act_window_id" ref="action_move_form2"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="action_stock_move_form_all">
|
||||
<field name="sequence" eval="3"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_move_form"/>
|
||||
<field name="act_window_id" ref="action_move_form2"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_move_form2" id="menu_action_move_form2" parent="menu_traceability" sequence="3"/>
|
||||
|
||||
<!--
|
||||
|
|
Loading…
Reference in New Issue