[MERGE] Merge from trunk-wms

bzr revid: jco@openerp.com-20140124105943-hydqvz0klylm3ed5
This commit is contained in:
Josse Colpaert 2014-01-24 11:59:43 +01:00
commit 6801d0c5af
8 changed files with 29 additions and 71 deletions

View File

@ -12,7 +12,7 @@
<field eval="False" name="doall"/>
<field eval="'procurement.order'" name="model"/>
<field eval="'run_scheduler'" name="function"/>
<field eval="'(False,True)'" name="args"/>
<field eval="'(True,)'" name="args"/>
</record>
<record id="sequence_proc_group_type" model="ir.sequence.type">

View File

@ -403,7 +403,7 @@ class procurement_order(osv.osv):
def _run(self, cr, uid, procurement, context=None):
requisition_obj = self.pool.get('purchase.requisition')
warehouse_obj = self.pool.get('stock.warehouse')
if procurement.product_id.purchase_requisition:
if procurement.rule_id and procurement.rule_id.action == 'buy' and procurement.product_id.purchase_requisition:
warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', procurement.company_id.id)], context=context)
requisition_id = requisition_obj.create(cr, uid, {
'origin': procurement.origin,

View File

@ -275,7 +275,7 @@ class procurement_order(osv.osv):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
move_obj = self.pool.get('stock.move')
#Minimum stock rules
self. _procure_orderpoint_confirm(cr, uid, automatic=False,use_new_cursor=False, context=context, user_id=False)
self. _procure_orderpoint_confirm(cr, uid, use_new_cursor=False, context=context, user_id=False)
#Search all confirmed stock_moves and try to assign them
confirmed_ids = move_obj.search(cr, uid, [('state', '=', 'confirmed'), ('company_id','=', company.id)], limit=None, order='picking_priority desc, date_expected asc', context=context)
@ -295,54 +295,6 @@ class procurement_order(osv.osv):
pass
return {}
def _prepare_automatic_op_procurement(self, cr, uid, product, warehouse, location_id, context=None):
return {'name': _('Automatic OP: %s') % (product.name,),
'origin': _('SCHEDULER'),
'date_planned': datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'product_id': product.id,
'product_qty': -product.virtual_available,
'product_uom': product.uom_id.id,
'location_id': location_id,
'company_id': warehouse.company_id.id,
}
def create_automatic_op(self, cr, uid, context=None):
"""
Create procurement of virtual stock < 0
@param self: The object pointer
@param cr: The current row, from the database cursor,
@param uid: The current user ID for security checks
@param context: A standard dictionary for contextual values
@return: Dictionary of values
"""
if context is None:
context = {}
product_obj = self.pool.get('product.product')
proc_obj = self.pool.get('procurement.order')
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_ids = warehouse_obj.search(cr, uid, [], context=context)
products_ids = product_obj.search(cr, uid, [], order='id', context=context)
for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context):
context['warehouse'] = warehouse
# Here we check products availability.
# We use the method 'read' for performance reasons, because using the method 'browse' may crash the server.
for product_read in product_obj.read(cr, uid, products_ids, ['virtual_available'], context=context):
if product_read['virtual_available'] >= 0.0:
continue
product = product_obj.browse(cr, uid, [product_read['id']], context=context)[0]
location_id = warehouse.lot_stock_id.id
proc_id = proc_obj.create(cr, uid,
self._prepare_automatic_op_procurement(cr, uid, product, warehouse, location_id, context=context),
context=context)
self.assign(cr, uid, [proc_id])
self.run(cr, uid, [proc_id])
return True
def _get_orderpoint_date_planned(self, cr, uid, orderpoint, start_date, context=None):
date_planned = start_date + \
@ -365,7 +317,7 @@ class procurement_order(osv.osv):
[order_point.product_id.id],
{'location': order_point.location_id.id})[order_point.product_id.id]['virtual_available']
def _procure_orderpoint_confirm(self, cr, uid, automatic=False,\
def _procure_orderpoint_confirm(self, cr, uid, \
use_new_cursor=False, context=None, user_id=False):
'''
Create procurement based on Orderpoint
@ -388,8 +340,6 @@ class procurement_order(osv.osv):
procurement_obj = self.pool.get('procurement.order')
offset = 0
ids = [1]
if automatic:
self.create_automatic_op(cr, uid, context=context)
while ids:
ids = orderpoint_obj.search(cr, uid, [], offset=offset, limit=100)
for op in orderpoint_obj.browse(cr, uid, ids, context=context):

View File

@ -2201,6 +2201,14 @@ class stock_inventory_line(osv.osv):
_name = "stock.inventory.line"
_description = "Inventory Line"
_rec_name = "inventory_id"
_order = "inventory_id, location_name, product_code, product_name, prod_lot_id"
def _get_product_name_change(self, cr, uid, ids, context=None):
return self.pool.get('stock.inventory.line').search(cr, uid, [('product_id', 'in', ids)], context=context)
def _get_location_change(self, cr, uid, ids, context=None):
return self.pool.get('stock.inventory.line').search(cr, uid, [('location_id', 'in', ids)], context=context)
_columns = {
'inventory_id': fields.many2one('stock.inventory', 'Inventory', ondelete='cascade', select=True),
'location_id': fields.many2one('stock.location', 'Location', required=True, select=True),
@ -2213,6 +2221,15 @@ class stock_inventory_line(osv.osv):
'state': fields.related('inventory_id', 'state', type='char', string='Status', readonly=True),
'th_qty': fields.float('Theoretical Quantity', readonly=True),
'partner_id': fields.many2one('res.partner', 'Owner'),
'product_name': fields.related('product_id', 'name', type='char', string='Product name', store={
'product.product': (_get_product_name_change, ['name', 'default_code'], 20),
'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['product_id'], 20),}),
'product_code': fields.related('product_id', 'default_code', type='char', string='Product code', store={
'product.product': (_get_product_name_change, ['name', 'default_code'], 20),
'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['product_id'], 20),}),
'location_name': fields.related('location_id', 'complete_name', type='char', string='Location name', store={
'stock.location': (_get_location_change, ['name', 'location_id', 'active'], 20),
'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['location_id'], 20),}),
}
_defaults = {
@ -2719,10 +2736,12 @@ class stock_warehouse(osv.osv):
'warehouse_id': new_id,
'code': 'outgoing',
'sequence_id': out_seq_id,
'return_picking_type_id': in_type_id,
'default_location_src_id': output_loc.id,
'default_location_dest_id': customer_loc.id,
'sequence': max_sequence + 4,
'color': color}, context=context)
picking_type_obj.write(cr, uid, [in_type_id], {'return_picking_type_id': out_type_id}, context=context)
int_type_id = picking_type_obj.create(cr, uid, vals={
'name': _('Internal Transfers'),
'warehouse_id': new_id,

View File

@ -1848,7 +1848,7 @@
<field name="res_model">stock.warehouse.orderpoint</field>
</record>
<record model="ir.actions.act_window" id="product_open_quants">
<field name="context">{'search_default_product_id': active_id}</field>
<field name="context">{'search_default_product_id': active_id, 'search_default_locationgroup':1}</field>
<field name="name">Quants</field>
<field name="res_model">stock.quant</field>
</record>
@ -1891,10 +1891,9 @@
</xpath>
<xpath expr="//div[@name='buttons']" position="inside">
<button string="Inventory" name="%(action_product_location_tree)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_locations"/>
<button string="Inventory" name="%(product_open_quants)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_locations"/>
<button string="Moves" name= "%(act_product_stock_move_open)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_user"/>
<button string="Orderpoints" name="%(product_open_orderpoint)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}"/>
<button string="Quants" name="%(product_open_quants)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="base.group_no_one"/>
</xpath>
<xpath expr="//group[@string='Sale Conditions']" position="inside">

View File

@ -31,13 +31,6 @@ class procurement_compute(osv.osv_memory):
_name = 'procurement.orderpoint.compute'
_description = 'Automatic Order Point'
_columns = {
'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
}
_defaults = {
'automatic': False,
}
def _procure_calculation_orderpoint(self, cr, uid, ids, context=None):
"""
@ -51,7 +44,7 @@ class procurement_compute(osv.osv_memory):
#As this function is in a new thread, I need to open a new cursor, because the old one may be closed
new_cr = self.pool.db.cursor()
for proc in self.browse(new_cr, uid, ids, context=context):
proc_obj._procure_orderpoint_confirm(new_cr, uid, automatic=proc.automatic, use_new_cursor=new_cr.dbname, context=context)
proc_obj._procure_orderpoint_confirm(new_cr, uid, use_new_cursor=new_cr.dbname, context=context)
#close the new cursor
new_cr.close()
return {}

View File

@ -12,9 +12,6 @@
<group>
<label string="Wizard checks all the stock minimum rules and generate procurement order."/>
</group>
<group col="2">
<field name="automatic"/>
</group>
<footer>
<button name="procure_calculation" string="Compute Stock" type="object" class="oe_highlight" />
or

View File

@ -66,11 +66,11 @@ class stock_return_picking(osv.osv_memory):
if pick.state != 'done':
raise osv.except_osv(_('Warning!'), _("You may only return pickings that are Done!"))
for line in pick.move_lines:
qty = line.product_qty
qty = line.product_uom_qty
if line.returned_move_ids:
for returned_move in line.returned_move_ids:
if returned_move.product_id.id == line.product_id.id:
qty -= returned_move.product_qty
qty -= returned_move.product_uom_qty
if qty > 0:
result1.append({'product_id': line.product_id.id, 'quantity': qty, 'move_id': line.id})
@ -127,7 +127,7 @@ class stock_return_picking(osv.osv_memory):
raise osv.except_osv(_('Warning!'), _("Please specify at least one non-zero quantity."))
pick_obj.action_confirm(cr, uid, [new_picking], context=context)
pick_obj.force_assign(cr, uid, [new_picking], context)
pick_obj.action_assign(cr, uid, [new_picking], context)
return new_picking, pick_type_id
def create_returns(self, cr, uid, ids, context=None):