2012-03-06 07:10:36 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
2012-04-03 08:44:25 +00:00
# OpenERP, Open Source Business Applications
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
2012-03-06 07:10:36 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
2012-12-06 14:56:32 +00:00
from openerp . osv import fields , osv
2014-04-16 14:53:13 +00:00
from openerp . tools . translate import _
2012-03-06 07:10:36 +00:00
2013-12-11 10:25:11 +00:00
class res_company ( osv . osv ) :
_inherit = " res.company "
_columns = {
' propagation_minimum_delta ' : fields . integer ( ' Minimum Delta for Propagation of a Date Change on moves linked together ' ) ,
2014-04-16 14:53:13 +00:00
' internal_transit_location_id ' : fields . many2one ( ' stock.location ' , ' Internal Transit Location ' , help = " Technical field used for resupply routes between warehouses that belong to this company " , on_delete = " restrict " ) ,
2013-12-11 10:25:11 +00:00
}
2014-04-16 14:53:13 +00:00
def create_transit_location ( self , cr , uid , company_id , company_name , context = None ) :
''' Create a transit location with company_id being the given company_id. This is needed
in case of resuply routes between warehouses belonging to the same company , because
we don ' t want to create accounting entries at that time.
'''
data_obj = self . pool . get ( ' ir.model.data ' )
try :
parent_loc = data_obj . get_object_reference ( cr , uid , ' stock ' , ' stock_location_locations ' ) [ 1 ]
except :
parent_loc = False
location_vals = {
' name ' : _ ( ' %s : Transit Location ' ) % company_name ,
' usage ' : ' transit ' ,
' company_id ' : company_id ,
' location_id ' : parent_loc ,
}
location_id = self . pool . get ( ' stock.location ' ) . create ( cr , uid , location_vals , context = context )
self . write ( cr , uid , [ company_id ] , { ' internal_transit_location_id ' : location_id } , context = context )
def create ( self , cr , uid , vals , context = None ) :
company_id = super ( res_company , self ) . create ( cr , uid , vals , context = context )
self . create_transit_location ( cr , uid , company_id , vals [ ' name ' ] , context = context )
return company_id
2013-12-11 10:25:11 +00:00
_defaults = {
' propagation_minimum_delta ' : 1 ,
}
2012-03-22 14:56:59 +00:00
class stock_config_settings ( osv . osv_memory ) :
_name = ' stock.config.settings '
2012-03-06 07:10:36 +00:00
_inherit = ' res.config.settings '
_columns = {
2013-12-12 09:56:51 +00:00
' company_id ' : fields . many2one ( ' res.company ' , ' Company ' , required = True ) ,
2014-03-27 21:32:01 +00:00
' module_procurement_jit ' : fields . boolean ( " Generate procurement in real time " ,
2013-09-03 10:17:36 +00:00
help = """ This allows Just In Time computation of procurement orders.
All procurement orders will be processed immediately , which could in some
cases entail a small performance impact .
2014-03-27 21:32:01 +00:00
This installs the module procurement_jit . """ ),
2012-09-12 07:14:13 +00:00
' module_claim_from_delivery ' : fields . boolean ( " Allow claim on deliveries " ,
2013-07-24 13:45:48 +00:00
help = ' Adds a Claim link to the delivery order. \n '
2013-09-17 13:08:14 +00:00
' -This installs the module claim_from_delivery. ' ) ,
2012-11-02 06:49:38 +00:00
' module_product_expiry ' : fields . boolean ( " Expiry date on serial numbers " ,
2012-05-09 13:24:01 +00:00
help = """ Track different dates on products and serial numbers.
2012-11-02 12:26:48 +00:00
The following dates can be tracked :
- end of life
- best before date
- removal date
- alert date .
This installs the module product_expiry . """ ),
2012-09-26 12:24:35 +00:00
' group_uom ' : fields . boolean ( " Manage different units of measure for products " ,
2012-03-22 14:53:35 +00:00
implied_group = ' product.group_uom ' ,
2012-04-03 09:52:10 +00:00
help = """ Allows you to select and maintain different units of measure for products. """ ) ,
2014-07-28 09:51:55 +00:00
' group_uos ' : fields . boolean ( " Store products in a different unit of measure than the sales order " ,
2012-04-03 09:16:44 +00:00
implied_group = ' product.group_uos ' ,
2014-07-28 09:51:55 +00:00
help = ' Allows you to store units of a product, but sell and invoice based on a different unit of measure. \n '
' For instance, you can store pieces of meat that you sell and invoice based on their weight. ' ) ,
2012-09-12 07:14:13 +00:00
' group_stock_packaging ' : fields . boolean ( " Allow to define several packaging methods on products " ,
2012-03-22 15:27:55 +00:00
implied_group = ' product.group_stock_packaging ' ,
2012-03-22 14:53:35 +00:00
help = """ Allows you to create and manage your packaging dimensions and types you want to be maintained in your system. """ ) ,
2014-02-20 16:31:11 +00:00
' group_stock_production_lot ' : fields . boolean ( " Track lots or serial numbers " ,
2014-01-30 17:47:11 +00:00
implied_group = ' stock.group_production_lot ' ,
help = """ This allows you to assign a lot (or serial number) to the pickings and moves. This can make it possible to know which production lot was sent to a certain client, ... """ ) ,
2014-02-20 16:31:11 +00:00
' group_stock_tracking_lot ' : fields . boolean ( " Use packages: pallets, boxes, ... " ,
2012-03-22 15:05:11 +00:00
implied_group = ' stock.group_tracking_lot ' ,
2014-08-13 16:45:17 +00:00
help = """ This allows to manipulate packages. You can put something in, take something from a package, but also move entire packages and put them even in another package. """ ) ,
2014-04-08 07:53:53 +00:00
' group_stock_tracking_owner ' : fields . boolean ( " Manage owner on stock " ,
implied_group = ' stock.group_tracking_owner ' ,
help = """ This way you can receive products attributed to a certain owner. """ ) ,
2012-09-12 07:14:13 +00:00
' group_stock_multiple_locations ' : fields . boolean ( " Manage multiple locations and warehouses " ,
2012-04-03 09:39:18 +00:00
implied_group = ' stock.group_locations ' ,
2014-04-08 07:53:53 +00:00
help = """ This will show you the locations and allows you to define multiple picking types and warehouses. """ ) ,
2014-03-27 10:24:21 +00:00
' group_stock_adv_location ' : fields . boolean ( " Manage advanced routes for your warehouse " ,
2013-12-11 10:25:11 +00:00
implied_group = ' stock.group_adv_location ' ,
2014-04-08 07:53:53 +00:00
help = """ This option supplements the warehouse application by effectively implementing Push and Pull inventory flows through Routes. """ ) ,
2012-08-01 15:47:01 +00:00
' decimal_precision ' : fields . integer ( ' Decimal precision on weight ' , help = " As an example, a decimal precision of 2 will allow weights like: 9.99 kg, whereas a decimal precision of 4 will allow weights like: 0.0231 kg. " ) ,
2013-12-11 10:25:11 +00:00
' propagation_minimum_delta ' : fields . related ( ' company_id ' , ' propagation_minimum_delta ' , type = ' integer ' , string = " Minimum days to trigger a propagation of date change in pushed/pull flows. " ) ,
2013-12-04 07:34:02 +00:00
' module_stock_dropshipping ' : fields . boolean ( " Manage dropshipping " ,
2013-12-03 13:44:48 +00:00
help = ' \n Creates the dropship route and add more complex tests '
' -This installs the module stock_dropshipping. ' ) ,
2014-02-03 07:28:33 +00:00
' module_stock_picking_wave ' : fields . boolean ( ' Manage picking wave ' , help = ' Install the picking wave module which will help you grouping your pickings and processing them in batch ' ) ,
2012-03-06 07:10:36 +00:00
}
2012-05-09 13:23:30 +00:00
2014-03-27 10:24:21 +00:00
def onchange_adv_location ( self , cr , uid , ids , group_stock_adv_location , context = None ) :
if group_stock_adv_location :
2014-04-08 07:53:53 +00:00
return { ' value ' : { ' group_stock_multiple_locations ' : True } }
2014-03-27 10:24:21 +00:00
return { }
2013-12-12 09:56:51 +00:00
def _default_company ( self , cr , uid , context = None ) :
user = self . pool . get ( ' res.users ' ) . browse ( cr , uid , uid , context = context )
return user . company_id . id
2012-05-09 13:23:30 +00:00
def get_default_dp ( self , cr , uid , fields , context = None ) :
dp = self . pool . get ( ' ir.model.data ' ) . get_object ( cr , uid , ' product ' , ' decimal_stock_weight ' )
return { ' decimal_precision ' : dp . digits }
def set_default_dp ( self , cr , uid , ids , context = None ) :
config = self . browse ( cr , uid , ids [ 0 ] , context )
dp = self . pool . get ( ' ir.model.data ' ) . get_object ( cr , uid , ' product ' , ' decimal_stock_weight ' )
dp . write ( { ' digits ' : config . decimal_precision } )
2013-12-12 09:56:51 +00:00
_defaults = {
' company_id ' : _default_company ,
}
2012-03-22 14:53:35 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: