[MERGE]: Merge with lp:~openerp-dev/openobject-addons/ksa-addons2

bzr revid: rpa@tinyerp.com-20101122134716-7ostuxk7lpxdk5yt
This commit is contained in:
rpa (Open ERP)
2010-11-22 19:17:16 +05:30
5 changed files with 43 additions and 22 deletions
+4 -8
View File
@@ -165,17 +165,13 @@ class procurement_order(osv.osv):
"""
return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids))
def check_move_done(self, cr, uid, ids, context={}):
def check_move_done(self, cr, uid, ids, context=None):
""" Checks if move is done or not.
@return: True or False.
"""
res = True
for proc in self.browse(cr, uid, ids, context):
if proc.move_id:
if not proc.move_id.state=='done':
res = False
return res
if not context:
context = {}
return all(not procurement.move_id or procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context))
#
# This method may be overrided by objects that override procurement.order
# for computing their own purpose
+5
View File
@@ -171,10 +171,15 @@
<field name="location_id" ref="stock_location_components"/>
</record>
<function model="stock.inventory" name="action_confirm">
<function eval="[[]]" model="stock.inventory" name="search"/>
</function>
<function model="stock.inventory" name="action_done">
<function eval="[[]]" model="stock.inventory" name="search"/>
</function>
<!-- Multi Company -->
<record id="res_partner_tinyshop0" model="res.partner">
+4 -7
View File
@@ -118,7 +118,7 @@
</form>
</field>
</page><page string="Posted Inventory" groups="base.group_extended">
<field colspan="2" name="move_ids" nolabel="1" widget="one2many_list">
<field colspan="2" name="move_ids" nolabel="1" widget="one2many_list" context="{'inventory_id':active_id}" >
<tree string="Stock Moves">
<field name="product_id"/>
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
@@ -127,17 +127,14 @@
<button name="%(track_line)d" string="Split in production lots" type="action"
icon="terp-stock_effects-object-colorize"
attrs="{'invisible': [('prodlot_id','&lt;&gt;',False)]}"
context="{'default_use_exist': picking_id.type=='in'}"
states="draft,done,cancel"
context="{'inventory_id':parent.id}"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,done,cancel"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
context="{'inventory_id':parent.id}"
states="draft,done,cancel"/>
<field name="location_id"/>
<field name="location_dest_id"/>
+12 -2
View File
@@ -218,10 +218,14 @@ class split_in_production_lot(osv.osv_memory):
@param context: A standard dictionary
@return:
"""
if context is None:
context = {}
inventory_id = context.get('inventory_id', False)
prodlot_obj = self.pool.get('stock.production.lot')
inventory_obj = self.pool.get('stock.inventory')
move_obj = self.pool.get('stock.move')
new_move = []
for data in self.browse(cr, uid, ids):
for data in self.browse(cr, uid, ids, context=context):
for move in move_obj.browse(cr, uid, move_ids):
move_qty = move.product_qty
quantity_rest = move.product_qty
@@ -249,6 +253,7 @@ class split_in_production_lot(osv.osv_memory):
if quantity_rest > 0:
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
if quantity_rest == 0:
current_move = move.id
prodlot_id = False
@@ -259,7 +264,7 @@ class split_in_production_lot(osv.osv_memory):
'name': line.name,
'product_id': move.product_id.id},
context=context)
move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state})
update_val = {}
@@ -268,6 +273,11 @@ class split_in_production_lot(osv.osv_memory):
update_val['product_uos_qty'] = uos_qty_rest
update_val['state'] = move.state
move_obj.write(cr, uid, [move.id], update_val)
if inventory_id and new_move:
for m_id in new_move:
inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context)
return new_move
split_in_production_lot()
+18 -5
View File
@@ -34,12 +34,17 @@ class stock_split_into(osv.osv_memory):
}
def split(self, cr, uid, data, context=None):
if context is None:
context = {}
inventory_id = context.get('inventory_id', False)
rec_id = context and context.get('active_ids', False)
move_obj = self.pool.get('stock.move')
track_obj = self.pool.get('stock.tracking')
inventory_obj = self.pool.get('stock.inventory')
quantity = self.browse(cr, uid, data[0], context).quantity or 0.0
for move in move_obj.browse(cr, uid, rec_id):
new_move = []
quantity_rest = move.product_qty - quantity
#if move.tracking_id :
# raise osv.except_osv(_('Error!'), _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \
@@ -56,12 +61,14 @@ class stock_split_into(osv.osv_memory):
'product_uos_qty': quantity,
'product_uos': move.product_uom.id,
})
if quantity_rest>0:
quantity_rest = move.product_qty - quantity
tracking_id = track_obj.create(cr, uid, {})
tracking_id = track_obj.create(cr, uid, {}, context=context)
if quantity==0.0:
move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id})
else:
move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id}, context=context)
else:
default_val = {
'product_qty': quantity_rest,
'product_uos_qty': quantity_rest,
@@ -69,7 +76,13 @@ class stock_split_into(osv.osv_memory):
'state': move.state,
'product_uos': move.product_uom.id
}
move_obj.copy(cr, uid, move.id, default_val)
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
if inventory_id and new_move:
for m_id in new_move:
inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context)
return {}
stock_split_into()