<field name="date_order"/>
<field name="origin" attr="{'invisible': [('origin','=',False)]}"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
- <field name="picking_type_id" on_change="onchange_picking_type_id(picking_type_id, context)" domain="[('code_id','=','incoming')]" widget="selection"/>
+ <field name="picking_type_id" on_change="onchange_picking_type_id(picking_type_id, context)" domain="[('code_id','=','incoming')]" widget="selection"/>
<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)],
routes += route_ids
route_id = line.route_id and [(4, line.route_id.id)] or []
routes += route_id
- print 'toutes les routes sur le procurement', routes
res.update({
'route_ids': routes
})
'stock.location.route': (_get_route, ['active'], 20),
'procurement.rule': (lambda self, cr, uid, ids, c={}: ids, ['route_id'], 20),},
help="If the active field is set to False, it will allow you to hide the rule without removing it." ),
-
- ### FROM MOD STOCK LOCATION
'delay': fields.integer('Number of Days'),
'partner_address_id': fields.many2one('res.partner', 'Partner Address'),
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when the previous move of the move (which was generated by a next procurement) is cancelled or split, the move generated by this move will too'),
'procure_method': 'make_to_stock',
'sequence': 20,
'active': True,
-
- ### FROM MOD STOCK LOCATION
'propagate': True,
'delay': 0,
}
'location_id': fields.many2one('stock.location', 'Procurement Location'),
'move_ids': fields.one2many('stock.move', 'procurement_id', 'Moves', help="Moves created by the procurement"),
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement"),
-
- ### FROM MOD STOCK LOCATION
'route_ids': fields.many2many('stock.location.route', 'stock_location_route_procurement', 'procurement_id', 'route_id', 'Followed Route', help="Preferred route to be followed by the procurement order"),
}
- ### FROM MOD STOCK LOCATION
def _find_parent_locations(self, cr, uid, procurement, context=None):
location = procurement.location_id
res = [location.id]
location = location.location_id
res.append(location.id)
return res
-#
-# REPLACED BY FUNCTION FROM MOD STOCK LOCATION
-# ( the functions _search_suitable_rule() and find_suitable_rule() have to be completly replaced by the ones from stock_location)
-#
-#
-# 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.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 + [('route_id', '=', False)], order='sequence', context=context)
-# return res
-#
-#
-# def _find_suitable_rule(self, cr, uid, procurement, context=None):
-# rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
-# if not rule_id:
-# rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', 'child_of', procurement.location_id.id)], context=context) #action=move
-# rule_id = rule_id and rule_id[0] or False
-# return rule_id
-
-
- def _find_suitable_rule(self, cr, uid, procurement, context=None):
- rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
- if not rule_id:
- #a rule defined on 'Stock' is suitable for a procurement in 'Stock\Bin A'
- all_parent_location_ids = self._find_parent_locations(cr, uid, procurement, context=context)
- rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', 'in', all_parent_location_ids)], context=context)
- rule_id = rule_id and rule_id[0] or False
- return rule_id
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'''
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context)
return res
+ def _find_suitable_rule(self, cr, uid, procurement, context=None):
+ rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
+ if not rule_id:
+ #a rule defined on 'Stock' is suitable for a procurement in 'Stock\Bin A'
+ all_parent_location_ids = self._find_parent_locations(cr, uid, procurement, context=context)
+ rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', 'in', all_parent_location_ids)], context=context)
+ rule_id = rule_id and rule_id[0] or False
+ return rule_id
+
def _run_move_create(self, cr, uid, procurement, context=None):
- d = {
+ vals = {
'name': procurement.name,
'company_id': procurement.company_id.id,
'product_id': procurement.product_id.id,
'origin': procurement.origin,
'picking_type_id': procurement.rule_id.picking_type_id.id,
'group_id': procurement.group_id and procurement.group_id.id or False,
-
- ### FROM MOD STOCK LOCATION
- 'route_ids': [(4,x.id) for x in procurement.route_ids],
+ 'route_ids': [(4, x.id) for x in procurement.route_ids],
}
- ### FROM MOD STOCK LOCATION
if procurement.rule_id:
newdate = (datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.rule_id.delay or 0)).strftime('%Y-%m-%d %H:%M:%S')
- d.update({
+ vals.update({
'date': newdate,
- 'propagate': procurement.rule_id.propagate,
+ 'propagate': procurement.rule_id.propagate,
})
- return d
+ return vals
def _run(self, cr, uid, procurement, context=None):
if procurement.rule_id and procurement.rule_id.action == 'move':
class product_product(osv.osv):
_inherit = "product.product"
- ### FROM MOD STOCK LOCATION
- _columns = {
- 'route_ids': fields.many2many('stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]"), #Adds domain
- }
-
-
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')
'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one'),
'warehouse_id': fields.dummy(string='Warehouse', relation='stock.warehouse', type='many2one'),
'orderpoint_ids': fields.one2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules'),
- 'route_ids': fields.many2many('stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes',
+ 'route_ids': fields.many2many('stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]",
help="Depending on the modules installed, this will allow you to define the route of the product: whether it will be bought, manufactured, MTO/MTS,..."),
}
'sale_delay': 7,
}
-
-### FROM MOD STOCK LOCATION [All under]
+
class product_removal_strategy(osv.osv):
_name = 'product.removal'
_description = 'Removal Strategy'
'location_id': fields.many2one('stock.location', 'Locations', required=True),
}
-#
-# class product_product(osv.osv):
-# _inherit = 'product.product'
-# _columns = {
-# 'route_ids': fields.many2many('stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]"), #Adds domain
-# }
+
+class product_putaway_strategy(osv.osv):
+ _name = 'product.putaway'
+ _description = 'Put Away Strategy'
+ _columns = {
+ 'product_categ_id':fields.many2one('product.category', 'Product Category', required=True),
+ 'location_id': fields.many2one('stock.location','Parent Location', help="Parent Destination Location from which a child bin location needs to be chosen", required=True), #domain=[('type', '=', 'parent')],
+ 'method': fields.selection([('fixed', 'Fixed Location')], "Method", required = True),
+ 'location_spec_id': fields.many2one('stock.location','Specific Location', help="When the location is specific, it will be put over there"), #domain=[('type', '=', 'parent')],
+ }
class product_category(osv.osv):
'putaway_strategy_ids': fields.one2many('product.putaway', 'product_categ_id', 'Put Away Strategies'),
'total_route_ids': fields.function(calculate_total_routes, relation='stock.location.route', type='many2many', string='Total routes', readonly=True),
}
-
-
-class product_putaway_strategy(osv.osv):
- _name = 'product.putaway'
- _description = 'Put Away Strategy'
- _columns = {
- 'product_categ_id':fields.many2one('product.category', 'Product Category', required=True),
- 'location_id': fields.many2one('stock.location','Parent Location', help="Parent Destination Location from which a child bin location needs to be chosen", required=True), #domain=[('type', '=', 'parent')],
- 'method': fields.selection([('fixed', 'Fixed Location')], "Method", required = True),
- 'location_spec_id': fields.many2one('stock.location','Specific Location', help="When the location is specific, it will be put over there"), #domain=[('type', '=', 'parent')],
- }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
'company_id': fields.many2one('res.company', 'Company', select=1, help='Let this field empty if this location is shared between all companies'),
'scrap_location': fields.boolean('Scrap Location', help='Check this box to allow using this location to put scrapped/damaged goods.'),
-
- ### FROM MOD STOCK LOCATION
'removal_strategy_ids': fields.one2many('product.removal', 'location_id', 'Removal Strategies'),
'putaway_strategy_ids': fields.one2many('product.putaway', 'location_id', 'Put Away Strategies'),
}
'scrap_location': False,
}
-
def get_putaway_strategy(self, cr, uid, location, product, context=None):
pa = self.pool.get('product.putaway')
categ = product.categ_id
], context=context)
if result:
return pa.browse(cr, uid, result[0], context=context)
- #return super(stock_location, self).get_putaway_strategy(cr, uid, location, product, context=context)
def get_removal_strategy(self, cr, uid, location, product, context=None):
pr = self.pool.get('product.removal')
('product_categ_id', 'in', categs)
], context=context)
if result:
- return pr.browse(cr, uid, result[0], context=context).method
- return None
-
+ return pr.browse(cr, uid, result[0], context=context).method
#----------------------------------------------------------
'sequence': fields.integer('Sequence'),
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules'),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the route without removing it."),
-
- ### FROM MOD STOCK_LOCATION
'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules'),
'product_selectable': fields.boolean('Selectable on Product'),
'product_categ_selectable': fields.boolean('Selectable on Product Category'),
- 'warehouse_selectable': fields.boolean('Selectable on Warehouse'),
+ 'warehouse_selectable': fields.boolean('Selectable on Warehouse'),
}
_defaults = {
'sequence': lambda self, cr, uid, ctx: 0,
'active': True,
-
- ### FROM MOD STOCK_LOCATION
'product_selectable': True,
}
def check_preferred_location(self, cr, uid, move, context=None):
- ### FROM MOD STOCK LOCATION
if move.putaway_ids and move.putaway_ids[0]:
#Take only first suggestion for the moment
return move.putaway_ids[0].location_id
'availability': fields.function(_get_product_availability, type='float', string='Availability'),
'restrict_lot_id': fields.many2one('stock.production.lot', 'Lot', help="Technical field used to depict a restriction on the lot of quants to consider when marking this move as 'done'"),
'restrict_partner_id': fields.many2one('res.partner', 'Owner ', help="Technical field used to depict a restriction on the ownership of quants to consider when marking this move as 'done'"),
-
- ### FROM MOD STOCK LOCATION
'putaway_ids': fields.one2many('stock.move.putaway', 'move_id', 'Put Away Suggestions'),
'route_ids': fields.many2many('stock.location.route', 'stock_location_route_move', 'move_id', 'route_id', 'Destination route', help="Preferred route to be followed by the procurement order"),
}
'move_dest_id': move.id,
'group_id': move.group_id and move.group_id.id or False,
'route_ids' : [(4, x.id) for x in move.route_ids],
- }
-
- ### FROM MOD STOCK LOCATION
+ }
+
def _push_apply(self, cr, uid, moves, context):
categ_obj = self.pool.get("product.category")
push_obj = self.pool.get("stock.location.path")
'location_id': putaway.location_spec_id.id,
'quantity': move.product_uom_qty}, context=context)
return True
- ### END FROM MOD STOCK LOCATION
def _create_procurement(self, cr, uid, move, context=None):
"""
for move in self.browse(cr, uid, write_ids, context=context):
if move.procure_method == 'make_to_order':
self._create_procurement(cr, uid, move, context=context)
-
- ### FROM MOD STOCK LOCATION (2 lines)
moves = self.browse(cr, uid, ids, context=context)
self._push_apply(cr, uid, moves, context=context)
-
return True
def force_assign(self, cr, uid, ids, context=None):
if all(map(lambda x:x[0], quants)):
done.append(move.id)
self.write(cr, uid, done, {'state': 'assigned'})
-
- ### FROM MOD STOCK LOCATION (1 line)
self._putaway_apply(cr, uid, ids, context=context)
return done
'partner_id': fields.many2one('res.partner', 'Address'),
'lot_stock_id': fields.many2one('stock.location', 'Location Stock', required=True, domain=[('usage', '=', 'internal')]),
'code': fields.char('Warehouse Unique Identifier', size=5, required=True, help="Short name used to identify your warehouse"),
-
-
- ### FROM MOD STOCK_LOCATION
'route_ids': fields.many2many('stock.location.route', 'stock_route_warehouse', 'warehouse_id', 'route_id', 'Routes', domain="[('warehouse_selectable', '=', True)]", help='Defaults routes through the warehouse'),
'reception_steps': fields.selection([
('one_step', 'Receive goods directly in stock (1 step)'),
'crossdock_route_id': fields.many2one('stock.location.route', 'Crossdock Route'),
'reception_route_id': fields.many2one('stock.location.route', 'Reception Route'),
'delivery_route_id': fields.many2one('stock.location.route', 'Delivery Route'),
-
}
def _default_stock_id(self, cr, uid, context=None):
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
'lot_stock_id': _default_stock_id,
-
- ### FROM MOD STOCK_LOCATION
'reception_steps': 'one_step',
'delivery_steps': 'ship_only',
}
('warehouse_name_uniq', 'unique (name, company_id)', 'The name of the warehouse must be unique per company!'),
('warehouse_code_uniq', 'unique (code, company_id)', 'The code of the warehouse must be unique per company !'),
]
-
- ### FROM MOD STOCK LOCATION [ALL UNDER]
+
def _get_partner_locations(self, cr, uid, ids, context=None):
''' returns a tuple made of the browse record of customer location and the browse record of supplier location'''
data_obj = self.pool.get('ir.model.data')
return super(stock_warehouse, self).unlink(cr, uid, ids, context=context)
-
-### FROM MOD STOCK LOCATION
class stock_location_path(osv.osv):
_name = "stock.location.path"
_description = "Pushed Flows"
<field name="route_id" ref="route_warehouse0_mto"/>
</record>
- <!--
+ <!--
Properties
- -->
+ -->
<record forcecreate="True" id="property_stock_supplier" model="ir.property">
<field name="name">property_stock_supplier</field>
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_stock_supplier')]"/>
<field name="name">property_stock_customer</field>
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_stock_customer')]"/>
<field eval="'stock.location,'+str(stock_location_customers)" name="value"/>
- </record>
+ </record>
<record id="base.main_partner" model="res.partner">
<field name="property_stock_customer" eval="ref('stock_location_stock')"/>
<h1><field name="name"/></h1>
<label for="location_id" class="oe_edit_only"/>
<h2><field name="location_id"/></h2>
- <group>
+ <group>
<group string="Additional Information">
<field name="usage"/>
<field name="partner_id"/>
<field name="posz"/>
</group>
</group>
-
- <!-- FROM MOD STOCK LOCATION -->
<separator string="Removal Strategies" groups="stock.group_adv_location"/>
<group groups="stock.group_adv_location">
<div class="oe_inline">
</tree>
</field>
</div>
- </group>
- <!-- END FROM MOD STOCK LOCATION -->
-
+ </group>
<separator string="Additional Information"/>
<field name="comment"/>
</form>
</field>
</record>
- <!-- FROM MOD STOCK LOCATION -->
-
<record id="view_putaway" model="ir.ui.view">
<field name="name">product.putaway.form</field>
<field name="model">product.putaway</field>
</field>
</record>
-
<record id="stock_location_path_tree" model="ir.ui.view">
<field name="name">stock.location.path.tree</field>
<field name="model">stock.location.path</field>
</xpath>
</field>
</record>
- <!-- END FROM MOD STOCK LOCATION -->
<record id="action_location_form" model="ir.actions.act_window">
<field name="picking_type_id" attrs="{'required': [('action', '!=', 'manufacture')]}"/>
<field name="route_id"/>
<field name="group_id" groups="base.group_no_one"/>
-
<field name="propagate" groups="stock.group_adv_location"/>
<label for="delay" string="Delay" groups="stock.group_adv_location"/>
<div>
<field name="active" groups="stock.group_adv_location" />
</group>
</group>
- <!-- FROM MOD STOCK LOCATION -->
<separator string="Applicable On"/>
<p class="oe_grey">Check these box so that the user can select this route during the following operations</p>
<group>
<group string="Push Rules" colspan="4" >
<field name="push_ids" colspan="4" nolabel="1"/>
</group>
-
- <!-- END FROM MOD STOCK LOCATION -->
<group string="Pull Rules" colspan="4" >
<field name="pull_ids" colspan="4" nolabel="1"/>
</group>
</field>
</record>
-
-
<menuitem action="action_routes_form" id="menu_stock_routes"
parent="stock.menu_stock_configuration" sequence="11" />
</data>
name: 'Panama WH address'
parent_id: base.main_partner
-
- !record {model: stock, id: view_location}:
+ !record {model: stock.location, id: view_location}:
name: 'Panama'
location_id: stock.stock_location_locations
usage: 'view'
-
- !record {model: stock, id: wh1_stock_id}:
+ !record {model: stock.location, id: wh1_stock_id}:
name: 'WH1: Stock'
location_id: view_location
usage: 'internal'
-
- !record {model: stock, id: wh1_stock_id_area1}:
+ !record {model: stock.location, id: wh1_stock_id_area1}:
name: 'Area1'
location_id: wh1_stock_id
-
- !record {model: stock, id: wh1_stock_id_area1_bin1}:
+ !record {model: stock.location, id: wh1_stock_id_area1_bin1}:
name: 'Bin1'
location_id: wh1_stock_id_area1
-
name: 'Dubai WH address'
parent_id: base.main_partner
-
- !record {model: stock, id: view_location_dub}:
+ !record {model: stock.location, id: view_location_dub}:
name: 'Dubai'
location_id: stock.stock_location_locations
usage: 'view'
-
- !record {model: stock, id: wh2_stock_id}:
+ !record {model: stock.location, id: wh2_stock_id}:
name: 'WH2: Stock'
location_id: view_location_dub
usage: 'internal'
-
- !record {model: stock, id: wh2_stock_id_area2}:
+ !record {model: stock.location, id: wh2_stock_id_area2}:
name: 'Area2'
location_id: wh2_stock_id
-