[UPD] Create a models and views subdirectories and split the source code by objects

This commit is contained in:
EL HADJI DEM
2015-08-10 14:27:37 -04:00
parent d183bf0450
commit ee52130d55
6 changed files with 83 additions and 33 deletions

View File

@@ -21,6 +21,6 @@
##############################################################################
from . import (
stock,
models,
report,
)

View File

@@ -46,7 +46,7 @@ Contributors
'stock',
],
'data': [
"stock_view.xml",
"views/stock_view.xml",
],
'application': False,
'installable': True,

View File

@@ -0,0 +1,26 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 - Present Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
#
# 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/>.
#
##############################################################################
from . import (
stock_location,
stock_move,
)

View File

@@ -20,7 +20,7 @@
#
##############################################################################
from openerp.osv import fields, orm
from openerp.osv import orm
from openerp.tools.translate import _
from openerp.tools.float_utils import float_compare
@@ -76,33 +76,3 @@ class StockLocation(orm.Model):
return super(StockLocation, self).write(
cr, uid, ids, vals, context=context
)
class StockMove(orm.Model):
"""
Subclass stock.move model.
Extend the model stock.move to add a constraint to check if
the location is disable
"""
_name = "stock.move"
_inherit = "stock.move"
def action_done(self, cr, uid, ids, context=None):
"""Override the action_done to add constraint to check if the
location_dest is disable"""
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
active = self.browse(cr, uid, ids, context)[0].location_dest_id.active
if not active:
raise orm.except_orm(
_('Validation Error'),
_('You cannot disable a location that contains products '
'or sub-locations')
)
return super(StockMove, self).action_done(
cr, uid, ids, context=context)

View File

@@ -0,0 +1,54 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 - Present Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
#
# 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/>.
#
##############################################################################
from openerp.osv import orm
from openerp.tools.translate import _
class StockMove(orm.Model):
"""
Subclass stock.move model.
Extend the model stock.move to add a constraint to check if
the location is disable
"""
_name = "stock.move"
_inherit = "stock.move"
def action_done(self, cr, uid, ids, context=None):
"""Override the action_done to add constraint to check if the
location_dest is disable"""
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
active = self.browse(cr, uid, ids, context)[0].location_dest_id.active
if not active:
raise orm.except_orm(
_('Validation Error'),
_('You cannot disable a location that contains products '
'or sub-locations')
)
return super(StockMove, self).action_done(
cr, uid, ids, context=context)