Feat(MySQL): Database population with data for Kitchen project.

This commit is contained in:
2024-11-11 14:56:55 +00:00
parent db15a7f8fc
commit 88ccfe592a
26 changed files with 591 additions and 280 deletions

View File

@@ -54,6 +54,7 @@ class Address(db.Model, Base):
address = cls()
address.id_address = query_row[1]
address.id_region = query_row[2]
return address
@classmethod
def from_DB_stock_item(cls, query_row):
address = cls()
@@ -81,7 +82,7 @@ class Address(db.Model, Base):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_ADDRESS: self.id_address,
self.FLAG_REGION: self.region.to_json(),
self.FLAG_REGION: None if self.region is None else self.region.to_json(),
self.FLAG_POSTCODE: self.postcode,
self.FLAG_ADDRESS_LINE_1: self.address_line_1,
self.FLAG_ADDRESS_LINE_2: self.address_line_2,

View File

@@ -76,7 +76,7 @@ class Plant(db.Model, Store_Base):
self.ATTR_ID_PLANT: self.id_plant,
self.FLAG_CODE: self.code,
self.FLAG_NAME: self.name,
self.FLAG_ADDRESS: self.address.to_json(),
self.FLAG_ADDRESS: None if self.address is None else self.address.to_json(),
self.ATTR_ID_USER_MANAGER: self.id_user_manager,
self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0
}

View File

@@ -43,9 +43,9 @@ class Storage_Location(db.Model, Store_Base):
location.id_location = query_row[0]
location.id_plant = query_row[1]
location.plant = Plant.from_DB_storage_location(query_row)
location.code = query_row[2]
location.name = query_row[3]
location.active = query_row[4]
location.code = query_row[4]
location.name = query_row[5]
location.active = query_row[6]
return location
@classmethod
def from_DB_stock_item(cls, query_row):