diff options
| author | Yannick Tivisse <yti@odoo.com> | 2016-02-03 18:20:12 +0100 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-02-04 11:19:09 +0100 |
| commit | ae9b29510a768cddae07b8959af8ec317bfc4679 (patch) | |
| tree | 0613bfdb79b194e57ebd35bb921ed511464c377c | |
| parent | 215cad9cae93e857446dbdd009107a977245713f (diff) | |
[MOV] stock: create res_company.py file from the overridden part in res_config
| -rw-r--r-- | addons/stock/__init__.py | 1 | ||||
| -rw-r--r-- | addons/stock/res_company.py | 45 | ||||
| -rw-r--r-- | addons/stock/res_config.py | 36 |
3 files changed, 46 insertions, 36 deletions
diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index c3e09c05e1b..c2e60b4ca55 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -8,6 +8,7 @@ import procurement import report import wizard import res_config +import res_company import web_planner import controllers diff --git a/addons/stock/res_company.py b/addons/stock/res_company.py new file mode 100644 index 00000000000..37e20b09225 --- /dev/null +++ b/addons/stock/res_company.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from openerp.osv import fields, osv +from openerp.tools.translate import _ + +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'), + '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"), + } + + 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.pool['stock.warehouse'].create(cr, uid, { + 'name': vals['name'], + 'code': vals['name'][:5], + 'company_id': company_id, + }, context=context) + self.create_transit_location(cr, uid, company_id, vals['name'], context=context) + return company_id + + _defaults = { + 'propagation_minimum_delta': 1, + } diff --git a/addons/stock/res_config.py b/addons/stock/res_config.py index c7366c9f325..ede1c668635 100644 --- a/addons/stock/res_config.py +++ b/addons/stock/res_config.py @@ -2,42 +2,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from openerp.osv import fields, osv -from openerp.tools.translate import _ - -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'), - '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"), - } - - 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 - - _defaults = { - 'propagation_minimum_delta': 1, - } class stock_config_settings(osv.osv_memory): _name = 'stock.config.settings' |
