lavkach3
1369 строк · 54.9 Кб
1from alembic import op2import sqlalchemy as sa3from uuid import uuid44from core.core_apps.base.company.models.company_models import Company5from core.core_apps.base.user.models.user_models import User6from core.core_apps.base.user.models.role_models import Role7from app.basic.store.models.store_models import Store8from app.basic.product.models.product_models import Product, ProductCategory9
10from app.inventory.product_storage.models.product_storage_models import ProductStorageType11from app.basic.uom.models.uom_models import Uom12from app.basic.uom.models.uom_category_models import UomCategory13from datetime import datetime14from app.inventory.location.models import Location, LocationType15from app.inventory.order.models import OrderType, Order16from app.inventory.quant.models import Lot, Quant17from sqlalchemy_utils.types import PasswordType18
19# revision identifiers, used by Alembic.
20revision = '6ea1b38aba41'21down_revision = 'c91e663a5810'22branch_labels = None23depends_on = 'c91e663a5810'24
25
26def upgrade():27company_1_id = uuid4().__str__()28company_2_id = uuid4().__str__()29store_1_company_1_id = uuid4().__str__()30store_2_company_1_id = uuid4().__str__()31store_3_company_1_id = uuid4().__str__()32store_1_company_2_id = uuid4().__str__()33store_2_company_2_id = uuid4().__str__()34store_3_company_2_id = uuid4().__str__()35user_admin_id = uuid4().__str__()36user_1_company_1_id = uuid4().__str__()37user_2_company_1_id = uuid4().__str__()38user_1_company_2_id = uuid4().__str__()39user_2_company_2_id = uuid4().__str__()40role_1_company_1_id = uuid4().__str__()41role_2_company_1_id = uuid4().__str__()42role_1_company_2_id = uuid4().__str__()43role_2_company_2_id = uuid4().__str__()44uom_category_1_company_1 = uuid4().__str__()45uom_category_1_company_2 = uuid4().__str__()46uom_1_company_1 = uuid4().__str__()47uom_1_company_2 = uuid4().__str__()48product_category_1_company_1 = uuid4().__str__()49product_category_1_company_2 = uuid4().__str__()50product_storage_type_1_company_1 = uuid4().__str__()51product_storage_type_1_company_2 = uuid4().__str__()52product_1_company_1_id = uuid4().__str__()53product_2_company_1_id = uuid4().__str__()54product_1_company_2_id = uuid4().__str__()55product_2_company_2_id = uuid4().__str__()56from passlib.hash import pbkdf2_sha51257target = User()58target.password = '1402'59new_password = pbkdf2_sha512.encrypt("1402")60
61# ### commands auto generated by Alembic - please adjust! ###62op.bulk_insert(Company.__table__,63[64{65'id': company_1_id,66'lsn': 1,67"title": "Apple",68"external_number": "100000",69"locale": "en_US",70"country": "US",71"currency": "USD",72'created_at': datetime.now(),73'updated_at': datetime.now(),74},75{76'id': company_2_id,77'lsn': 2,78"title": "Yandex",79"external_number": "100001",80"locale": "ru_RU",81"country": "RU",82"currency": "RUB",83'created_at': datetime.now(),84'updated_at': datetime.now(),85}86])87
88op.bulk_insert(ProductCategory.__table__, [89{90'id': product_category_1_company_1,91'lsn': 1,92"company_id": company_1_id,93"title": "Product Category 1",94'created_at': datetime.now(),95'updated_at': datetime.now(),96},97{98'id': product_category_1_company_2,99'lsn': 1,100"company_id": company_2_id,101"title": "Product Category 1",102'created_at': datetime.now(),103'updated_at': datetime.now(),104},105])106
107op.bulk_insert(UomCategory.__table__, [108{109'id': uom_category_1_company_1,110'lsn': 1,111"company_id": company_1_id,112"title": "Uom category 1",113'created_at': datetime.now(),114'updated_at': datetime.now(),115},116{117'id': uom_category_1_company_2,118'lsn': 2,119"company_id": company_2_id,120"title": "Uom category 2",121'created_at': datetime.now(),122'updated_at': datetime.now(),123},124])125op.bulk_insert(Uom.__table__, [126{127'id': uom_1_company_1,128'lsn': 1,129"company_id": company_1_id,130"title": "Uom 1",131'uom_category_id': uom_category_1_company_1,132'type': 'standart',133'ratio': 2,134'precision': 2,135'created_at': datetime.now(),136'updated_at': datetime.now(),137},138{139'id': uom_1_company_2,140'lsn': 1,141"company_id": company_2_id,142"title": "Uom 1",143'uom_category_id': uom_category_1_company_2,144'type': 'standart',145'ratio': 2,146'precision': 2,147'created_at': datetime.now(),148'updated_at': datetime.now(),149},150])151op.bulk_insert(Product.__table__, [152{153'id': product_storage_type_1_company_1,154'lsn': 1,155"company_id": company_1_id,156"title": "Product Storage type 1",157'product_type': 'storable',158'uom_id': uom_1_company_1,159'product_category_id': product_category_1_company_1,160'barcode_list': ['111'],161'created_at': datetime.now(),162'updated_at': datetime.now(),163},164{165'id': product_storage_type_1_company_2,166'lsn': 2,167"company_id": company_2_id,168"title": "Product Storage type 1",169'product_type': 'storable',170'uom_id': uom_1_company_2,171'barcode_list': ['111'],172'product_category_id': product_category_1_company_2,173'created_at': datetime.now(),174'updated_at': datetime.now(),175},176])177op.bulk_insert(Store.__table__,178[179{180'id': store_1_company_1_id,181'lsn': 1,182"company_id": company_1_id,183"title": "Apple Store New York",184"external_number": "100",185"address": "Gansevoort St",186"source": "internal",187'created_at': datetime.now(),188'updated_at': datetime.now(),189},190{191'id': store_2_company_1_id,192'lsn': 2,193"company_id": company_1_id,194"title": "Apple Store Florida",195"external_number": "101",196"address": "Florida St",197"source": "internal",198'created_at': datetime.now(),199'updated_at': datetime.now(),200},201{202'id': store_3_company_1_id,203'lsn': 2,204"company_id": company_1_id,205"title": "Apple Store Denver",206"external_number": "109",207"address": "Denver St",208"source": "internal",209'created_at': datetime.now(),210'updated_at': datetime.now(),211},212{213'id': store_1_company_2_id,214'lsn': 1,215"company_id": company_2_id,216"title": "Yandex Market",217"external_number": "117",218"address": "Lenina 4",219"source": "internal",220'created_at': datetime.now(),221'updated_at': datetime.now(),222},223{224'id': store_2_company_2_id,225'lsn': 2,226"company_id": company_2_id,227"title": "Yandex HUB Taxi",228"external_number": "108",229"address": "Stalina 90 st",230"source": "internal",231'created_at': datetime.now(),232'updated_at': datetime.now(),233},234{235'id': store_3_company_2_id,236'lsn': 2,237"company_id": company_2_id,238"title": "Yandex Lavka Gamovniki",239"external_number": "102",240"address": "Burjuya 17 St",241"source": "internal",242'created_at': datetime.now(),243'updated_at': datetime.now(),244}245])246
247op.bulk_insert(Role.__table__,248[249{250"id": role_1_company_1_id,251'lsn': 2,252"title": "support",253'created_at': datetime.now(),254'updated_at': datetime.now(),255"permission_allow_list": [256"user_create",257"user_edit",258"user_list",259"user_delete",260"user_get",261],262"company_id": company_1_id263},264{265"id": role_2_company_1_id,266"title": "admin",267'lsn': 3,268'created_at': datetime.now(),269'updated_at': datetime.now(),270'is_admin': True,271"permission_allow_list": [272"company_create",273"company_edit",274"company_list",275"company_delete",276"company_get",277],278"company_id": company_1_id,279'company_ids': [280company_1_id,281company_2_id
282]283},284{285"id": role_1_company_2_id,286'lsn': 4,287"title": "support",288'created_at': datetime.now(),289'updated_at': datetime.now(),290"permission_allow_list": [291"user_create",292"user_edit",293"user_list",294"user_delete",295"user_get",296],297"company_id": company_2_id298},299{300"id": role_2_company_2_id,301'lsn': 5,302"title": "admin",303'created_at': datetime.now(),304'updated_at': datetime.now(),305"permission_allow_list": [306"company_create",307"company_edit",308"company_list",309"company_delete",310"company_get",311],312"company_id": company_2_id313}314])315op.bulk_insert(User.__table__,316[317{318"id": user_admin_id,319'lsn': 1,320"email": "admin@admin.ru",321"country": "US",322"locale": "en_US",323"phone_number": "+449534771093",324"nickname": "Admin",325"is_admin": True,326"company_id": company_1_id,327"company_ids": [company_1_id, company_2_id],328'created_at': datetime.now(),329'updated_at': datetime.now(),330"password": '1402'331},332{333"id": user_1_company_1_id,334'lsn': 3,335"email": "user1@apple.ru",336"country": "RU",337"locale": "ru_RU",338"phone_number": "+449534771093",339"nickname": "Albert",340'created_at': datetime.now(),341'updated_at': datetime.now(),342"roles": [343role_1_company_1_id
344],345"is_admin": False,346"company_id": company_1_id,347"company_ids": [company_1_id],348"password": '1402'349},350{351"id": user_2_company_1_id,352'lsn': 4,353"email": "user2@apple.ru",354"country": "RU",355"locale": "ru_RU",356"phone_number": "+449534771093",357"nickname": "Albert",358"company_id": company_1_id,359"company_ids": [company_1_id],360'created_at': datetime.now(),361'updated_at': datetime.now(),362"roles": [363role_2_company_1_id
364],365"is_admin": False,366"password": '1402'367},368{369"id": user_1_company_2_id,370'lsn': 5,371"email": "user1@yandex.ru",372"country": "RU",373"locale": "ru_RU",374"phone_number": "+449534771093",375"nickname": "Albert",376'created_at': datetime.now(),377'updated_at': datetime.now(),378"is_admin": False,379"company_id": company_2_id,380"company_ids": [company_2_id],381"roles": [382role_1_company_2_id
383],384"password": '1402'385},386{387"id": user_2_company_2_id,388'lsn': 6,389"email": "user2@yandex.ru",390"country": "RU",391"locale": "ru_RU",392"phone_number": "+449534771093",393"nickname": "Albert",394"is_admin": False,395"company_id": company_2_id,396"company_ids": [company_2_id],397'created_at': datetime.now(),398'updated_at': datetime.now(),399"roles": [400role_2_company_2_id
401],402"password": '1402'403}404])405
406location_type_partner_company_1 = uuid4().__str__()407location_type_place_company_1 = uuid4().__str__()408location_type_resource_company_1 = uuid4().__str__()409location_type_package_company_1 = uuid4().__str__()410location_type_zone_company_1 = uuid4().__str__()411location_type_lost_company_1 = uuid4().__str__()412location_type_inventory_company_1 = uuid4().__str__()413location_type_scrap_company_1 = uuid4().__str__()414location_type_scrapped_company_1 = uuid4().__str__()415location_type_buffer_company_1 = uuid4().__str__()416location_type_partner_company_2 = uuid4().__str__()417location_type_place_company_2 = uuid4().__str__()418location_type_resource_company_2 = uuid4().__str__()419location_type_package_company_2 = uuid4().__str__()420location_type_zone_company_2 = uuid4().__str__()421location_type_lost_company_2 = uuid4().__str__()422location_type_inventory_company_2 = uuid4().__str__()423location_type_scrap_company_2 = uuid4().__str__()424location_type_scrapped_company_2 = uuid4().__str__()425location_type_buffer_company_2 = uuid4().__str__()426op.bulk_insert(LocationType.__table__,427[428{429'id': location_type_partner_company_1,430'lsn': 1,431"company_id": company_1_id,432"title": "partner",433"location_class": "partner",434"is_can_negative": True,435'created_at': datetime.now(),436'updated_at': datetime.now(),437},438{439'id': location_type_place_company_1,440'lsn': 2,441"company_id": company_1_id,442"title": "place",443"location_class": "place",444"is_can_negative": False,445'created_at': datetime.now(),446'updated_at': datetime.now(),447},448{449'id': location_type_resource_company_1,450'lsn': 3,451"company_id": company_1_id,452"title": "resource",453"location_class": "resource",454"is_can_negative": False,455'created_at': datetime.now(),456'updated_at': datetime.now(),457},458{459'id': location_type_package_company_1,460'lsn': 4,461"company_id": company_1_id,462"title": "package",463"location_class": "package",464"is_can_negative": False,465'created_at': datetime.now(),466'updated_at': datetime.now(),467},468{469'id': location_type_zone_company_1,470'lsn': 5,471"company_id": company_1_id,472"title": "zone",473"location_class": "zone",474"is_can_negative": False,475'created_at': datetime.now(),476'updated_at': datetime.now(),477},478{479'id': location_type_lost_company_1,480'lsn': 6,481"company_id": company_1_id,482"title": "lost",483"location_class": "lost",484"is_can_negative": True,485'created_at': datetime.now(),486'updated_at': datetime.now(),487},488{489'id': location_type_inventory_company_1,490'lsn': 7,491"company_id": company_1_id,492"title": "inventory",493"location_class": "inventory",494"is_can_negative": True,495'created_at': datetime.now(),496'updated_at': datetime.now(),497},498{499'id': location_type_scrap_company_1,500'lsn': 8,501"company_id": company_1_id,502"title": "scrap",503"location_class": "scrap",504"is_can_negative": False,505'created_at': datetime.now(),506'updated_at': datetime.now(),507},508{509'id': location_type_scrapped_company_1,510'lsn': 9,511"company_id": company_1_id,512"title": "scrapped",513"location_class": "scrapped",514"is_can_negative": False,515'created_at': datetime.now(),516'updated_at': datetime.now(),517},518{519'id': location_type_buffer_company_1,520'lsn': 10,521"company_id": company_1_id,522"title": "buffer",523"location_class": "buffer",524"is_can_negative": False,525'created_at': datetime.now(),526'updated_at': datetime.now(),527},528{529'id': location_type_partner_company_2,530'lsn': 1,531"company_id": company_2_id,532"title": "partner",533"is_can_negative": True,534"is_can_negative": False,535"location_class": "partner",536'created_at': datetime.now(),537'updated_at': datetime.now(),538},539{540'id': location_type_place_company_2,541'lsn': 2,542"company_id": company_2_id,543"title": "place",544"location_class": "place",545"is_can_negative": False,546'created_at': datetime.now(),547'updated_at': datetime.now(),548},549{550'id': location_type_resource_company_2,551'lsn': 3,552"company_id": company_2_id,553"title": "resource",554"location_class": "resource",555"is_can_negative": False,556'created_at': datetime.now(),557'updated_at': datetime.now(),558},559{560'id': location_type_package_company_2,561'lsn': 4,562"company_id": company_2_id,563"title": "package",564"location_class": "package",565"is_can_negative": False,566'created_at': datetime.now(),567'updated_at': datetime.now(),568},569{570'id': location_type_zone_company_2,571'lsn': 5,572"company_id": company_2_id,573"title": "zone",574"location_class": "zone",575"is_can_negative": False,576'created_at': datetime.now(),577'updated_at': datetime.now(),578},579{580'id': location_type_lost_company_2,581'lsn': 6,582"company_id": company_2_id,583"title": "lost",584"location_class": "lost",585"is_can_negative": True,586'created_at': datetime.now(),587'updated_at': datetime.now(),588},589{590'id': location_type_inventory_company_2,591'lsn': 7,592"company_id": company_2_id,593"title": "inventory",594"location_class": "inventory",595"is_can_negative": True,596'created_at': datetime.now(),597'updated_at': datetime.now(),598},599{600'id': location_type_scrap_company_2,601'lsn': 8,602"company_id": company_2_id,603"title": "scrap",604"location_class": "scrap",605"is_can_negative": False,606'created_at': datetime.now(),607'updated_at': datetime.now(),608},609{610'id': location_type_scrapped_company_2,611'lsn': 9,612"company_id": company_2_id,613"title": "scrapped",614"location_class": "scrapped",615"is_can_negative": False,616'created_at': datetime.now(),617'updated_at': datetime.now(),618},619{620'id': location_type_buffer_company_2,621'lsn': 10,622"company_id": company_2_id,623"title": "buffer",624"location_class": "buffer",625"is_can_negative": False,626'created_at': datetime.now(),627'updated_at': datetime.now(),628},629])630location_partner_company_1 = uuid4().__str__()631location_place_company_1 = uuid4().__str__()632location_resource_company_1 = uuid4().__str__()633location_package_company_1 = uuid4().__str__()634location_zone_company_1 = uuid4().__str__()635location_lost_company_1 = uuid4().__str__()636location_inventory_company_1 = uuid4().__str__()637location_scrap_company_1 = uuid4().__str__()638location_scrapped_company_1 = uuid4().__str__()639location_buffer_company_1 = uuid4().__str__()640location_partner_company_2 = uuid4().__str__()641location_place_company_2 = uuid4().__str__()642location_resource_company_2 = uuid4().__str__()643location_package_company_2 = uuid4().__str__()644location_zone_company_2 = uuid4().__str__()645location_lost_company_2 = uuid4().__str__()646location_inventory_company_2 = uuid4().__str__()647location_scrap_company_2 = uuid4().__str__()648location_scrapped_company_2 = uuid4().__str__()649location_buffer_company_2 = uuid4().__str__()650
651op.bulk_insert(Location.__table__, [652{653'id': location_partner_company_1,654'lsn': 1,655"company_id": company_1_id,656'created_at': datetime.now(),657'updated_at': datetime.now(),658'store_id': store_1_company_1_id,659'is_can_negative': True,660'location_type_id': location_type_partner_company_1,661'location_class': 'partner',662"title": f"LOCATION_PARTNER_COMPANY 1",663},664{665'id': location_resource_company_1,666'lsn': 3,667"company_id": company_1_id,668'created_at': datetime.now(),669'updated_at': datetime.now(),670'store_id': store_1_company_1_id,671"is_can_negative": False,672'location_type_id': location_type_resource_company_1,673'location_class': 'resource',674"title": f"LOCATION_RESOURCE_COMPANY 1",675},676{677'id': location_zone_company_1,678'lsn': 5,679"company_id": company_1_id,680'created_at': datetime.now(),681'updated_at': datetime.now(),682'store_id': store_1_company_1_id,683"is_can_negative": False,684'location_type_id': location_type_zone_company_1,685'location_class': 'zone',686"title": f"LOCATION_ZONE_COMPANY 1",687},688
689{690'id': location_lost_company_1,691'lsn': 6,692"company_id": company_1_id,693'created_at': datetime.now(),694'updated_at': datetime.now(),695'store_id': store_1_company_1_id,696'location_type_id': location_type_lost_company_1,697'location_class': 'lost',698'is_can_negative': True,699"title": f"LOCATION_LOST_COMPANY 1",700},701{702'id': location_inventory_company_1,703'lsn': 7,704"company_id": company_1_id,705'created_at': datetime.now(),706'updated_at': datetime.now(),707'store_id': store_1_company_1_id,708'location_type_id': location_type_inventory_company_1,709'location_class': 'inventory',710'is_can_negative': True,711"title": f"LOCATION_INVENTORY_COMPANY 1",712},713{714'id': location_scrap_company_1,715'lsn': 8,716"company_id": company_1_id,717'created_at': datetime.now(),718'updated_at': datetime.now(),719'store_id': store_1_company_1_id,720'location_type_id': location_type_scrap_company_1,721'location_class': 'scrap',722"is_can_negative": False,723"title": f"LOCATION_SCRAP_COMPANY 1",724},725{726'id': location_scrapped_company_1,727'lsn': 9,728"company_id": company_1_id,729'created_at': datetime.now(),730'updated_at': datetime.now(),731'store_id': store_1_company_1_id,732'location_type_id': location_type_scrapped_company_1,733'location_class': 'scrapped',734"is_can_negative": False,735"title": f"LOCATION_SCRAPED_COMPANY 1",736},737{738'id': location_buffer_company_1,739'lsn': 10,740"company_id": company_1_id,741'created_at': datetime.now(),742'updated_at': datetime.now(),743'store_id': store_1_company_1_id,744'location_type_id': location_type_buffer_company_1,745'location_class': 'buffer',746"is_can_negative": False,747"title": f"LOCATION_BUFFER_COMPANY 1",748},749{750'id': location_partner_company_2,751'lsn': 11,752"company_id": company_2_id,753'created_at': datetime.now(),754'updated_at': datetime.now(),755'store_id': store_1_company_2_id,756'location_type_id': location_type_partner_company_2,757'location_class': 'partner',758'is_can_negative': True,759"title": f"LOCATION_PARTNER_COMPANY 2",760},761{762'id': location_resource_company_2,763'lsn': 13,764"company_id": company_2_id,765'created_at': datetime.now(),766'updated_at': datetime.now(),767'store_id': store_1_company_2_id,768'location_type_id': location_type_resource_company_2,769'location_class': 'resource',770"is_can_negative": False,771"title": f"LOCATION_RESOURCE_COMPANY 2",772},773{774'id': location_zone_company_2,775'lsn': 16,776"company_id": company_2_id,777'created_at': datetime.now(),778'updated_at': datetime.now(),779'store_id': store_1_company_2_id,780'location_type_id': location_type_zone_company_2,781'location_class': 'zone',782"is_can_negative": False,783"title": f"LOCATION_ZONE_COMPANY 2",784},785
786{787'id': location_lost_company_2,788'lsn': 17,789"company_id": company_2_id,790'created_at': datetime.now(),791'updated_at': datetime.now(),792'store_id': store_1_company_2_id,793'location_type_id': location_type_lost_company_2,794'location_class': 'lost',795'is_can_negative': True,796"title": f"LOCATION_LOST_COMPANY 2",797},798{799'id': location_inventory_company_2,800'lsn': 18,801"company_id": company_2_id,802'created_at': datetime.now(),803'updated_at': datetime.now(),804'store_id': store_1_company_2_id,805'location_type_id': location_type_inventory_company_2,806'location_class': 'inventory',807"is_can_negative": False,808"title": f"LOCATION_INVENTORY_COMPANY 2",809},810{811'id': location_scrap_company_2,812'lsn': 19,813"company_id": company_2_id,814'created_at': datetime.now(),815'updated_at': datetime.now(),816'store_id': store_1_company_2_id,817'location_type_id': location_type_scrap_company_2,818'location_class': 'scrap',819"is_can_negative": False,820"title": f"LOCATION_SCRAP_COMPANY 2",821},822{823'id': location_scrapped_company_2,824'lsn': 20,825"company_id": company_2_id,826'created_at': datetime.now(),827'updated_at': datetime.now(),828'store_id': store_1_company_2_id,829'location_type_id': location_type_scrapped_company_2,830'location_class': 'scrapped',831"is_can_negative": False,832"title": f"LOCATION_SCRAPED_COMPANY 2",833},834{835'id': location_buffer_company_2,836'lsn': 21,837"company_id": company_2_id,838'created_at': datetime.now(),839'updated_at': datetime.now(),840'store_id': store_1_company_2_id,841'location_type_id': location_type_buffer_company_2,842'location_class': 'buffer',843"is_can_negative": False,844"title": f"LOCATION_BUFFER_COMPANY 2",845},846])847op.bulk_insert(Location.__table__, [848{849'id': location_place_company_1,850'lsn': 2,851"company_id": company_1_id,852'created_at': datetime.now(),853'parent_id': location_zone_company_1,854'updated_at': datetime.now(),855'store_id': store_1_company_1_id,856'location_type_id': location_type_place_company_1,857'location_class': 'place',858"is_can_negative": False,859"title": f"LOCATION_PLACE_COMPANY 1",860},861
862{863'id': location_package_company_1,864'lsn': 4,865"company_id": company_1_id,866"parent_id": location_place_company_1,867'created_at': datetime.now(),868'updated_at': datetime.now(),869'store_id': store_1_company_1_id,870'location_type_id': location_type_package_company_1,871'location_class': 'package',872"is_can_negative": False,873"title": f"LOCATION_PACKAGE_COMPANY 1",874},875{876'id': location_place_company_2,877'lsn': 12,878"company_id": company_2_id,879'parent_id': location_zone_company_2,880'created_at': datetime.now(),881'updated_at': datetime.now(),882'store_id': store_1_company_2_id,883'location_type_id': location_type_place_company_2,884'location_class': 'place',885"is_can_negative": False,886"title": f"LOCATION_PLACE_COMPANY 2",887},888{889'id': location_package_company_2,890'lsn': 15,891"company_id": company_2_id,892"parent_id": location_place_company_2,893'created_at': datetime.now(),894'updated_at': datetime.now(),895'store_id': store_1_company_2_id,896'location_type_id': location_type_package_company_2,897'location_class': 'package',898"is_can_negative": False,899"title": f"LOCATION_PACKAGE_COMPANY 2",900},901])902
903lot_1_company_1 = uuid4().__str__()904lot_2_company_1 = uuid4().__str__()905lot_1_company_2 = uuid4().__str__()906lot_2_company_2 = uuid4().__str__()907op.bulk_insert(Lot.__table__, [908{909'id': lot_1_company_1,910'lsn': 1,911"company_id": company_1_id,912'created_at': datetime.now(),913'updated_at': datetime.now(),914'expiration_date': datetime.now(),915'product_id': product_1_company_1_id,916'external_number': 'lot1_external1',917},918{919'id': lot_2_company_1,920'lsn': 2,921"company_id": company_2_id,922'created_at': datetime.now(),923'updated_at': datetime.now(),924'expiration_date': datetime.now(),925'product_id': product_2_company_1_id,926'external_number': 'lot2_external1',927},928{929'id': lot_1_company_2,930'lsn': 3,931"company_id": company_2_id,932'created_at': datetime.now(),933'updated_at': datetime.now(),934'expiration_date': datetime.now(),935'product_id': product_1_company_2_id,936'external_number': 'lot1_external2',937},938{939'id': lot_2_company_2,940'lsn': 4,941"company_id": company_2_id,942'created_at': datetime.now(),943'updated_at': datetime.now(),944'expiration_date': datetime.now(),945'product_id': product_2_company_2_id,946'external_number': 'lot2_external2',947},948])949quant_1_company_1 = uuid4().__str__()950quant_2_company_1 = uuid4().__str__()951quant_3_company_1 = uuid4().__str__()952quant_1_company_2 = uuid4().__str__()953quant_2_company_2 = uuid4().__str__()954quant_3_company_2 = uuid4().__str__()955# op.bulk_insert(Quant.__table__, [956# {957# 'id': quant_1_company_1,958# 'lsn': 1,959# "company_id": company_1_id,960# 'created_at': datetime.now(),961# 'updated_at': datetime.now(),962# 'store_id': store_1_company_1_id,963# 'lot_id': lot_1_company_1,964# 'quantity': 100.0,965# 'reserved_quantity': 0.0,966# 'expiration_date': datetime.now(),967# 'product_id': product_1_company_1_id,968# 'uom_id': uom_1_company_1,969# },970# {971# 'id': quant_2_company_1,972# 'lsn': 2,973# "company_id": company_1_id,974# 'created_at': datetime.now(),975# 'updated_at': datetime.now(),976# 'store_id': store_1_company_1_id,977# 'lot_id': lot_2_company_1,978# 'quantity': 200.0,979# 'reserved_quantity': 0.0,980# 'expiration_date': datetime.now(),981# 'product_id': product_1_company_1_id,982# 'uom_id': uom_1_company_1,983# },984# {985# 'id': quant_1_company_2,986# 'lsn': 4,987# "company_id": company_2_id,988# 'created_at': datetime.now(),989# 'updated_at': datetime.now(),990# 'store_id': store_2_company_1_id,991# 'lot_id': lot_1_company_2,992# 'quantity': 100.0,993# 'reserved_quantity': 0.0,994# 'expiration_date': datetime.now(),995# 'product_id': product_1_company_2_id,996# 'uom_id': uom_1_company_2,997# },998# {999# 'id': quant_2_company_2,1000# 'lsn': 5,1001# "company_id": company_2_id,1002# 'created_at': datetime.now(),1003# 'updated_at': datetime.now(),1004# 'store_id': store_2_company_1_id,1005# 'lot_id': lot_2_company_2,1006# 'quantity': 200.0,1007# 'reserved_quantity': 0.0,1008# 'expiration_date': datetime.now(),1009# 'product_id': product_1_company_2_id,1010# 'uom_id': uom_1_company_2,1011# },1012# ])1013order_type_inc_company_1 = uuid4().__str__()1014order_type_out_company_1 = uuid4().__str__()1015order_type_int_company_1 = uuid4().__str__()1016order_type_inc_company_2 = uuid4().__str__()1017order_type_out_company_2 = uuid4().__str__()1018order_type_int_company_2 = uuid4().__str__()1019op.bulk_insert(OrderType.__table__, [1020{1021'id': order_type_inc_company_1,1022'company_id': company_1_id,1023'prefix': 'INC',1024'title': 'Incoming type',1025'order_class': 'incoming',1026'allowed_location_src_ids': [location_partner_company_1, ],1027'exclusive_location_src_ids': None,1028'allowed_location_dest_ids': [location_buffer_company_1, ],1029'exclusive_location_dest_ids': None,1030'backorder_order_type_id': None,1031'backorder_action_type': 'ask',1032'store_id': None,1033'partner_id': None,1034'reservation_method': 'at_confirm',1035'reservation_time_before': 0,1036'allowed_package_ids': [],1037'exclusive_package_ids': None,1038'is_homogeneity': False,1039'is_allow_create_package': True,1040'is_can_create_order_manualy': True,1041'is_overdelivery': False,1042'created_by': user_1_company_1_id,1043'edited_by': user_1_company_1_id,1044'barcode': '2132132131231',1045'strategy': 'fefo',1046'created_at': datetime.now(),1047'updated_at': datetime.now(),1048},1049{1050'id': order_type_out_company_1,1051'company_id': company_1_id,1052'prefix': 'OUT',1053'title': 'OUT',1054'order_class': 'incoming',1055'allowed_location_src_ids': [location_buffer_company_1, ],1056'exclusive_location_src_ids': None,1057'allowed_location_dest_ids': [location_partner_company_1, ],1058'exclusive_location_dest_ids': None,1059'backorder_order_type_id': None,1060'backorder_action_type': 'ask',1061'store_id': None,1062'partner_id': None,1063'reservation_method': 'at_confirm',1064'reservation_time_before': 0,1065'allowed_package_ids': [],1066'exclusive_package_ids': None,1067'is_homogeneity': False,1068'is_allow_create_package': True,1069'is_can_create_order_manualy': True,1070'is_overdelivery': False,1071'created_by': user_1_company_1_id,1072'edited_by': user_1_company_1_id,1073'barcode': '2132132131231',1074'strategy': 'fefo',1075'created_at': datetime.now(),1076'updated_at': datetime.now(),1077},1078{1079'id': order_type_int_company_1,1080'company_id': company_1_id,1081'prefix': 'INT',1082'title': 'Internal type',1083'order_class': 'incoming',1084'allowed_location_src_ids': [],1085'exclusive_location_src_ids': None,1086'allowed_location_dest_ids': [],1087'exclusive_location_dest_ids': None,1088'backorder_order_type_id': None,1089'backorder_action_type': 'ask',1090'store_id': None,1091'partner_id': None,1092'reservation_method': 'at_confirm',1093'reservation_time_before': 0,1094'allowed_package_ids': [],1095'exclusive_package_ids': None,1096'is_homogeneity': False,1097'is_allow_create_package': True,1098'is_can_create_order_manualy': True,1099'is_overdelivery': False,1100'created_by': user_1_company_1_id,1101'edited_by': user_1_company_1_id,1102'barcode': '2132132131231',1103'strategy': 'fefo',1104'created_at': datetime.now(),1105'updated_at': datetime.now(),1106},1107# Company 21108{1109'id': order_type_inc_company_2,1110'company_id': company_2_id,1111'prefix': 'INC',1112'title': 'Incoming type',1113'order_class': 'incoming',1114'allowed_location_src_ids': [location_partner_company_2, ],1115'exclusive_location_src_ids': None,1116'allowed_location_dest_ids': [location_buffer_company_2, ],1117'exclusive_location_dest_ids': None,1118'backorder_order_type_id': None,1119'backorder_action_type': 'ask',1120'store_id': None,1121'partner_id': None,1122'reservation_method': 'at_confirm',1123'reservation_time_before': 0,1124'allowed_package_ids': [],1125'exclusive_package_ids': None,1126'is_homogeneity': False,1127'is_allow_create_package': True,1128'is_can_create_order_manualy': True,1129'is_overdelivery': False,1130'created_by': user_1_company_2_id,1131'edited_by': user_1_company_2_id,1132'barcode': '2132132131231',1133'strategy': 'fefo',1134'created_at': datetime.now(),1135'updated_at': datetime.now(),1136},1137{1138'id': order_type_out_company_2,1139'company_id': company_2_id,1140'prefix': 'OUT',1141'title': 'OUT',1142'order_class': 'incoming',1143'allowed_location_src_ids': [location_buffer_company_2, ],1144'exclusive_location_src_ids': None,1145'allowed_location_dest_ids': [location_partner_company_2, ],1146'exclusive_location_dest_ids': None,1147'backorder_order_type_id': None,1148'backorder_action_type': 'ask',1149'store_id': None,1150'partner_id': None,1151'reservation_method': 'at_confirm',1152'reservation_time_before': 0,1153'allowed_package_ids': [],1154'exclusive_package_ids': None,1155'is_homogeneity': False,1156'is_allow_create_package': True,1157'is_can_create_order_manualy': True,1158'is_overdelivery': False,1159'created_by': user_1_company_2_id,1160'edited_by': user_1_company_2_id,1161'barcode': '2132132131231',1162'strategy': 'fefo',1163'created_at': datetime.now(),1164'updated_at': datetime.now(),1165},1166{1167'id': order_type_int_company_2,1168'company_id': company_2_id,1169'prefix': 'INT',1170'title': 'Internal type',1171'order_class': 'incoming',1172'allowed_location_src_ids': [],1173'exclusive_location_src_ids': None,1174'allowed_location_dest_ids': [],1175'exclusive_location_dest_ids': None,1176'backorder_order_type_id': None,1177'backorder_action_type': 'ask',1178'store_id': None,1179'partner_id': None,1180'reservation_method': 'at_confirm',1181'reservation_time_before': 0,1182'allowed_package_ids': [],1183'exclusive_package_ids': None,1184'is_homogeneity': False,1185'is_allow_create_package': True,1186'is_can_create_order_manualy': True,1187'is_overdelivery': False,1188'created_by': user_1_company_2_id,1189'edited_by': user_1_company_2_id,1190'barcode': '2132132131231',1191'strategy': 'fefo',1192'created_at': datetime.now(),1193'updated_at': datetime.now(),1194},1195])1196
1197order_inc_company_1 = uuid4().__str__()1198order_out_company_1 = uuid4().__str__()1199order_int_company_1 = uuid4().__str__()1200order_inc_company_2 = uuid4().__str__()1201order_out_company_2 = uuid4().__str__()1202order_int_company_2 = uuid4().__str__()1203op.bulk_insert(Order.__table__, [1204{1205'id': order_inc_company_1,1206'number': 'number',1207'company_id': company_1_id,1208'order_type_id': order_type_inc_company_1,1209'parent_id': None,1210'external_number': 'order_inc_company_1',1211'store_id': store_1_company_1_id,1212'partner_id': None,1213'lot_id': None,1214'origin_type': 'Purchase Order',1215'origin_number': 'Some Purchase Order Number',1216'planned_date': datetime.now(),1217'actual_date': None,1218'created_by': user_1_company_1_id,1219'edited_by': user_1_company_1_id,1220'expiration_date': datetime.now(),1221'users_ids': None,1222'description': 'description',1223'status': 'draft'1224},1225{1226'id': order_out_company_1,1227'company_id': company_1_id,1228'number': 'number',1229'order_type_id': order_type_out_company_1,1230'parent_id': None,1231'external_number': 'order_out_company_1',1232'store_id': store_1_company_1_id,1233'partner_id': None,1234'lot_id': None,1235'origin_type': 'Shipment Order',1236'origin_number': 'Shipment',1237'planned_date': datetime.now(),1238'actual_date': None,1239'created_by': user_1_company_1_id,1240'edited_by': user_1_company_1_id,1241'expiration_date': datetime.now(),1242'users_ids': None,1243'description': 'description',1244'status': 'draft'1245},1246{1247'id': order_int_company_1,1248'company_id': company_1_id,1249'number': 'number',1250'order_type_id': order_type_int_company_1,1251'parent_id': None,1252'external_number': 'order_int_company_1',1253'store_id': store_1_company_1_id,1254'partner_id': None,1255'lot_id': None,1256'origin_type': 'Internatl Order',1257'origin_number': 'Internal',1258'planned_date': datetime.now(),1259'actual_date': None,1260'created_by': user_1_company_1_id,1261'edited_by': user_1_company_1_id,1262'expiration_date': datetime.now(),1263'users_ids': None,1264'description': 'description',1265'status': 'draft'1266},1267# Company 21268{1269'id': order_inc_company_2,1270'company_id': company_2_id,1271'number': 'number',1272'order_type_id': order_type_inc_company_2,1273'parent_id': None,1274'external_number': 'order_inc_company_2',1275'store_id': store_1_company_2_id,1276'partner_id': None,1277'lot_id': None,1278'origin_type': 'Purchase Order',1279'origin_number': 'Some Purchase Order Number',1280'planned_date': datetime.now(),1281'actual_date': None,1282'created_by': user_1_company_2_id,1283'edited_by': user_1_company_2_id,1284'expiration_date': datetime.now(),1285'users_ids': None,1286'description': 'description',1287'status': 'draft'1288},1289{1290'id': order_out_company_2,1291'company_id': company_2_id,1292'number': 'number',1293'order_type_id': order_type_out_company_2,1294'parent_id': None,1295'external_number': 'order_out_company_2',1296'store_id': store_1_company_2_id,1297'partner_id': None,1298'lot_id': None,1299'origin_type': 'Shipment Order',1300'origin_number': 'Shipment',1301'planned_date': datetime.now(),1302'actual_date': None,1303'created_by': user_1_company_2_id,1304'edited_by': user_1_company_2_id,1305'expiration_date': datetime.now(),1306'users_ids': None,1307'description': 'description',1308'status': 'draft'1309},1310{1311'id': order_int_company_2,1312'company_id': company_2_id,1313'number': 'number',1314'order_type_id': order_type_int_company_2,1315'parent_id': None,1316'external_number': 'order_int_company_2',1317'store_id': store_1_company_2_id,1318'partner_id': None,1319'lot_id': None,1320'origin_type': 'Internatl Order',1321'origin_number': 'Internal',1322'planned_date': datetime.now(),1323'actual_date': None,1324'created_by': user_1_company_2_id,1325'edited_by': user_1_company_2_id,1326'expiration_date': datetime.now(),1327'users_ids': None,1328'description': 'description',1329'status': 'draft'1330},1331
1332])1333# ### end Alembic commands ###1334
1335
1336def downgrade():1337# ### commands auto generated by Alembic - please adjust! ###1338op.execute(f"TRUNCATE TABLE {Company.__table__}")1339op.execute(f"TRUNCATE TABLE {Store.__table__}")1340op.execute(f"TRUNCATE TABLE {Role.__table__}")1341op.execute(f"TRUNCATE TABLE {User.__table__}")1342op.execute(f"TRUNCATE TABLE {UomCategory.__table__}")1343op.execute(f"TRUNCATE TABLE {Uom.__table__}")1344op.execute(f"TRUNCATE TABLE {ProductCategory.__table__}")1345op.execute(f"TRUNCATE TABLE {ProductStorageType.__table__}")1346op.execute(f"TRUNCATE TABLE {Product.__table__}")1347op.execute(f"TRUNCATE TABLE {Lot.__table__}")1348op.execute(f"TRUNCATE TABLE {Quant.__table__}")1349op.execute(f"TRUNCATE TABLE {LocationType.__table__}")1350op.execute(f"TRUNCATE TABLE {Location.__table__}")1351op.execute(f"TRUNCATE TABLE {OrderType.__table__}")1352op.execute(f"TRUNCATE TABLE {Order.__table__}")1353
1354# ### commands auto generated by Alembic - please adjust! ###1355op.execute(f"TRUNCATE TABLE {Company.__table__}")1356op.execute(f"TRUNCATE TABLE {Store.__table__}")1357op.execute(f"TRUNCATE TABLE {Role.__table__}")1358op.execute(f"TRUNCATE TABLE {User.__table__}")1359op.execute(f"TRUNCATE TABLE {UomCategory.__table__}")1360op.execute(f"TRUNCATE TABLE {Uom.__table__}")1361op.execute(f"TRUNCATE TABLE {ProductCategory.__table__}")1362op.execute(f"TRUNCATE TABLE {ProductStorageType.__table__}")1363op.execute(f"TRUNCATE TABLE {Product.__table__}")1364op.execute(f"TRUNCATE TABLE {Lot.__table__}")1365op.execute(f"TRUNCATE TABLE {Quant.__table__}")1366op.execute(f"TRUNCATE TABLE {LocationType.__table__}")1367op.execute(f"TRUNCATE TABLE {Location.__table__}")1368op.execute(f"TRUNCATE TABLE {OrderType.__table__}")1369op.execute(f"TRUNCATE TABLE {Order.__table__}")1370