mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[UPD] Create a models and views subdirectories and split the source code by objects
This commit is contained in:
@@ -21,6 +21,6 @@
|
||||
##############################################################################
|
||||
|
||||
from . import (
|
||||
stock,
|
||||
models,
|
||||
report,
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ Contributors
|
||||
'stock',
|
||||
],
|
||||
'data': [
|
||||
"stock_view.xml",
|
||||
"views/stock_view.xml",
|
||||
],
|
||||
'application': False,
|
||||
'installable': True,
|
||||
|
||||
26
stock_location_inactive/models/__init__.py
Normal file
26
stock_location_inactive/models/__init__.py
Normal 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,
|
||||
)
|
||||
@@ -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)
|
||||
54
stock_location_inactive/models/stock_move.py
Normal file
54
stock_location_inactive/models/stock_move.py
Normal 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)
|
||||
Reference in New Issue
Block a user