add id_internal in placeholder model
This commit is contained in:
parent
45ae96ce33
commit
02f394d81e
|
@ -75,11 +75,15 @@ def create_code(context):
|
||||||
return hashcode.encode(_id)
|
return hashcode.encode(_id)
|
||||||
|
|
||||||
|
|
||||||
def create_phid(context):
|
def create_phid(context, count=1):
|
||||||
_hid = Placeholder.query.order_by(Placeholder.id.desc()).first()
|
phid = str(Placeholder.query.filter(Placeholder.owner == g.user).count() + count)
|
||||||
if _hid:
|
if (
|
||||||
return str(_hid.id + 1)
|
Placeholder.query.filter(Placeholder.owner == g.user)
|
||||||
return '1'
|
.filter(Placeholder.phid == phid)
|
||||||
|
.count()
|
||||||
|
):
|
||||||
|
return create_phid(context, count=count + 1)
|
||||||
|
return phid
|
||||||
|
|
||||||
|
|
||||||
class Device(Thing):
|
class Device(Thing):
|
||||||
|
@ -901,8 +905,8 @@ class DisplayMixin:
|
||||||
|
|
||||||
class Placeholder(Thing):
|
class Placeholder(Thing):
|
||||||
id = Column(BigInteger, Sequence('placeholder_seq'), primary_key=True)
|
id = Column(BigInteger, Sequence('placeholder_seq'), primary_key=True)
|
||||||
|
phid = Column(nullable=False, default=create_phid)
|
||||||
pallet = Column(Unicode(), nullable=True)
|
pallet = Column(Unicode(), nullable=True)
|
||||||
phid = Column(Unicode(), nullable=False, default=create_phid)
|
|
||||||
pallet.comment = "used for identification where from where is this placeholders"
|
pallet.comment = "used for identification where from where is this placeholders"
|
||||||
info = db.Column(CIText())
|
info = db.Column(CIText())
|
||||||
components = Column(CIText())
|
components = Column(CIText())
|
||||||
|
@ -912,6 +916,8 @@ class Placeholder(Thing):
|
||||||
id_device_supplier.comment = (
|
id_device_supplier.comment = (
|
||||||
"Identification used for one supplier of one placeholders"
|
"Identification used for one supplier of one placeholders"
|
||||||
)
|
)
|
||||||
|
id_device_internal = db.Column(CIText())
|
||||||
|
id_device_internal.comment = "Identification used internaly for the user"
|
||||||
|
|
||||||
device_id = db.Column(
|
device_id = db.Column(
|
||||||
BigInteger,
|
BigInteger,
|
||||||
|
|
Reference in New Issue