[IMP] Onchange of picking type on purchase order + improvement packing when result_package_id = False
bzr revid: jco@openerp.com-20130903124649-29x5hfwfx3x6bnn6
This commit is contained in:
parent
28a3c2b628
commit
b77f96a20b
|
@ -83,8 +83,8 @@ Dashboard / Reports for Purchase Management will include:
|
|||
'test/average_price.yml',
|
||||
],
|
||||
'demo': [
|
||||
'purchase_order_demo.yml',
|
||||
'purchase_demo.xml',
|
||||
#'purchase_order_demo.yml',
|
||||
#'purchase_demo.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
|
|
|
@ -235,6 +235,7 @@ class purchase_order(osv.osv):
|
|||
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
|
||||
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
|
||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment", required=True),
|
||||
'related_location_id':fields.related('picking_type_id', 'default_location_dest_id', type='many2one', relation='stock.location', string="Related location", store=True),
|
||||
}
|
||||
_defaults = {
|
||||
'date_order': fields.date.context_today,
|
||||
|
@ -308,6 +309,16 @@ class purchase_order(osv.osv):
|
|||
values.update({'location_id': location_id})
|
||||
return {'value':values}
|
||||
|
||||
def onchange_picking_type_id(self, cr, uid, ids, picking_type_id, context=None):
|
||||
value = {}
|
||||
if picking_type_id:
|
||||
picktype = self.pool.get("stock.picking.type").browse(cr, uid, picking_type_id, context=context)
|
||||
if picktype.default_location_dest_id:
|
||||
value.update({'location_id': picktype.default_location_dest_id.id})
|
||||
value.update({'related_location_id': picktype.default_location_dest_id and picktype.default_location_dest_id.id or False})
|
||||
return {'value': value}
|
||||
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id):
|
||||
partner = self.pool.get('res.partner')
|
||||
if not partner_id:
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<field name="origin" attr="{'invisible': [('origin','=',False)]}"/>
|
||||
<field name="warehouse_id" widget="selection" groups="stock.group_locations"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
<field name="picking_type_id"/>
|
||||
<field name="picking_type_id" on_change="onchange_picking_type_id(picking_type_id, context)" domain="[('code_id','=','incoming')]"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
|
@ -241,7 +241,11 @@
|
|||
<page string="Deliveries & Invoices">
|
||||
<group>
|
||||
<group>
|
||||
<field name="dest_address_id" string="Customer Address" on_change="onchange_dest_address_id(dest_address_id)" groups="stock.group_locations"/>
|
||||
<field name="related_location_id" invisible="1"/>
|
||||
<field name="dest_address_id" string="Customer Address" on_change="onchange_dest_address_id(dest_address_id)"
|
||||
attrs="{'invisible':['|', ('picking_type_id','=',False), ('related_location_id','!=', False)],
|
||||
'required': [('picking_type_id','!=',False), ('related_location_id','=', False)]}"
|
||||
groups="stock.group_locations"/>
|
||||
<field name="minimum_planned_date"/>
|
||||
<field name="location_id" groups="stock.group_locations"/>
|
||||
<field name="shipped" groups="base.group_no_one"/>
|
||||
|
|
|
@ -773,8 +773,8 @@ class stock_picking(osv.osv):
|
|||
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
|
||||
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
|
||||
#In the end, move quants in correct package
|
||||
if create and ops.result_package_id:
|
||||
quant_obj.write(cr, uid, [x[0] for x in quants], {'package_id': ops.result_package_id.id}, context=context)
|
||||
if create:
|
||||
quant_obj.write(cr, uid, [x[0] for x in quants], {'package_id': ops.result_package_id and ops.result_package_id.id or False}, context=context)
|
||||
res2[move.id] -= qty
|
||||
res[ops.id] = {}
|
||||
res[ops.id][ops.product_id.id] = qty_to_do
|
||||
|
@ -796,8 +796,8 @@ class stock_picking(osv.osv):
|
|||
res.setdefault(ops.id, {}).setdefault(quant.product_id.id, 0.0)
|
||||
res[ops.id][quant.product_id.id] += qty_to_do
|
||||
#Add parent package
|
||||
if create and ops.result_package_id:
|
||||
self.pool.get("stock.package").write(cr, uid, [ops.package_id.id], {'parent_id': ops.result_package_id.id}, context=context)
|
||||
if create:
|
||||
self.pool.get("stock.package").write(cr, uid, [ops.package_id.id], {'parent_id': ops.result_package_id and ops.result_package_id.id or False}, context=context)
|
||||
return (res, res2)
|
||||
|
||||
|
||||
|
|
|
@ -168,13 +168,10 @@ class procurement_order(osv.osv):
|
|||
|
||||
def _search_suitable_rule(self, cr, uid, procurement, domain, context=None):
|
||||
'''we try to first find a rule among the ones defined on the procurement order group and if none is found, we try on the routes defined for the product, and finally we fallback on the default behavior'''
|
||||
route_ids = [x.id for x in procurement.route_ids]
|
||||
route_ids = [x.id for x in procurement.route_ids] + [x.id for x in procurement.product_id.route_ids]
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
if not res:
|
||||
route_ids = [x.id for x in procurement.product_id.route_ids]
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
if not res:
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain, order='sequence', context=context)
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain, order='sequence', context=context)
|
||||
return res
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue