mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
fix trailing
This commit is contained in:
@ -65,7 +65,7 @@ def reverse_association(apps, schema_editor): # pragma: no cover
|
||||
|
||||
# Now extract the "name" for the manufacturer
|
||||
response = cursor.execute(f"SELECT name from company_company where id={manufacturer_id};")
|
||||
|
||||
|
||||
row = cursor.fetchone()
|
||||
|
||||
name = row[0]
|
||||
@ -77,7 +77,7 @@ def reverse_association(apps, schema_editor): # pragma: no cover
|
||||
def associate_manufacturers(apps, schema_editor):
|
||||
"""
|
||||
This migration is the "middle step" in migration of the "manufacturer" field for the SupplierPart model.
|
||||
|
||||
|
||||
Previously the "manufacturer" field was a simple text field with the manufacturer name.
|
||||
This is quite insufficient.
|
||||
The new "manufacturer" field is a link to Company object which has the "is_manufacturer" parameter set to True
|
||||
@ -87,7 +87,7 @@ def associate_manufacturers(apps, schema_editor):
|
||||
|
||||
It uses fuzzy pattern matching to help the user out as much as possible.
|
||||
"""
|
||||
|
||||
|
||||
def get_manufacturer_name(part_id):
|
||||
"""
|
||||
THIS IS CRITICAL!
|
||||
@ -149,7 +149,7 @@ def associate_manufacturers(apps, schema_editor):
|
||||
|
||||
return True
|
||||
|
||||
# Have we already mapped this
|
||||
# Have we already mapped this
|
||||
if name in links.keys(): # pragma: no cover
|
||||
print(" - Part[{pk}]: Mapped '{n}' - manufacturer <{c}>".format(pk=part_id, n=name, c=links[name]))
|
||||
|
||||
@ -178,7 +178,7 @@ def associate_manufacturers(apps, schema_editor):
|
||||
links[company_name] = manufacturer.pk
|
||||
|
||||
companies[company_name] = manufacturer.pk
|
||||
|
||||
|
||||
print(" - Part[{pk}]: Created new manufacturer: '{name}'".format(pk=part_id, name=company_name))
|
||||
|
||||
# Update SupplierPart object in the database
|
||||
@ -228,9 +228,9 @@ def associate_manufacturers(apps, schema_editor):
|
||||
# Present a list of options
|
||||
if not TESTING: # pragma: no cover
|
||||
print("----------------------------------")
|
||||
|
||||
|
||||
print("Checking part [{pk}] ({idx} of {total})".format(pk=part_id, idx=idx+1, total=total))
|
||||
|
||||
|
||||
if not TESTING: # pragma: no cover
|
||||
print("Manufacturer name: '{n}'".format(n=name))
|
||||
print("----------------------------------")
|
||||
@ -293,7 +293,7 @@ def associate_manufacturers(apps, schema_editor):
|
||||
if not response or len(response) == 0:
|
||||
# Response cannot be empty!
|
||||
print("Please select an option")
|
||||
|
||||
|
||||
# Double-check if the typed name corresponds to an existing item
|
||||
elif response in companies.keys():
|
||||
link_part(part, companies[response])
|
||||
@ -334,7 +334,7 @@ def associate_manufacturers(apps, schema_editor):
|
||||
results = cursor.fetchall()
|
||||
|
||||
part_count = len(results)
|
||||
|
||||
|
||||
# Create a unique set of manufacturer names
|
||||
for index, row in enumerate(results):
|
||||
pk, MPN, SKU, manufacturer_id, manufacturer_name = row
|
||||
|
@ -32,7 +32,7 @@ def migrate_currencies(apps, schema_editor):
|
||||
|
||||
# The 'suffix' field denotes the currency code
|
||||
response = cursor.execute('SELECT id, suffix, description from common_currency;')
|
||||
|
||||
|
||||
results = cursor.fetchall()
|
||||
|
||||
remap = {}
|
||||
@ -56,7 +56,7 @@ def migrate_currencies(apps, schema_editor):
|
||||
|
||||
# Now iterate through each SupplierPriceBreak and update the rows
|
||||
response = cursor.execute('SELECT id, cost, currency_id, price, price_currency from part_supplierpricebreak;')
|
||||
|
||||
|
||||
results = cursor.fetchall()
|
||||
|
||||
count = 0
|
||||
@ -92,7 +92,7 @@ def reverse_currencies(apps, schema_editor): # pragma: no cover
|
||||
|
||||
# Extract a list of currency codes which are in use
|
||||
response = cursor.execute(f'SELECT id, price, price_currency from part_supplierpricebreak;')
|
||||
|
||||
|
||||
results = cursor.fetchall()
|
||||
|
||||
codes_in_use = set()
|
||||
@ -123,7 +123,7 @@ def reverse_currencies(apps, schema_editor): # pragma: no cover
|
||||
|
||||
# Create a new object in the database
|
||||
print(f"Creating new Currency object for {code}")
|
||||
|
||||
|
||||
# Construct a query to create a new Currency object
|
||||
query = f'INSERT into common_currency (symbol, suffix, description, value, base) VALUES ("$", "{code}", "{description}", 1.0, False);'
|
||||
|
||||
|
@ -9,7 +9,7 @@ def supplierpart_make_manufacturer_parts(apps, schema_editor):
|
||||
SupplierPart = apps.get_model('company', 'SupplierPart')
|
||||
|
||||
supplier_parts = SupplierPart.objects.all()
|
||||
|
||||
|
||||
if supplier_parts:
|
||||
print(f'\nCreating ManufacturerPart Objects\n{"-"*10}')
|
||||
for supplier_part in supplier_parts:
|
||||
@ -23,7 +23,7 @@ def supplierpart_make_manufacturer_parts(apps, schema_editor):
|
||||
if not part: # pragma: no cover
|
||||
print(f'[ERROR: SUPPLIER PART IS NOT CONNECTED TO PART]')
|
||||
continue
|
||||
|
||||
|
||||
manufacturer = supplier_part.manufacturer
|
||||
MPN = supplier_part.MPN
|
||||
link = supplier_part.link
|
||||
@ -31,7 +31,7 @@ def supplierpart_make_manufacturer_parts(apps, schema_editor):
|
||||
|
||||
if manufacturer or MPN:
|
||||
print(f' | {part.name[:15].ljust(15)}', end='')
|
||||
|
||||
|
||||
try:
|
||||
print(f' | {manufacturer.name[:15].ljust(15)}', end='')
|
||||
except AttributeError:
|
||||
@ -73,12 +73,12 @@ def supplierpart_populate_manufacturer_info(apps, schema_editor): # pragma: no
|
||||
SupplierPart = apps.get_model('company', 'SupplierPart')
|
||||
|
||||
supplier_parts = SupplierPart.objects.all()
|
||||
|
||||
|
||||
if supplier_parts:
|
||||
print(f'\nSupplierPart: Populating Manufacturer Information\n{"-"*10}')
|
||||
for supplier_part in supplier_parts:
|
||||
print(f'{supplier_part.supplier.name[:15].ljust(15)} | {supplier_part.SKU[:15].ljust(15)}\t', end='')
|
||||
|
||||
|
||||
manufacturer_part = supplier_part.manufacturer_part
|
||||
|
||||
if manufacturer_part:
|
||||
@ -89,13 +89,13 @@ def supplierpart_populate_manufacturer_info(apps, schema_editor): # pragma: no
|
||||
supplier_part.MPN = manufacturer_part.MPN
|
||||
|
||||
supplier_part.save()
|
||||
|
||||
|
||||
print(f'[SUCCESS: UPDATED MANUFACTURER INFO]')
|
||||
else:
|
||||
print(f'[IGNORED: NO MANUFACTURER PART]')
|
||||
|
||||
print(f'{"-"*10}\nDone\n')
|
||||
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
Reference in New Issue
Block a user