mirror of
https://gitlab.com/datalifeit/trytond-stock_product_category_location
synced 2023-12-14 04:33:11 +01:00
501 Parametrización del almacén para la confección
This commit is contained in:
parent
46c557678c
commit
727ae66cc3
20
location.py
20
location.py
|
@ -1,7 +1,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pyson import If, Eval, Bool, Not, Equal
|
||||
from trytond.pyson import In, Eval, Bool, Not, Equal
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.transaction import Transaction
|
||||
from sql.aggregate import Max
|
||||
|
@ -21,17 +21,12 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
|||
warehouse = fields.Many2One('stock.location', 'Warehouse', required=True,
|
||||
domain=[('type', '=', 'warehouse')],
|
||||
states={
|
||||
'invisible':
|
||||
If(Bool(Eval('context', {}).get('current_location', None)), True, False),
|
||||
'readonly':
|
||||
If(Bool(Eval('context', {}).get('current_location', None)), True, False)
|
||||
'invisible': Bool(Eval('context', {}).get('current_location', None)),
|
||||
'readonly': Bool(Eval('context', {}).get('current_location', None)),
|
||||
},
|
||||
ondelete='CASCADE')
|
||||
location = fields.Many2One('stock.location', 'Storage Location', required=True, ondelete='CASCADE',
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
('parent', 'child_of', If(Bool(Eval('warehouse')), [Eval('warehouse')], [])),
|
||||
],
|
||||
domain=[('type', '=', 'storage'), ('parent', 'child_of', Eval('warehouse'))],
|
||||
depends=['warehouse'])
|
||||
process = fields.Selection('get_processes', 'Process', required=True, select=True, translate=True)
|
||||
sequence = fields.Integer('Sequence')
|
||||
|
@ -71,9 +66,10 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
|||
if loc_id:
|
||||
location_pool = Pool().get('stock.location')
|
||||
loc = location_pool(loc_id)
|
||||
while not loc.parent.type == 'warehouse':
|
||||
loc = loc.parent
|
||||
return loc.parent.id
|
||||
if loc.type == 'storage':
|
||||
while not loc.parent.type == 'warehouse':
|
||||
loc = loc.parent
|
||||
return loc.parent.id
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -10,7 +10,7 @@ import doctest
|
|||
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
|
||||
|
||||
class StockProductCategoryLocationTestCase(ModuleTestCase):
|
||||
"""Test module"""
|
||||
"""Test Stock Product Category Location module"""
|
||||
module = 'stock_product_category_location'
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in a new issue