})
return action
+
+ def view_picking_(self, cr, uid, ids, context=None):
+ '''
+ This function returns an action that display existing picking orders of given purchase order ids.
+ '''
+
+ import ipdb; ipdb.set_trace()
+
+ if context is None:
+ context = {}
+ mod_obj = self.pool.get('ir.model.data')
+ pick_ids = []
+ for po in self.browse(cr, uid, ids, context=context):
+ pick_ids += [picking.id for picking in po.picking_ids]
+
+ print(pick_ids)
+
+ action_model, action_id = tuple(mod_obj.get_object_reference(cr, uid, 'stock', 'action_picking_tree'))
+ action = self.pool[action_model].read(cr, uid, action_id, context=context)
+ active_id = context.get('active_id',ids[0])
+ picking_type_id = self.browse(cr, uid, active_id, context=context)['picking_type_id'].id
+
+ ctx = eval(action['context'],{'active_id': picking_type_id}, nocopy=True)
+ ctx.update({
+ 'search_default_purchase_id': ids[0]
+ })
+ if pick_ids and len(pick_ids) == 1:
+ form_view_ids = [view_id for view_id, view in action['views'] if view == 'form']
+ view_id = form_view_ids and form_view_ids[0] or False
+ action.update({
+ 'views': [],
+ 'view_mode': 'form',
+ 'view_id': view_id,
+ 'res_id': pick_ids[0]
+ })
+
+ action.update({
+ 'context': ctx,
+ })
+ return action
+
def wkf_approve_order(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)})
return True
<button name="invoice_ok" states="except_invoice" string="Manually Corrected"/>
<button name="purchase_approve" states="confirmed" string="Approve Order" class="oe_highlight" groups="purchase.group_purchase_manager"/>
<button name="wkf_send_rfq" states="approved" string="Send PO by Email" type="object" context="{'send_rfq':False}"/>
- <button name="view_picking" string="Receptions" type="object" attrs="{'invisible': ['|', ('shipped','=',True), ('state','!=', 'approved')]}" class="oe_highlight"/>
+ <button name="view_picking_" string="Receptions" type="object" attrs="{'invisible': ['|', ('shipped','=',True), ('state','!=', 'approved')]}" class="oe_highlight"/>
<button name="view_invoice" string="Receive Invoice" type="object" attrs="{'invisible': ['|', ('invoice_method','=','picking'), '|', ('state','!=', 'approved'), ('invoiced','=',True) ]}" class="oe_highlight"/>
<button name="action_cancel_draft" states="cancel,sent,confirmed" string="Set to Draft" type="object" />
<button name="purchase_cancel" states="draft,confirmed,sent,bid" string="Cancel"/>
class product_product(osv.osv):
_inherit = "product.product"
-
+
def _stock_move_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict([(id, {'reception_count': 0, 'delivery_count': 0}) for id in ids])
move_pool=self.pool.get('stock.move')
else:
res[pick.id] = False
return res
-
-
+
+# def onchange_owner_id(self,cr,uid,ids,new_owner_id,pack_operation_ids, context=None):
+# packop_ids = self.resolve_2many_commands(cr, uid, 'pack_operation_ids',pack_operation_ids, ['id'])
+# packop_ids = [p['id'] for p in packop_ids] #NO CORRECT FOR NEW
+# self.pool.get('stock.pack.operation').write(cr,uid,packop_ids,{'owner_id':new_owner_id},context=context)
+# result = {
+# 'pack_operation_ids':pack_operation_ids
+# }
+# return { 'value' : result}
+#
+ def action_assign_owner(self, cr, uid, ids, context=None):
+ pack_op = self.browse(cr,uid,ids[0],context=context)
+ packop_ids = [p.id for p in pack_op.pack_operation_ids]
+ self.pool.get('stock.pack.operation').write(cr,uid,packop_ids,{'owner_id':pack_op.owner_id.id},context=context)
_columns = {
'name': fields.char('Reference', size=64, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'pack_operation_exist': fields.function(_get_pack_operation_exist, type='boolean', string='Pack Operation Exists?', help='technical field for attrs in view'),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True),
+ 'owner_id': fields.many2one('res.partner', 'Owner', help="Default Owner"),
# Used to search on pickings
'product_id': fields.related('move_lines', 'product_id', type='many2one', relation='product.product', string='Product'),#?
'location_id': fields.related('move_lines', 'location_id', type='many2one', relation='stock.location', string='Location', readonly=True),
'location_dest_id': fields.related('move_lines', 'location_dest_id', type='many2one', relation='stock.location', string='Destination Location', readonly=True),
'group_id': fields.related('move_lines', 'group_id', type='many2one', relation='procurement.group', string='Procurement Group', readonly=True),
-# 'group_id': fields.function(_get_group_id, type='many2one', store={'stock.move': (_get_pickings, ['picking_id', 'group_id'], 10)}),
+ # 'group_id': fields.function(_get_group_id, type='many2one', store={'stock.move': (_get_pickings, ['picking_id', 'group_id'], 10)}),
}
_defaults = {
'name': lambda self, cr, uid, context: '/',
_name = "stock.pack.operation"
_description = "Packing Operation"
+
+ def onchange_product_id_for_owner(self,cr,uid,ids,powner_id, context=None):
+ return { 'value' : {'owner_id' : powner_id} }
+
+
def _get_remaining_qty(self, cr, uid, ids, context=None):
res = {}
for ops in self.browse(cr, uid, ids, context=context):
res[ops.id] = qty
return res
-
_columns = {
'picking_id': fields.many2one('stock.picking', 'Stock Picking', help='The stock operation where the packing has been made', required=True),
'product_id': fields.many2one('product.product', 'Product', ondelete="CASCADE"), # 1
}
_defaults = {
- 'date': fields.date.context_today,
+ 'date': fields.date.context_today,
}
<field name="date"/>
<field name="min_date" attrs="{'invisible': [('min_date','=',False)]}"/>
<field name="origin" placeholder="e.g. PO0032" class="oe_inline"/>
+ <label for="owner_id" groups="stock.group_tracking_owner"/>
+ <div groups="stock.group_tracking_owner">
+ <field name="owner_id"/>
+ <button name="action_assign_owner" string="Assign Owner" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state', 'not in', ('draft','assigned','confirmed'))]}"
+ class="oe_link oe_edit_only"/>
+ </div>
</group>
</group>
<notebook>
groups="stock.group_tracking_lot"/>
<button name="do_split" string="Split" groups="base.group_no_one" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state','!=','assigned')]}"/>
<field name="pack_operation_ids" attrs="{'invisible': [('pack_operation_exist', '=', False)]}">
- <tree editable="top">
- <field name="product_id"/>
+ <tree editable="top">
+ <field name="product_id"
+ on_change="onchange_product_id_for_owner(parent.owner_id)"/>
<field name="product_uom_id" groups="product.group_uom"/>
<field name="lot_id" domain="[('product_id','=?', product_id)]" context="{'product_id': product_id}" groups="stock.group_production_lot"/>
<field name="package_id" groups="stock.group_tracking_lot"/>
def unlink(self, cr, uid, ids, context=None):
#TODO try to delete location and route and if not possible, put them in inactive
return super(stock_warehouse, self).unlink(cr, uid, ids, context=context)
+
+ def view_all_routes_for_wh(self, cr, uid, ids, context):
+ wh_obj = self.pool.get("stock.warehouse")
+
+ wh = wh_obj.browse(cr,uid,ids[0])
+
+ all_routes = []
+ all_routes += [wh.crossdock_route_id.id]
+ all_routes += [wh.reception_route_id.id]
+ all_routes += [wh.delivery_route_id.id]
+ all_routes += [wh.mto_pull_id.route_id.id]
+ all_routes += [route.id for route in wh.resupply_route_ids]
+ all_routes += [route.id for route in wh.route_ids]
+
+ res_id = ids and ids[0] or False
+ domain = [('id', 'in', all_routes)]
+ return {
+ 'name': _('The routes !'),
+ 'domain': domain,
+ 'res_model': 'stock.location.route',
+ 'type': 'ir.actions.act_window',
+ 'view_id': False,
+ 'view_mode': 'tree,form',
+ 'view_type': 'form',
+ 'limit': 20
+ }
class stock_location_path(osv.osv):
_name = "stock.location.path"
</xpath>
</field>
</record>
-
+
<record id="view_warehouse_inherit" model="ir.ui.view">
<field name="name">stock.warehouse</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
+ <xpath expr="/form/sheet/label" position="before">
+ <div class="oe_right oe_button_box">
+ <button name="view_all_routes_for_wh" string="View related routes" type="object" />
+ </div>
+ </xpath>
<xpath expr="//group[last()]" position="after">
<notebook colspan="4">
<page string="Warehouse Configuration" colspan="4">
<field name="default_resupply_wh_id"/> <!-- TODO should be filtered on resupply_wh_ids only... -->
</group>
</page>
+ <!--
<page string="Routes Information" colspan="4">
<group colspan="4">
<field name="route_ids" nolabel="1" readonly="1"/>
</group>
- </page>
+ </page>
+ -->
</notebook>
</xpath>
</field>