[IMP] stock : Incoming product form view is improved.

bzr revid: vir@tinyerp.com-20100528094840-7podf6mi8p6cft8p
This commit is contained in:
Vir (Open ERP) 2010-05-28 15:18:40 +05:30
parent fdcb3c5170
commit 7fc422fe2b
3 changed files with 36 additions and 34 deletions

View File

@ -223,7 +223,7 @@ class purchase_order(osv.osv):
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
# TODO: temporary fix in 5.0, to remove in 5.2 when subflows support
# TODO: temporary fix in 5.0, to remove in 5.2 when subflows support
# automatically sending subflow.delete upon deletion
wf_service = netsvc.LocalService("workflow")
for id in unlink_ids:
@ -248,7 +248,7 @@ class purchase_order(osv.osv):
return {'value':{'location_id': res, 'dest_address_id': False}}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
return {'value':{'partner_address_id': False, 'fiscal_position': False}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default'])
@ -264,14 +264,14 @@ class purchase_order(osv.osv):
def wkf_confirm_order(self, cr, uid, ids, context={}):
todo = []
for po in self.browse(cr, uid, ids):
if self.pool.get('res.partner.event.type').check(cr, uid, 'purchase_open'):
self.pool.get('res.partner.event').create(cr, uid, {'name':'Purchase Order: '+po.name, 'partner_id':po.partner_id.id, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id':uid, 'partner_type':'retailer', 'probability': 1.0, 'planned_cost':po.amount_untaxed})
if not po.order_line:
raise osv.except_osv(_('Error !'),_('You can not confirm purchase order without Purchase Order Lines.'))
for line in po.order_line:
for line in po.order_line:
if line.state=='draft':
todo.append(line.id)
todo.append(line.id)
current_name = self.name_get(cr, uid, ids)[0][1]
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
for id in ids:
@ -315,13 +315,13 @@ class purchase_order(osv.osv):
wf_service = netsvc.LocalService("workflow")
for p_id in ids:
# Deleting the existing instance of workflow for PO
wf_service.trg_delete(uid, 'purchase.order', p_id, cr)
wf_service.trg_delete(uid, 'purchase.order', p_id, cr)
wf_service.trg_create(uid, 'purchase.order', p_id, cr)
return True
def action_invoice_create(self, cr, uid, ids, *args):
res = False
journal_obj = self.pool.get('account.journal')
for o in self.browse(cr, uid, ids):
il = []
@ -439,7 +439,7 @@ class purchase_order(osv.osv):
})
if order_line.move_dest_id:
self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id})
todo_moves.append(move)
todo_moves.append(move)
self.pool.get('stock.move').action_confirm(cr, uid, todo_moves)
self.pool.get('stock.move').force_assign(cr, uid, todo_moves)
wf_service = netsvc.LocalService("workflow")
@ -461,26 +461,26 @@ class purchase_order(osv.osv):
def do_merge(self, cr, uid, ids, context):
"""
To merge similar type of purchase orders.
Orders will only be merged if:
* Purchase Orders are in draft
* Purchase Orders belong to the same partner
"""
To merge similar type of purchase orders.
Orders will only be merged if:
* Purchase Orders are in draft
* Purchase Orders belong to the same partner
* Purchase Orders are have same stock location, same pricelist
Lines will only be merged if:
* Order lines are exactly the same except for the quantity and unit
Lines will only be merged if:
* Order lines are exactly the same except for the quantity and unit
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID or list of IDs
@param context: A standard dictionary
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return: new purchase order id
"""
wf_service = netsvc.LocalService("workflow")
def make_key(br, fields):
"""
wf_service = netsvc.LocalService("workflow")
def make_key(br, fields):
list_key = []
for field in fields:
field_val = getattr(br, field)
@ -498,9 +498,9 @@ class purchase_order(osv.osv):
return tuple(list_key)
# compute what the new orders should contain
new_orders = {}
for porder in [order for order in self.browse(cr, uid, ids) if order.state == 'draft']:
order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
new_order = new_orders.setdefault(order_key, ({}, []))
@ -543,7 +543,7 @@ class purchase_order(osv.osv):
o_line[field] = field_val
o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
allorders = []
for order_key, (order_data, old_ids) in new_orders.iteritems():
@ -603,7 +603,7 @@ class purchase_order_line(osv.osv):
'invoiced': fields.boolean('Invoiced', readonly=True),
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner"),
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
}
_defaults = {
'product_qty': lambda *a: 1.0,
@ -623,7 +623,7 @@ class purchase_order_line(osv.osv):
partner_id, date_order=False, fiscal_position=False, date_planned=False,
name=False, price_unit=False, notes=False):
if not pricelist:
raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist in the purchase form !\nPlease set one before choosing a product.'))
raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.'))
if not partner_id:
raise osv.except_osv(_('No Partner!'), _('You have to select a partner in the purchase form !\nPlease set one partner before choosing a product.'))
if not product:
@ -694,7 +694,7 @@ class purchase_order_line(osv.osv):
return res
def action_confirm(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state': 'confirmed'}, context)
return True
return True
purchase_order_line()
class mrp_procurement(osv.osv):
@ -702,7 +702,7 @@ class mrp_procurement(osv.osv):
_columns = {
'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'),
}
def action_po_assign(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign purchase order to procurements
@return: True

View File

@ -511,12 +511,12 @@ class sale_order(osv.osv):
def action_invoice_end(self, cr, uid, ids, context=None):
if context is None:
context = {}
for order in self.browse(cr, uid, ids, context=context):
for line in order.order_line:
if line.state == 'exception':
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'state': 'confirmed'}, context=context)
if order.state == 'invoice_except':
self.write(cr, uid, [order.id], {'state' : 'progress'}, context=context)
@ -1086,7 +1086,7 @@ class sale_order_line(osv.osv):
warning = {
'title': 'No Pricelist !',
'message':
'You have to select a pricelist in the sale form !\n'
'You have to select a pricelist or a customer in the sale form !\n'
'Please set one before choosing a product.'
}
else:

View File

@ -1495,8 +1495,10 @@
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
<field name="tracking_id"/>
<newline/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
<group col="2" colspan="2">
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
</group>
<separator colspan="4" string="Move State"/>
<field name="state"/>
<group col="5" colspan="2">