[IMP] stock : Incoming product form view is improved.
bzr revid: vir@tinyerp.com-20100528094840-7podf6mi8p6cft8p
This commit is contained in:
parent
fdcb3c5170
commit
7fc422fe2b
|
@ -223,7 +223,7 @@ class purchase_order(osv.osv):
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
|
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
|
# automatically sending subflow.delete upon deletion
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
for id in unlink_ids:
|
for id in unlink_ids:
|
||||||
|
@ -248,7 +248,7 @@ class purchase_order(osv.osv):
|
||||||
return {'value':{'location_id': res, 'dest_address_id': False}}
|
return {'value':{'location_id': res, 'dest_address_id': False}}
|
||||||
|
|
||||||
def onchange_partner_id(self, cr, uid, ids, part):
|
def onchange_partner_id(self, cr, uid, ids, part):
|
||||||
|
|
||||||
if not part:
|
if not part:
|
||||||
return {'value':{'partner_address_id': False, 'fiscal_position': False}}
|
return {'value':{'partner_address_id': False, 'fiscal_position': False}}
|
||||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default'])
|
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={}):
|
def wkf_confirm_order(self, cr, uid, ids, context={}):
|
||||||
todo = []
|
todo = []
|
||||||
for po in self.browse(cr, uid, ids):
|
for po in self.browse(cr, uid, ids):
|
||||||
|
|
||||||
if self.pool.get('res.partner.event.type').check(cr, uid, 'purchase_open'):
|
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})
|
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:
|
if not po.order_line:
|
||||||
raise osv.except_osv(_('Error !'),_('You can not confirm purchase order without Purchase Order Lines.'))
|
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':
|
if line.state=='draft':
|
||||||
todo.append(line.id)
|
todo.append(line.id)
|
||||||
current_name = self.name_get(cr, uid, ids)[0][1]
|
current_name = self.name_get(cr, uid, ids)[0][1]
|
||||||
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
|
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
@ -315,13 +315,13 @@ class purchase_order(osv.osv):
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
for p_id in ids:
|
for p_id in ids:
|
||||||
# Deleting the existing instance of workflow for PO
|
# 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)
|
wf_service.trg_create(uid, 'purchase.order', p_id, cr)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_invoice_create(self, cr, uid, ids, *args):
|
def action_invoice_create(self, cr, uid, ids, *args):
|
||||||
res = False
|
res = False
|
||||||
|
|
||||||
journal_obj = self.pool.get('account.journal')
|
journal_obj = self.pool.get('account.journal')
|
||||||
for o in self.browse(cr, uid, ids):
|
for o in self.browse(cr, uid, ids):
|
||||||
il = []
|
il = []
|
||||||
|
@ -439,7 +439,7 @@ class purchase_order(osv.osv):
|
||||||
})
|
})
|
||||||
if order_line.move_dest_id:
|
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})
|
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').action_confirm(cr, uid, todo_moves)
|
||||||
self.pool.get('stock.move').force_assign(cr, uid, todo_moves)
|
self.pool.get('stock.move').force_assign(cr, uid, todo_moves)
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
|
@ -461,26 +461,26 @@ class purchase_order(osv.osv):
|
||||||
|
|
||||||
|
|
||||||
def do_merge(self, cr, uid, ids, context):
|
def do_merge(self, cr, uid, ids, context):
|
||||||
"""
|
"""
|
||||||
To merge similar type of purchase orders.
|
To merge similar type of purchase orders.
|
||||||
Orders will only be merged if:
|
Orders will only be merged if:
|
||||||
* Purchase Orders are in draft
|
* Purchase Orders are in draft
|
||||||
* Purchase Orders belong to the same partner
|
* Purchase Orders belong to the same partner
|
||||||
* Purchase Orders are have same stock location, same pricelist
|
* Purchase Orders are have same stock location, same pricelist
|
||||||
Lines will only be merged if:
|
Lines will only be merged if:
|
||||||
* Order lines are exactly the same except for the quantity and unit
|
* Order lines are exactly the same except for the quantity and unit
|
||||||
|
|
||||||
@param self: The object pointer.
|
@param self: The object pointer.
|
||||||
@param cr: A database cursor
|
@param cr: A database cursor
|
||||||
@param uid: ID of the user currently logged in
|
@param uid: ID of the user currently logged in
|
||||||
@param ids: the ID or list of IDs
|
@param ids: the ID or list of IDs
|
||||||
@param context: A standard dictionary
|
@param context: A standard dictionary
|
||||||
|
|
||||||
@return: new purchase order id
|
@return: new purchase order id
|
||||||
|
|
||||||
"""
|
"""
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
def make_key(br, fields):
|
def make_key(br, fields):
|
||||||
list_key = []
|
list_key = []
|
||||||
for field in fields:
|
for field in fields:
|
||||||
field_val = getattr(br, field)
|
field_val = getattr(br, field)
|
||||||
|
@ -498,9 +498,9 @@ class purchase_order(osv.osv):
|
||||||
return tuple(list_key)
|
return tuple(list_key)
|
||||||
|
|
||||||
# compute what the new orders should contain
|
# compute what the new orders should contain
|
||||||
|
|
||||||
new_orders = {}
|
new_orders = {}
|
||||||
|
|
||||||
for porder in [order for order in self.browse(cr, uid, ids) if order.state == 'draft']:
|
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'))
|
order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
|
||||||
new_order = new_orders.setdefault(order_key, ({}, []))
|
new_order = new_orders.setdefault(order_key, ({}, []))
|
||||||
|
@ -543,7 +543,7 @@ class purchase_order(osv.osv):
|
||||||
o_line[field] = field_val
|
o_line[field] = field_val
|
||||||
o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
|
o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
allorders = []
|
allorders = []
|
||||||
for order_key, (order_data, old_ids) in new_orders.iteritems():
|
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),
|
'invoiced': fields.boolean('Invoiced', readonly=True),
|
||||||
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner"),
|
'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")
|
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
|
||||||
|
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'product_qty': lambda *a: 1.0,
|
'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,
|
partner_id, date_order=False, fiscal_position=False, date_planned=False,
|
||||||
name=False, price_unit=False, notes=False):
|
name=False, price_unit=False, notes=False):
|
||||||
if not pricelist:
|
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:
|
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.'))
|
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:
|
if not product:
|
||||||
|
@ -694,7 +694,7 @@ class purchase_order_line(osv.osv):
|
||||||
return res
|
return res
|
||||||
def action_confirm(self, cr, uid, ids, context={}):
|
def action_confirm(self, cr, uid, ids, context={}):
|
||||||
self.write(cr, uid, ids, {'state': 'confirmed'}, context)
|
self.write(cr, uid, ids, {'state': 'confirmed'}, context)
|
||||||
return True
|
return True
|
||||||
purchase_order_line()
|
purchase_order_line()
|
||||||
|
|
||||||
class mrp_procurement(osv.osv):
|
class mrp_procurement(osv.osv):
|
||||||
|
@ -702,7 +702,7 @@ class mrp_procurement(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'),
|
'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def action_po_assign(self, cr, uid, ids, context={}):
|
def action_po_assign(self, cr, uid, ids, context={}):
|
||||||
""" This is action which call from workflow to assign purchase order to procurements
|
""" This is action which call from workflow to assign purchase order to procurements
|
||||||
@return: True
|
@return: True
|
||||||
|
|
|
@ -511,12 +511,12 @@ class sale_order(osv.osv):
|
||||||
def action_invoice_end(self, cr, uid, ids, context=None):
|
def action_invoice_end(self, cr, uid, ids, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
for order in self.browse(cr, uid, ids, context=context):
|
for order in self.browse(cr, uid, ids, context=context):
|
||||||
for line in order.order_line:
|
for line in order.order_line:
|
||||||
if line.state == 'exception':
|
if line.state == 'exception':
|
||||||
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'state': 'confirmed'}, context=context)
|
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'state': 'confirmed'}, context=context)
|
||||||
|
|
||||||
if order.state == 'invoice_except':
|
if order.state == 'invoice_except':
|
||||||
self.write(cr, uid, [order.id], {'state' : 'progress'}, context=context)
|
self.write(cr, uid, [order.id], {'state' : 'progress'}, context=context)
|
||||||
|
|
||||||
|
@ -1086,7 +1086,7 @@ class sale_order_line(osv.osv):
|
||||||
warning = {
|
warning = {
|
||||||
'title': 'No Pricelist !',
|
'title': 'No Pricelist !',
|
||||||
'message':
|
'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.'
|
'Please set one before choosing a product.'
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1495,8 +1495,10 @@
|
||||||
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
|
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
|
||||||
<field name="tracking_id"/>
|
<field name="tracking_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label/>
|
<group col="2" colspan="2">
|
||||||
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
|
<label/>
|
||||||
|
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
|
||||||
|
</group>
|
||||||
<separator colspan="4" string="Move State"/>
|
<separator colspan="4" string="Move State"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<group col="5" colspan="2">
|
<group col="5" colspan="2">
|
||||||
|
|
Loading…
Reference in New Issue