From e28b83603b512bcbbf3c1ec3d491a71d89d2c822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 22 Mar 2016 13:49:48 +0100 Subject: [PATCH] [MOV] stock: barcode, procurement, product, res_* Move models not located in stock.py file and their views: - barcode - procurement - product - product.putaway, product.removal and stock.fixed.putaway.strat are extracted from product.py to their own product_strategy file to separate product and product.template code from stock specific code related to products - res_* - settings - web_planner This commit only moves files. No change is done. --- addons/stock/__init__.py | 14 +- addons/stock/__openerp__.py | 8 +- addons/stock/models/__init__.py | 11 ++ addons/stock/models/barcode.py | 19 +++ addons/stock/{ => models}/procurement.py | 0 addons/stock/{ => models}/product.py | 50 +----- addons/stock/models/product_strategy.py | 53 ++++++ addons/stock/{ => models}/res_company.py | 0 .../{partner.py => models/res_partner.py} | 0 .../stock_config_settings.py} | 0 addons/stock/{ => models}/web_planner.py | 0 addons/stock/stock.py | 14 -- addons/stock/stock_view.xml | 157 ------------------ addons/stock/views/procurement_views.xml | 101 +++++++++++ addons/stock/views/product_strategy_views.xml | 38 +++++ .../product_views.xml} | 43 +++++ .../res_partner_views.xml} | 0 .../stock_config_settings_views.xml} | 0 addons/stock/views/stock_menu_views.xml | 20 +-- 19 files changed, 278 insertions(+), 250 deletions(-) create mode 100644 addons/stock/models/__init__.py create mode 100644 addons/stock/models/barcode.py rename addons/stock/{ => models}/procurement.py (100%) rename addons/stock/{ => models}/product.py (94%) create mode 100644 addons/stock/models/product_strategy.py rename addons/stock/{ => models}/res_company.py (100%) rename addons/stock/{partner.py => models/res_partner.py} (100%) rename addons/stock/{res_config.py => models/stock_config_settings.py} (100%) rename addons/stock/{ => models}/web_planner.py (100%) create mode 100644 addons/stock/views/procurement_views.xml create mode 100644 addons/stock/views/product_strategy_views.xml rename addons/stock/{product_view.xml => views/product_views.xml} (89%) rename addons/stock/{partner_view.xml => views/res_partner_views.xml} (100%) rename addons/stock/{res_config_view.xml => views/stock_config_settings_views.xml} (100%) diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index c2e60b4ca55..95b05d6a96a 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -1,14 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from stock import * -import partner -import product -import procurement -import report -import wizard -import res_config -import res_company -import web_planner - import controllers +import models +import report +import stock +import wizard \ No newline at end of file diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 67a75e6eb34..124573e3049 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -69,10 +69,12 @@ Dashboard / Reports for Inventory Management will include: 'wizard/stock_immediate_transfer.xml', 'wizard/stock_backorder_confirmation.xml', + 'views/res_partner_views.xml', + 'views/product_strategy_views.xml', 'stock_view.xml', - 'product_view.xml', - 'partner_view.xml', - 'res_config_view.xml', + 'views/procurement_views.xml', + 'views/product_views.xml', + 'views/stock_config_settings_views.xml', 'stock_dashboard.xml', 'data/default_barcode_patterns.xml', diff --git a/addons/stock/models/__init__.py b/addons/stock/models/__init__.py new file mode 100644 index 00000000000..49511e3eba0 --- /dev/null +++ b/addons/stock/models/__init__.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import barcode +import product +import procurement +import product_strategy +import res_company +import res_partner +import stock_config_settings +import web_planner \ No newline at end of file diff --git a/addons/stock/models/barcode.py b/addons/stock/models/barcode.py new file mode 100644 index 00000000000..627d2016a46 --- /dev/null +++ b/addons/stock/models/barcode.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models +from odoo.tools.translate import _ + + +class barcode_rule(models.Model): + _inherit = 'barcode.rule' + + def _get_type_selection(self): + types = set(super(barcode_rule, self)._get_type_selection()) + types.update([ + ('weight', _('Weighted Product')), + ('location', _('Location')), + ('lot', _('Lot')), + ('package', _('Package')) + ]) + return list(types) diff --git a/addons/stock/procurement.py b/addons/stock/models/procurement.py similarity index 100% rename from addons/stock/procurement.py rename to addons/stock/models/procurement.py diff --git a/addons/stock/product.py b/addons/stock/models/product.py similarity index 94% rename from addons/stock/product.py rename to addons/stock/models/product.py index 791e840a603..91a587fd14a 100644 --- a/addons/stock/product.py +++ b/addons/stock/models/product.py @@ -8,6 +8,7 @@ import openerp.addons.decimal_precision as dp from openerp.tools.float_utils import float_round from openerp.exceptions import UserError + class product_product(osv.osv): _inherit = "product.product" @@ -513,55 +514,6 @@ class product_template(osv.osv): return super(product_template, self).write(cr, uid, ids, vals, context=context) -class product_removal_strategy(osv.osv): - _name = 'product.removal' - _description = 'Removal Strategy' - - _columns = { - 'name': fields.char('Name', required=True), - 'method': fields.char("Method", required=True, help="FIFO, LIFO..."), - } - - -class product_putaway_strategy(osv.osv): - _name = 'product.putaway' - _description = 'Put Away Strategy' - - def _get_putaway_options(self, cr, uid, context=None): - return [('fixed', 'Fixed Location')] - - _columns = { - 'name': fields.char('Name', required=True), - 'method': fields.selection(_get_putaway_options, "Method", required=True), - 'fixed_location_ids': fields.one2many('stock.fixed.putaway.strat', 'putaway_id', 'Fixed Locations Per Product Category', help="When the method is fixed, this location will be used to store the products", copy=True), - } - - _defaults = { - 'method': 'fixed', - } - - def putaway_apply(self, cr, uid, ids, product, context=None): - putaway_strat = self.browse(cr, uid, ids[0], context=context) - if putaway_strat.method == 'fixed': - for strat in putaway_strat.fixed_location_ids: - categ = product.categ_id - while categ: - if strat.category_id.id == categ.id: - return strat.fixed_location_id.id - categ = categ.parent_id - - -class fixed_putaway_strat(osv.osv): - _name = 'stock.fixed.putaway.strat' - _order = 'sequence' - _columns = { - 'putaway_id': fields.many2one('product.putaway', 'Put Away Method', required=True), - 'category_id': fields.many2one('product.category', 'Product Category', required=True), - 'fixed_location_id': fields.many2one('stock.location', 'Location', required=True), - 'sequence': fields.integer('Priority', help="Give to the more specialized category, a higher priority to have them in top of the list."), - } - - class product_category(osv.osv): _inherit = 'product.category' diff --git a/addons/stock/models/product_strategy.py b/addons/stock/models/product_strategy.py new file mode 100644 index 00000000000..3b8d19e4d40 --- /dev/null +++ b/addons/stock/models/product_strategy.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from openerp.osv import fields, osv + + +class product_removal_strategy(osv.osv): + _name = 'product.removal' + _description = 'Removal Strategy' + + _columns = { + 'name': fields.char('Name', required=True), + 'method': fields.char("Method", required=True, help="FIFO, LIFO..."), + } + + +class product_putaway_strategy(osv.osv): + _name = 'product.putaway' + _description = 'Put Away Strategy' + + def _get_putaway_options(self, cr, uid, context=None): + return [('fixed', 'Fixed Location')] + + _columns = { + 'name': fields.char('Name', required=True), + 'method': fields.selection(_get_putaway_options, "Method", required=True), + 'fixed_location_ids': fields.one2many('stock.fixed.putaway.strat', 'putaway_id', 'Fixed Locations Per Product Category', help="When the method is fixed, this location will be used to store the products", copy=True), + } + + _defaults = { + 'method': 'fixed', + } + + def putaway_apply(self, cr, uid, ids, product, context=None): + putaway_strat = self.browse(cr, uid, ids[0], context=context) + if putaway_strat.method == 'fixed': + for strat in putaway_strat.fixed_location_ids: + categ = product.categ_id + while categ: + if strat.category_id.id == categ.id: + return strat.fixed_location_id.id + categ = categ.parent_id + + +class fixed_putaway_strat(osv.osv): + _name = 'stock.fixed.putaway.strat' + _order = 'sequence' + _columns = { + 'putaway_id': fields.many2one('product.putaway', 'Put Away Method', required=True), + 'category_id': fields.many2one('product.category', 'Product Category', required=True), + 'fixed_location_id': fields.many2one('stock.location', 'Location', required=True), + 'sequence': fields.integer('Priority', help="Give to the more specialized category, a higher priority to have them in top of the list."), + } \ No newline at end of file diff --git a/addons/stock/res_company.py b/addons/stock/models/res_company.py similarity index 100% rename from addons/stock/res_company.py rename to addons/stock/models/res_company.py diff --git a/addons/stock/partner.py b/addons/stock/models/res_partner.py similarity index 100% rename from addons/stock/partner.py rename to addons/stock/models/res_partner.py diff --git a/addons/stock/res_config.py b/addons/stock/models/stock_config_settings.py similarity index 100% rename from addons/stock/res_config.py rename to addons/stock/models/stock_config_settings.py diff --git a/addons/stock/web_planner.py b/addons/stock/models/web_planner.py similarity index 100% rename from addons/stock/web_planner.py rename to addons/stock/models/web_planner.py diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 24ec392a3a9..9db1ee8da97 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -5,7 +5,6 @@ from datetime import datetime from dateutil import relativedelta import json import time -import sets from openerp.osv import fields, osv from openerp.tools.float_utils import float_compare, float_round @@ -4936,19 +4935,6 @@ class stock_picking_type(osv.osv): 'use_create_lots': True, } -class barcode_rule(models.Model): - _inherit = 'barcode.rule' - - def _get_type_selection(self): - types = sets.Set(super(barcode_rule,self)._get_type_selection()) - types.update([ - ('weight', _('Weighted Product')), - ('location', _('Location')), - ('lot', _('Lot')), - ('package', _('Package')) - ]) - return list(types) - class StockPackOperation(models.Model): _inherit = 'stock.pack.operation' diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index d5db9efa796..ac26c41b86c 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -386,42 +386,6 @@ - - product.putaway.form - product.putaway - -
- - - - -
- - - - - - - - -
-
-
-
- - - product.removal.form - product.removal - -
- - - - -
-
-
- stock.location.path.select stock.location.path @@ -485,24 +449,6 @@ - - product.category.form - product.category - - - - - -
- The following routes will apply to the products in this category taking into account parent categories: - -
- -
-
-
-
- Locations stock.location @@ -1918,86 +1864,6 @@ src_model="stock.warehouse" groups="stock.group_stock_user"/> - - - - procurement.order.form.stock.inherit - procurement.order - - - - - - - - - -
-
- - - - -
-
- - procurement.order.tree.stock.inherit - procurement.order - - - - - - - - - procurement.rule.tree.stock.inherit - procurement.rule - - - - - - - - - - procurement.rule.form.stock.inherit - procurement.rule - - - - - - - - - - - - - - - - - - - - - - - - - {'search_default_route_false':1} - Procurement Rules - procurement.rule - - {'search_default_route_false':1} Push Rules @@ -2131,23 +1997,10 @@ - - - - - - - - - - {'default_product_id': active_id, 'search_default_product_id': active_id} - Reordering Rules - stock.warehouse.orderpoint - Stock On Hand @@ -2369,15 +2222,5 @@ tree,form [('group_id','=',active_id)] - - procurement.group.form.herited - procurement.group - - -
-
-
-
diff --git a/addons/stock/views/procurement_views.xml b/addons/stock/views/procurement_views.xml new file mode 100644 index 00000000000..241b0a296d8 --- /dev/null +++ b/addons/stock/views/procurement_views.xml @@ -0,0 +1,101 @@ + + + + procurement.group.view.form.inherit.picking + procurement.group + + +
+
+
+
+ + + + + procurement.order.form.stock.inherit + procurement.order + + + + + + + + + +
+
+ + + + +
+
+ + procurement.order.tree.stock.inherit + procurement.order + + + + + + + + + procurement.rule.tree.stock.inherit + procurement.rule + + + + + + + + + + procurement.rule.form.stock.inherit + procurement.rule + + + + + + + + + + + + + + + + + + + + + + + + + {'search_default_route_false':1} + Procurement Rules + procurement.rule + + + + + + + + + +
\ No newline at end of file diff --git a/addons/stock/views/product_strategy_views.xml b/addons/stock/views/product_strategy_views.xml new file mode 100644 index 00000000000..c93a1428bbd --- /dev/null +++ b/addons/stock/views/product_strategy_views.xml @@ -0,0 +1,38 @@ + + + + product.putaway.form + product.putaway + +
+ + + + +
+ + + + + + + + +
+
+
+
+ + + product.removal.form + product.removal + +
+ + + + +
+
+
+
\ No newline at end of file diff --git a/addons/stock/product_view.xml b/addons/stock/views/product_views.xml similarity index 89% rename from addons/stock/product_view.xml rename to addons/stock/views/product_views.xml index 050cc3eb1df..fc668c0d2e6 100644 --- a/addons/stock/product_view.xml +++ b/addons/stock/views/product_views.xml @@ -2,6 +2,30 @@ + + product.category.form + product.category + + + + + +
+ The following routes will apply to the products in this category taking into account parent categories: + +
+ +
+
+
+
+ + + {'default_product_id': active_id, 'search_default_product_id': active_id} + Reordering Rules + stock.warehouse.orderpoint + + product.stock.tree.inherit product.product @@ -328,5 +352,24 @@
+ + + Products + ir.actions.act_window + product.template + kanban,tree,form + form + {"search_default_products": 1, 'default_type': 'product'} + +

+ Click to define a new product. +

+
+
+ + + diff --git a/addons/stock/partner_view.xml b/addons/stock/views/res_partner_views.xml similarity index 100% rename from addons/stock/partner_view.xml rename to addons/stock/views/res_partner_views.xml diff --git a/addons/stock/res_config_view.xml b/addons/stock/views/stock_config_settings_views.xml similarity index 100% rename from addons/stock/res_config_view.xml rename to addons/stock/views/stock_config_settings_views.xml diff --git a/addons/stock/views/stock_menu_views.xml b/addons/stock/views/stock_menu_views.xml index 623fdbc1fc6..7484db4d3b5 100644 --- a/addons/stock/views/stock_menu_views.xml +++ b/addons/stock/views/stock_menu_views.xml @@ -11,9 +11,11 @@ + + @@ -23,27 +25,11 @@ + - - Products - ir.actions.act_window - product.template - kanban,tree,form - form - {"search_default_products": 1, 'default_type': 'product'} - -

- Click to define a new product. -

-
-
- - \ No newline at end of file