Active Record
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of this
|
||||
#repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from .stock import *
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Location,
|
||||
module='stock_location_sequence', type_='model')
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
#This file is part of Tryton. 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.model import fields
|
||||
from trytond.pyson import Not, Eval, Bool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.backend import TableHandler
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Location']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Location(ModelSQL, ModelView):
|
||||
class Location:
|
||||
"Stock Location"
|
||||
_name = 'stock.location'
|
||||
__name__ = 'stock.location'
|
||||
sequence = fields.Integer('Sequence',
|
||||
order_field='(%(table)s.sequence IS NULL) %(order)s, '
|
||||
'%(table)s.sequence %(order)s',
|
||||
@@ -17,17 +21,17 @@ class Location(ModelSQL, ModelView):
|
||||
},
|
||||
depends=['active'])
|
||||
|
||||
def __init__(self):
|
||||
super(Location, self).__init__()
|
||||
self._order.insert(0, ('sequence', 'ASC'))
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Location, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
def init(self, module_name):
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
cursor = Transaction().cursor
|
||||
table = TableHandler(cursor, self, module_name)
|
||||
table = TableHandler(cursor, cls, module_name)
|
||||
|
||||
super(Location, self).init(module_name)
|
||||
super(Location, cls).__register__(module_name)
|
||||
|
||||
# Migration from 2.4: drop required on sequence
|
||||
table.not_null_action('sequence', action='remove')
|
||||
|
||||
Location()
|
||||
|
||||
Reference in New Issue
Block a user