[MIGR] stock: stock_warehouse
Warehouse models are migrated to new API. No change is performed to code structure or functional structure. Some code cleaning may be performed when migrating to simplify the code. Other files may be updated due to the move towards the new API.
This commit is contained in:
+7
-7
@@ -3,6 +3,7 @@
|
||||
|
||||
import time
|
||||
|
||||
from openerp import api
|
||||
from openerp.osv import fields
|
||||
from openerp.osv import osv
|
||||
from openerp.tools.translate import _
|
||||
@@ -246,7 +247,7 @@ class stock_warehouse(osv.osv):
|
||||
raise UserError(_('Can\'t find any generic Manufacture route.'))
|
||||
|
||||
return {
|
||||
'name': self._format_routename(cr, uid, warehouse, _(' Manufacture'), context=context),
|
||||
'name': warehouse._format_routename(_(' Manufacture')),
|
||||
'location_id': warehouse.lot_stock_id.id,
|
||||
'route_id': manufacture_route_id,
|
||||
'action': 'manufacture',
|
||||
@@ -283,12 +284,11 @@ class stock_warehouse(osv.osv):
|
||||
pull_obj.unlink(cr, uid, warehouse.manufacture_pull_id.id, context=context)
|
||||
return super(stock_warehouse, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def get_all_routes_for_wh(self, cr, uid, ids, context=None):
|
||||
all_routes = super(stock_warehouse, self).get_all_routes_for_wh(cr, uid, ids, context=context)
|
||||
warehouse = self.browse(cr, uid, ids[0], context=context)
|
||||
if warehouse.manufacture_to_resupply and warehouse.manufacture_pull_id and warehouse.manufacture_pull_id.route_id:
|
||||
all_routes += [warehouse.manufacture_pull_id.route_id.id]
|
||||
return all_routes
|
||||
@api.multi
|
||||
def _get_all_routes(self):
|
||||
routes = super(stock_warehouse, self).get_all_routes_for_wh()
|
||||
routes |= self.filtered(lambda self: self.manufacture_to_resupply and self.manufacture_pull_id and self.manufacture_pull_id.route_id).mapped('manufacture_pull_id').mapped('route_id')
|
||||
return routes
|
||||
|
||||
def _handle_renaming(self, cr, uid, ids, name, code, context=None):
|
||||
res = super(stock_warehouse, self)._handle_renaming(cr, uid, ids, name, code, context=context)
|
||||
|
||||
@@ -526,7 +526,7 @@ class PosOrder(models.Model):
|
||||
destination_id = order.partner_id.property_stock_customer.id
|
||||
else:
|
||||
if (not picking_type) or (not picking_type.default_location_dest_id):
|
||||
customerloc, supplierloc = StockWarehouse._get_partner_locations([])
|
||||
customerloc, supplierloc = StockWarehouse._get_partner_locations()
|
||||
destination_id = customerloc.id
|
||||
else:
|
||||
destination_id = picking_type.default_location_dest_id.id
|
||||
|
||||
@@ -104,6 +104,7 @@ class product_uom(osv.osv):
|
||||
('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!')
|
||||
]
|
||||
|
||||
@api.cr_uid
|
||||
def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, round=True, rounding_method='UP'):
|
||||
if not from_uom_id or not qty or not to_uom_id:
|
||||
return qty
|
||||
|
||||
+11
-12
@@ -80,7 +80,7 @@ class stock_warehouse(osv.osv):
|
||||
raise UserError(_('Can\'t find any generic Buy route.'))
|
||||
|
||||
return {
|
||||
'name': self._format_routename(cr, uid, warehouse, _(' Buy'), context=context),
|
||||
'name': warehouse._format_routename(_(' Buy')),
|
||||
'location_id': warehouse.in_type_id.default_location_dest_id.id,
|
||||
'route_id': buy_route_id,
|
||||
'action': 'buy',
|
||||
@@ -117,12 +117,11 @@ class stock_warehouse(osv.osv):
|
||||
buy_pull_id = pull_obj.unlink(cr, uid, warehouse.buy_pull_id.id, context=context)
|
||||
return super(stock_warehouse, self).write(cr, uid, ids, vals, context=None)
|
||||
|
||||
def get_all_routes_for_wh(self, cr, uid, ids, context=None):
|
||||
all_routes = super(stock_warehouse, self).get_all_routes_for_wh(cr, uid, ids, context=context)
|
||||
warehouse = self.browse(cr, uid, ids[0], context=context)
|
||||
if warehouse.buy_to_resupply and warehouse.buy_pull_id and warehouse.buy_pull_id.route_id:
|
||||
all_routes += [warehouse.buy_pull_id.route_id.id]
|
||||
return all_routes
|
||||
@api.multi
|
||||
def _get_all_routes(self):
|
||||
routes = super(stock_warehouse, self).get_all_routes_for_wh()
|
||||
routes |= self.filtered(lambda self: self.buy_to_resupply and self.buy_pull_id and self.buy_pull_id.route_id).mapped('buy_pull_id').mapped('route_id')
|
||||
return routes
|
||||
|
||||
def _get_all_products_to_resupply(self, cr, uid, warehouse, context=None):
|
||||
res = super(stock_warehouse, self)._get_all_products_to_resupply(cr, uid, warehouse, context=context)
|
||||
@@ -143,9 +142,9 @@ class stock_warehouse(osv.osv):
|
||||
pull_obj.write(cr, uid, warehouse.buy_pull_id.id, {'name': warehouse.buy_pull_id.name.replace(warehouse.name, name, 1)}, context=context)
|
||||
return res
|
||||
|
||||
def change_route(self, cr, uid, ids, new_reception_step=False, new_delivery_step=False, context=None):
|
||||
res = super(stock_warehouse, self).change_route(cr, uid, ids, new_reception_step=new_reception_step, new_delivery_step=new_delivery_step, context=context)
|
||||
warehouse = self.browse(cr, uid, ids[0], context=context)
|
||||
if warehouse.in_type_id.default_location_dest_id != warehouse.buy_pull_id.location_id:
|
||||
self.pool.get('procurement.rule').write(cr, uid, warehouse.buy_pull_id.id, {'location_id': warehouse.in_type_id.default_location_dest_id.id}, context=context)
|
||||
def change_route(self, cr, uid, ids, context=None):
|
||||
res = super(stock_warehouse, self).change_route(cr, uid, ids, context=context)
|
||||
for warehouse in self.browse(cr, uid, ids[0], context=context):
|
||||
if warehouse.in_type_id.default_location_dest_id != warehouse.buy_pull_id.location_id:
|
||||
self.pool.get('procurement.rule').write(cr, uid, warehouse.buy_pull_id.id, {'location_id': warehouse.in_type_id.default_location_dest_id.id}, context=context)
|
||||
return res
|
||||
|
||||
@@ -228,13 +228,13 @@ class SaleOrderLine(models.Model):
|
||||
if wh_mto_route and wh_mto_route <= product_routes:
|
||||
is_available = True
|
||||
else:
|
||||
mto_route_id = False
|
||||
mto_route = False
|
||||
try:
|
||||
mto_route_id = self.env['stock.warehouse']._get_mto_route()
|
||||
mto_route = self.env['stock.warehouse']._get_mto_route()
|
||||
except UserError:
|
||||
# if route MTO not found in ir_model_data, we treat the product as in MTS
|
||||
pass
|
||||
if mto_route_id and mto_route_id in product_routes.ids:
|
||||
if mto_route and mto_route in product_routes:
|
||||
is_available = True
|
||||
|
||||
# Check Drop-Shipping
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,8 +33,8 @@
|
||||
<group colspan="4">
|
||||
<field name="reception_steps" widget='radio'/>
|
||||
<field name="delivery_steps" widget='radio'/>
|
||||
<field name="default_resupply_wh_id" widget='selection' on_change="onchange_filter_default_resupply_wh_id(default_resupply_wh_id, resupply_wh_ids)"/>
|
||||
<field name="resupply_wh_ids" domain="[('id', '!=', id)]" widget='many2many_checkboxes' on_change="onchange_filter_default_resupply_wh_id(default_resupply_wh_id, resupply_wh_ids)"/>
|
||||
<field name="default_resupply_wh_id" widget='selection'/>
|
||||
<field name="resupply_wh_ids" domain="[('id', '!=', id)]" widget='many2many_checkboxes'/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Technical Information" groups='base.group_no_one'>
|
||||
@@ -156,10 +156,10 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="product_id" on_change="onchange_product_id(product_id)"/>
|
||||
<field name="product_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="warehouse_id" widget="selection" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_uom" options="{'no_open': True, 'no_create': True}" groups="product.group_uom"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="group_id" groups="stock.group_adv_location"/>
|
||||
|
||||
Reference in New Issue
Block a user