- Cleaned up admin.py by removing unnecessary dictionary wrapping for fields. - Adjusted migration files to maintain consistent formatting and removed redundant lines. - Updated models.py and tests to remove unnecessary blank lines and improve readability. - Enhanced error handling in the analytics API to properly forward upstream status and messages. - Added comprehensive tests for the analytics proxy to ensure correct status and body forwarding. - Updated contributing guidelines to clarify the use of ruff for code style enforcement.
924 lines
40 KiB
Python
924 lines
40 KiB
Python
# Generated by Django 5.2.9 on 2026-02-19 02:29
|
|
|
|
import uuid
|
|
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
initial = True
|
|
|
|
dependencies = [
|
|
("accounts", "0006_add_enterprise_constraints"),
|
|
("common", "0012_add_tag_color_description_isactive"),
|
|
("contacts", "0010_add_enterprise_constraints"),
|
|
("invoices", "0007_add_cancelled_at_field"),
|
|
("opportunity", "0009_salesgoal"),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="Order",
|
|
fields=[
|
|
(
|
|
"created_at",
|
|
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
|
|
),
|
|
(
|
|
"updated_at",
|
|
models.DateTimeField(
|
|
auto_now=True, verbose_name="Last Modified At"
|
|
),
|
|
),
|
|
(
|
|
"id",
|
|
models.UUIDField(
|
|
db_index=True,
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
unique=True,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=255, verbose_name="Order Name")),
|
|
(
|
|
"order_number",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=100,
|
|
null=True,
|
|
verbose_name="Order Number",
|
|
),
|
|
),
|
|
(
|
|
"status",
|
|
models.CharField(
|
|
choices=[
|
|
("DRAFT", "Draft"),
|
|
("ACTIVATED", "Activated"),
|
|
("COMPLETED", "Completed"),
|
|
("CANCELLED", "Cancelled"),
|
|
],
|
|
default="DRAFT",
|
|
max_length=20,
|
|
verbose_name="Status",
|
|
),
|
|
),
|
|
(
|
|
"currency",
|
|
models.CharField(
|
|
blank=True, max_length=3, null=True, verbose_name="Currency"
|
|
),
|
|
),
|
|
(
|
|
"subtotal",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Subtotal",
|
|
),
|
|
),
|
|
(
|
|
"discount_amount",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Discount Amount",
|
|
),
|
|
),
|
|
(
|
|
"tax_amount",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Tax Amount",
|
|
),
|
|
),
|
|
(
|
|
"total_amount",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Total Amount",
|
|
),
|
|
),
|
|
(
|
|
"order_date",
|
|
models.DateField(blank=True, null=True, verbose_name="Order Date"),
|
|
),
|
|
(
|
|
"activated_date",
|
|
models.DateField(
|
|
blank=True, null=True, verbose_name="Activated Date"
|
|
),
|
|
),
|
|
(
|
|
"shipped_date",
|
|
models.DateField(
|
|
blank=True, null=True, verbose_name="Shipped Date"
|
|
),
|
|
),
|
|
(
|
|
"billing_address_line",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=255,
|
|
null=True,
|
|
verbose_name="Billing Address",
|
|
),
|
|
),
|
|
(
|
|
"billing_city",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=100,
|
|
null=True,
|
|
verbose_name="Billing City",
|
|
),
|
|
),
|
|
(
|
|
"billing_state",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=100,
|
|
null=True,
|
|
verbose_name="Billing State",
|
|
),
|
|
),
|
|
(
|
|
"billing_postcode",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=20,
|
|
null=True,
|
|
verbose_name="Billing Postal Code",
|
|
),
|
|
),
|
|
(
|
|
"billing_country",
|
|
models.CharField(
|
|
blank=True,
|
|
choices=[
|
|
("GB", "United Kingdom"),
|
|
("AF", "Afghanistan"),
|
|
("AX", "Aland Islands"),
|
|
("AL", "Albania"),
|
|
("DZ", "Algeria"),
|
|
("AS", "American Samoa"),
|
|
("AD", "Andorra"),
|
|
("AO", "Angola"),
|
|
("AI", "Anguilla"),
|
|
("AQ", "Antarctica"),
|
|
("AG", "Antigua and Barbuda"),
|
|
("AR", "Argentina"),
|
|
("AM", "Armenia"),
|
|
("AW", "Aruba"),
|
|
("AU", "Australia"),
|
|
("AT", "Austria"),
|
|
("AZ", "Azerbaijan"),
|
|
("BS", "Bahamas"),
|
|
("BH", "Bahrain"),
|
|
("BD", "Bangladesh"),
|
|
("BB", "Barbados"),
|
|
("BY", "Belarus"),
|
|
("BE", "Belgium"),
|
|
("BZ", "Belize"),
|
|
("BJ", "Benin"),
|
|
("BM", "Bermuda"),
|
|
("BT", "Bhutan"),
|
|
("BO", "Bolivia"),
|
|
("BA", "Bosnia and Herzegovina"),
|
|
("BW", "Botswana"),
|
|
("BV", "Bouvet Island"),
|
|
("BR", "Brazil"),
|
|
("IO", "British Indian Ocean Territory"),
|
|
("BN", "Brunei Darussalam"),
|
|
("BG", "Bulgaria"),
|
|
("BF", "Burkina Faso"),
|
|
("BI", "Burundi"),
|
|
("KH", "Cambodia"),
|
|
("CM", "Cameroon"),
|
|
("CA", "Canada"),
|
|
("CV", "Cape Verde"),
|
|
("KY", "Cayman Islands"),
|
|
("CF", "Central African Republic"),
|
|
("TD", "Chad"),
|
|
("CL", "Chile"),
|
|
("CN", "China"),
|
|
("CX", "Christmas Island"),
|
|
("CC", "Cocos (Keeling) Islands"),
|
|
("CO", "Colombia"),
|
|
("KM", "Comoros"),
|
|
("CG", "Congo"),
|
|
("CD", "Congo, The Democratic Republic of the"),
|
|
("CK", "Cook Islands"),
|
|
("CR", "Costa Rica"),
|
|
("CI", "Cote d'Ivoire"),
|
|
("HR", "Croatia"),
|
|
("CU", "Cuba"),
|
|
("CY", "Cyprus"),
|
|
("CZ", "Czech Republic"),
|
|
("DK", "Denmark"),
|
|
("DJ", "Djibouti"),
|
|
("DM", "Dominica"),
|
|
("DO", "Dominican Republic"),
|
|
("EC", "Ecuador"),
|
|
("EG", "Egypt"),
|
|
("SV", "El Salvador"),
|
|
("GQ", "Equatorial Guinea"),
|
|
("ER", "Eritrea"),
|
|
("EE", "Estonia"),
|
|
("ET", "Ethiopia"),
|
|
("FK", "Falkland Islands (Malvinas)"),
|
|
("FO", "Faroe Islands"),
|
|
("FJ", "Fiji"),
|
|
("FI", "Finland"),
|
|
("FR", "France"),
|
|
("GF", "French Guiana"),
|
|
("PF", "French Polynesia"),
|
|
("TF", "French Southern Territories"),
|
|
("GA", "Gabon"),
|
|
("GM", "Gambia"),
|
|
("GE", "Georgia"),
|
|
("DE", "Germany"),
|
|
("GH", "Ghana"),
|
|
("GI", "Gibraltar"),
|
|
("GR", "Greece"),
|
|
("GL", "Greenland"),
|
|
("GD", "Grenada"),
|
|
("GP", "Guadeloupe"),
|
|
("GU", "Guam"),
|
|
("GT", "Guatemala"),
|
|
("GG", "Guernsey"),
|
|
("GN", "Guinea"),
|
|
("GW", "Guinea-Bissau"),
|
|
("GY", "Guyana"),
|
|
("HT", "Haiti"),
|
|
("HM", "Heard Island and McDonald Islands"),
|
|
("VA", "Holy See (Vatican City State)"),
|
|
("HN", "Honduras"),
|
|
("HK", "Hong Kong"),
|
|
("HU", "Hungary"),
|
|
("IS", "Iceland"),
|
|
("IN", "India"),
|
|
("ID", "Indonesia"),
|
|
("IR", "Iran, Islamic Republic of"),
|
|
("IQ", "Iraq"),
|
|
("IE", "Ireland"),
|
|
("IM", "Isle of Man"),
|
|
("IL", "Israel"),
|
|
("IT", "Italy"),
|
|
("JM", "Jamaica"),
|
|
("JP", "Japan"),
|
|
("JE", "Jersey"),
|
|
("JO", "Jordan"),
|
|
("KZ", "Kazakhstan"),
|
|
("KE", "Kenya"),
|
|
("KI", "Kiribati"),
|
|
("KP", "Korea, Democratic People's Republic of"),
|
|
("KR", "Korea, Republic of"),
|
|
("KW", "Kuwait"),
|
|
("KG", "Kyrgyzstan"),
|
|
("LA", "Lao People's Democratic Republic"),
|
|
("LV", "Latvia"),
|
|
("LB", "Lebanon"),
|
|
("LS", "Lesotho"),
|
|
("LR", "Liberia"),
|
|
("LY", "Libyan Arab Jamahiriya"),
|
|
("LI", "Liechtenstein"),
|
|
("LT", "Lithuania"),
|
|
("LU", "Luxembourg"),
|
|
("MO", "Macao"),
|
|
("MK", "Macedonia, The Former Yugoslav Republic of"),
|
|
("MG", "Madagascar"),
|
|
("MW", "Malawi"),
|
|
("MY", "Malaysia"),
|
|
("MV", "Maldives"),
|
|
("ML", "Mali"),
|
|
("MT", "Malta"),
|
|
("MH", "Marshall Islands"),
|
|
("MQ", "Martinique"),
|
|
("MR", "Mauritania"),
|
|
("MU", "Mauritius"),
|
|
("YT", "Mayotte"),
|
|
("MX", "Mexico"),
|
|
("FM", "Micronesia, Federated States of"),
|
|
("MD", "Moldova"),
|
|
("MC", "Monaco"),
|
|
("MN", "Mongolia"),
|
|
("ME", "Montenegro"),
|
|
("MS", "Montserrat"),
|
|
("MA", "Morocco"),
|
|
("MZ", "Mozambique"),
|
|
("MM", "Myanmar"),
|
|
("NA", "Namibia"),
|
|
("NR", "Nauru"),
|
|
("NP", "Nepal"),
|
|
("NL", "Netherlands"),
|
|
("AN", "Netherlands Antilles"),
|
|
("NC", "New Caledonia"),
|
|
("NZ", "New Zealand"),
|
|
("NI", "Nicaragua"),
|
|
("NE", "Niger"),
|
|
("NG", "Nigeria"),
|
|
("NU", "Niue"),
|
|
("NF", "Norfolk Island"),
|
|
("MP", "Northern Mariana Islands"),
|
|
("NO", "Norway"),
|
|
("OM", "Oman"),
|
|
("PK", "Pakistan"),
|
|
("PW", "Palau"),
|
|
("PS", "Palestinian Territory, Occupied"),
|
|
("PA", "Panama"),
|
|
("PG", "Papua New Guinea"),
|
|
("PY", "Paraguay"),
|
|
("PE", "Peru"),
|
|
("PH", "Philippines"),
|
|
("PN", "Pitcairn"),
|
|
("PL", "Poland"),
|
|
("PT", "Portugal"),
|
|
("PR", "Puerto Rico"),
|
|
("QA", "Qatar"),
|
|
("RE", "Reunion"),
|
|
("RO", "Romania"),
|
|
("RU", "Russian Federation"),
|
|
("RW", "Rwanda"),
|
|
("BL", "Saint Barthelemy"),
|
|
("SH", "Saint Helena"),
|
|
("KN", "Saint Kitts and Nevis"),
|
|
("LC", "Saint Lucia"),
|
|
("MF", "Saint Martin"),
|
|
("PM", "Saint Pierre and Miquelon"),
|
|
("VC", "Saint Vincent and the Grenadines"),
|
|
("WS", "Samoa"),
|
|
("SM", "San Marino"),
|
|
("ST", "Sao Tome and Principe"),
|
|
("SA", "Saudi Arabia"),
|
|
("SN", "Senegal"),
|
|
("RS", "Serbia"),
|
|
("SC", "Seychelles"),
|
|
("SL", "Sierra Leone"),
|
|
("SG", "Singapore"),
|
|
("SK", "Slovakia"),
|
|
("SI", "Slovenia"),
|
|
("SB", "Solomon Islands"),
|
|
("SO", "Somalia"),
|
|
("ZA", "South Africa"),
|
|
("GS", "South Georgia and the South Sandwich Islands"),
|
|
("ES", "Spain"),
|
|
("LK", "Sri Lanka"),
|
|
("SD", "Sudan"),
|
|
("SR", "Suriname"),
|
|
("SJ", "Svalbard and Jan Mayen"),
|
|
("SZ", "Swaziland"),
|
|
("SE", "Sweden"),
|
|
("CH", "Switzerland"),
|
|
("SY", "Syrian Arab Republic"),
|
|
("TW", "Taiwan, Province of China"),
|
|
("TJ", "Tajikistan"),
|
|
("TZ", "Tanzania, United Republic of"),
|
|
("TH", "Thailand"),
|
|
("TL", "Timor-Leste"),
|
|
("TG", "Togo"),
|
|
("TK", "Tokelau"),
|
|
("TO", "Tonga"),
|
|
("TT", "Trinidad and Tobago"),
|
|
("TN", "Tunisia"),
|
|
("TR", "Turkey"),
|
|
("TM", "Turkmenistan"),
|
|
("TC", "Turks and Caicos Islands"),
|
|
("TV", "Tuvalu"),
|
|
("UG", "Uganda"),
|
|
("UA", "Ukraine"),
|
|
("AE", "United Arab Emirates"),
|
|
("US", "United States"),
|
|
("UM", "United States Minor Outlying Islands"),
|
|
("UY", "Uruguay"),
|
|
("UZ", "Uzbekistan"),
|
|
("VU", "Vanuatu"),
|
|
("VE", "Venezuela"),
|
|
("VN", "Viet Nam"),
|
|
("VG", "Virgin Islands, British"),
|
|
("VI", "Virgin Islands, U.S."),
|
|
("WF", "Wallis and Futuna"),
|
|
("EH", "Western Sahara"),
|
|
("YE", "Yemen"),
|
|
("ZM", "Zambia"),
|
|
("ZW", "Zimbabwe"),
|
|
],
|
|
max_length=3,
|
|
null=True,
|
|
verbose_name="Billing Country",
|
|
),
|
|
),
|
|
(
|
|
"shipping_address_line",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=255,
|
|
null=True,
|
|
verbose_name="Shipping Address",
|
|
),
|
|
),
|
|
(
|
|
"shipping_city",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=100,
|
|
null=True,
|
|
verbose_name="Shipping City",
|
|
),
|
|
),
|
|
(
|
|
"shipping_state",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=100,
|
|
null=True,
|
|
verbose_name="Shipping State",
|
|
),
|
|
),
|
|
(
|
|
"shipping_postcode",
|
|
models.CharField(
|
|
blank=True,
|
|
max_length=20,
|
|
null=True,
|
|
verbose_name="Shipping Postal Code",
|
|
),
|
|
),
|
|
(
|
|
"shipping_country",
|
|
models.CharField(
|
|
blank=True,
|
|
choices=[
|
|
("GB", "United Kingdom"),
|
|
("AF", "Afghanistan"),
|
|
("AX", "Aland Islands"),
|
|
("AL", "Albania"),
|
|
("DZ", "Algeria"),
|
|
("AS", "American Samoa"),
|
|
("AD", "Andorra"),
|
|
("AO", "Angola"),
|
|
("AI", "Anguilla"),
|
|
("AQ", "Antarctica"),
|
|
("AG", "Antigua and Barbuda"),
|
|
("AR", "Argentina"),
|
|
("AM", "Armenia"),
|
|
("AW", "Aruba"),
|
|
("AU", "Australia"),
|
|
("AT", "Austria"),
|
|
("AZ", "Azerbaijan"),
|
|
("BS", "Bahamas"),
|
|
("BH", "Bahrain"),
|
|
("BD", "Bangladesh"),
|
|
("BB", "Barbados"),
|
|
("BY", "Belarus"),
|
|
("BE", "Belgium"),
|
|
("BZ", "Belize"),
|
|
("BJ", "Benin"),
|
|
("BM", "Bermuda"),
|
|
("BT", "Bhutan"),
|
|
("BO", "Bolivia"),
|
|
("BA", "Bosnia and Herzegovina"),
|
|
("BW", "Botswana"),
|
|
("BV", "Bouvet Island"),
|
|
("BR", "Brazil"),
|
|
("IO", "British Indian Ocean Territory"),
|
|
("BN", "Brunei Darussalam"),
|
|
("BG", "Bulgaria"),
|
|
("BF", "Burkina Faso"),
|
|
("BI", "Burundi"),
|
|
("KH", "Cambodia"),
|
|
("CM", "Cameroon"),
|
|
("CA", "Canada"),
|
|
("CV", "Cape Verde"),
|
|
("KY", "Cayman Islands"),
|
|
("CF", "Central African Republic"),
|
|
("TD", "Chad"),
|
|
("CL", "Chile"),
|
|
("CN", "China"),
|
|
("CX", "Christmas Island"),
|
|
("CC", "Cocos (Keeling) Islands"),
|
|
("CO", "Colombia"),
|
|
("KM", "Comoros"),
|
|
("CG", "Congo"),
|
|
("CD", "Congo, The Democratic Republic of the"),
|
|
("CK", "Cook Islands"),
|
|
("CR", "Costa Rica"),
|
|
("CI", "Cote d'Ivoire"),
|
|
("HR", "Croatia"),
|
|
("CU", "Cuba"),
|
|
("CY", "Cyprus"),
|
|
("CZ", "Czech Republic"),
|
|
("DK", "Denmark"),
|
|
("DJ", "Djibouti"),
|
|
("DM", "Dominica"),
|
|
("DO", "Dominican Republic"),
|
|
("EC", "Ecuador"),
|
|
("EG", "Egypt"),
|
|
("SV", "El Salvador"),
|
|
("GQ", "Equatorial Guinea"),
|
|
("ER", "Eritrea"),
|
|
("EE", "Estonia"),
|
|
("ET", "Ethiopia"),
|
|
("FK", "Falkland Islands (Malvinas)"),
|
|
("FO", "Faroe Islands"),
|
|
("FJ", "Fiji"),
|
|
("FI", "Finland"),
|
|
("FR", "France"),
|
|
("GF", "French Guiana"),
|
|
("PF", "French Polynesia"),
|
|
("TF", "French Southern Territories"),
|
|
("GA", "Gabon"),
|
|
("GM", "Gambia"),
|
|
("GE", "Georgia"),
|
|
("DE", "Germany"),
|
|
("GH", "Ghana"),
|
|
("GI", "Gibraltar"),
|
|
("GR", "Greece"),
|
|
("GL", "Greenland"),
|
|
("GD", "Grenada"),
|
|
("GP", "Guadeloupe"),
|
|
("GU", "Guam"),
|
|
("GT", "Guatemala"),
|
|
("GG", "Guernsey"),
|
|
("GN", "Guinea"),
|
|
("GW", "Guinea-Bissau"),
|
|
("GY", "Guyana"),
|
|
("HT", "Haiti"),
|
|
("HM", "Heard Island and McDonald Islands"),
|
|
("VA", "Holy See (Vatican City State)"),
|
|
("HN", "Honduras"),
|
|
("HK", "Hong Kong"),
|
|
("HU", "Hungary"),
|
|
("IS", "Iceland"),
|
|
("IN", "India"),
|
|
("ID", "Indonesia"),
|
|
("IR", "Iran, Islamic Republic of"),
|
|
("IQ", "Iraq"),
|
|
("IE", "Ireland"),
|
|
("IM", "Isle of Man"),
|
|
("IL", "Israel"),
|
|
("IT", "Italy"),
|
|
("JM", "Jamaica"),
|
|
("JP", "Japan"),
|
|
("JE", "Jersey"),
|
|
("JO", "Jordan"),
|
|
("KZ", "Kazakhstan"),
|
|
("KE", "Kenya"),
|
|
("KI", "Kiribati"),
|
|
("KP", "Korea, Democratic People's Republic of"),
|
|
("KR", "Korea, Republic of"),
|
|
("KW", "Kuwait"),
|
|
("KG", "Kyrgyzstan"),
|
|
("LA", "Lao People's Democratic Republic"),
|
|
("LV", "Latvia"),
|
|
("LB", "Lebanon"),
|
|
("LS", "Lesotho"),
|
|
("LR", "Liberia"),
|
|
("LY", "Libyan Arab Jamahiriya"),
|
|
("LI", "Liechtenstein"),
|
|
("LT", "Lithuania"),
|
|
("LU", "Luxembourg"),
|
|
("MO", "Macao"),
|
|
("MK", "Macedonia, The Former Yugoslav Republic of"),
|
|
("MG", "Madagascar"),
|
|
("MW", "Malawi"),
|
|
("MY", "Malaysia"),
|
|
("MV", "Maldives"),
|
|
("ML", "Mali"),
|
|
("MT", "Malta"),
|
|
("MH", "Marshall Islands"),
|
|
("MQ", "Martinique"),
|
|
("MR", "Mauritania"),
|
|
("MU", "Mauritius"),
|
|
("YT", "Mayotte"),
|
|
("MX", "Mexico"),
|
|
("FM", "Micronesia, Federated States of"),
|
|
("MD", "Moldova"),
|
|
("MC", "Monaco"),
|
|
("MN", "Mongolia"),
|
|
("ME", "Montenegro"),
|
|
("MS", "Montserrat"),
|
|
("MA", "Morocco"),
|
|
("MZ", "Mozambique"),
|
|
("MM", "Myanmar"),
|
|
("NA", "Namibia"),
|
|
("NR", "Nauru"),
|
|
("NP", "Nepal"),
|
|
("NL", "Netherlands"),
|
|
("AN", "Netherlands Antilles"),
|
|
("NC", "New Caledonia"),
|
|
("NZ", "New Zealand"),
|
|
("NI", "Nicaragua"),
|
|
("NE", "Niger"),
|
|
("NG", "Nigeria"),
|
|
("NU", "Niue"),
|
|
("NF", "Norfolk Island"),
|
|
("MP", "Northern Mariana Islands"),
|
|
("NO", "Norway"),
|
|
("OM", "Oman"),
|
|
("PK", "Pakistan"),
|
|
("PW", "Palau"),
|
|
("PS", "Palestinian Territory, Occupied"),
|
|
("PA", "Panama"),
|
|
("PG", "Papua New Guinea"),
|
|
("PY", "Paraguay"),
|
|
("PE", "Peru"),
|
|
("PH", "Philippines"),
|
|
("PN", "Pitcairn"),
|
|
("PL", "Poland"),
|
|
("PT", "Portugal"),
|
|
("PR", "Puerto Rico"),
|
|
("QA", "Qatar"),
|
|
("RE", "Reunion"),
|
|
("RO", "Romania"),
|
|
("RU", "Russian Federation"),
|
|
("RW", "Rwanda"),
|
|
("BL", "Saint Barthelemy"),
|
|
("SH", "Saint Helena"),
|
|
("KN", "Saint Kitts and Nevis"),
|
|
("LC", "Saint Lucia"),
|
|
("MF", "Saint Martin"),
|
|
("PM", "Saint Pierre and Miquelon"),
|
|
("VC", "Saint Vincent and the Grenadines"),
|
|
("WS", "Samoa"),
|
|
("SM", "San Marino"),
|
|
("ST", "Sao Tome and Principe"),
|
|
("SA", "Saudi Arabia"),
|
|
("SN", "Senegal"),
|
|
("RS", "Serbia"),
|
|
("SC", "Seychelles"),
|
|
("SL", "Sierra Leone"),
|
|
("SG", "Singapore"),
|
|
("SK", "Slovakia"),
|
|
("SI", "Slovenia"),
|
|
("SB", "Solomon Islands"),
|
|
("SO", "Somalia"),
|
|
("ZA", "South Africa"),
|
|
("GS", "South Georgia and the South Sandwich Islands"),
|
|
("ES", "Spain"),
|
|
("LK", "Sri Lanka"),
|
|
("SD", "Sudan"),
|
|
("SR", "Suriname"),
|
|
("SJ", "Svalbard and Jan Mayen"),
|
|
("SZ", "Swaziland"),
|
|
("SE", "Sweden"),
|
|
("CH", "Switzerland"),
|
|
("SY", "Syrian Arab Republic"),
|
|
("TW", "Taiwan, Province of China"),
|
|
("TJ", "Tajikistan"),
|
|
("TZ", "Tanzania, United Republic of"),
|
|
("TH", "Thailand"),
|
|
("TL", "Timor-Leste"),
|
|
("TG", "Togo"),
|
|
("TK", "Tokelau"),
|
|
("TO", "Tonga"),
|
|
("TT", "Trinidad and Tobago"),
|
|
("TN", "Tunisia"),
|
|
("TR", "Turkey"),
|
|
("TM", "Turkmenistan"),
|
|
("TC", "Turks and Caicos Islands"),
|
|
("TV", "Tuvalu"),
|
|
("UG", "Uganda"),
|
|
("UA", "Ukraine"),
|
|
("AE", "United Arab Emirates"),
|
|
("US", "United States"),
|
|
("UM", "United States Minor Outlying Islands"),
|
|
("UY", "Uruguay"),
|
|
("UZ", "Uzbekistan"),
|
|
("VU", "Vanuatu"),
|
|
("VE", "Venezuela"),
|
|
("VN", "Viet Nam"),
|
|
("VG", "Virgin Islands, British"),
|
|
("VI", "Virgin Islands, U.S."),
|
|
("WF", "Wallis and Futuna"),
|
|
("EH", "Western Sahara"),
|
|
("YE", "Yemen"),
|
|
("ZM", "Zambia"),
|
|
("ZW", "Zimbabwe"),
|
|
],
|
|
max_length=3,
|
|
null=True,
|
|
verbose_name="Shipping Country",
|
|
),
|
|
),
|
|
(
|
|
"description",
|
|
models.TextField(blank=True, null=True, verbose_name="Description"),
|
|
),
|
|
(
|
|
"account",
|
|
models.ForeignKey(
|
|
help_text="The account this order belongs to",
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="orders",
|
|
to="accounts.account",
|
|
),
|
|
),
|
|
(
|
|
"contact",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
help_text="The contact associated with this order",
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="orders",
|
|
to="contacts.contact",
|
|
),
|
|
),
|
|
(
|
|
"created_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="%(class)s_created_by",
|
|
to=settings.AUTH_USER_MODEL,
|
|
verbose_name="Created By",
|
|
),
|
|
),
|
|
(
|
|
"opportunity",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
help_text="The opportunity this order originated from",
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="orders",
|
|
to="opportunity.opportunity",
|
|
),
|
|
),
|
|
(
|
|
"org",
|
|
models.ForeignKey(
|
|
help_text="Organization this record belongs to",
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="%(class)s_set",
|
|
to="common.org",
|
|
),
|
|
),
|
|
(
|
|
"updated_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="%(class)s_updated_by",
|
|
to=settings.AUTH_USER_MODEL,
|
|
verbose_name="Last Modified By",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "Order",
|
|
"verbose_name_plural": "Orders",
|
|
"db_table": "orders",
|
|
"ordering": ("-created_at",),
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="OrderLineItem",
|
|
fields=[
|
|
(
|
|
"created_at",
|
|
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
|
|
),
|
|
(
|
|
"updated_at",
|
|
models.DateTimeField(
|
|
auto_now=True, verbose_name="Last Modified At"
|
|
),
|
|
),
|
|
(
|
|
"id",
|
|
models.UUIDField(
|
|
db_index=True,
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
unique=True,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=255, verbose_name="Item Name")),
|
|
(
|
|
"description",
|
|
models.TextField(blank=True, null=True, verbose_name="Description"),
|
|
),
|
|
(
|
|
"quantity",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=1,
|
|
max_digits=10,
|
|
verbose_name="Quantity",
|
|
),
|
|
),
|
|
(
|
|
"unit_price",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Unit Price",
|
|
),
|
|
),
|
|
(
|
|
"discount_amount",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
default=0,
|
|
max_digits=15,
|
|
verbose_name="Discount Amount",
|
|
),
|
|
),
|
|
(
|
|
"total",
|
|
models.DecimalField(
|
|
decimal_places=2, default=0, max_digits=15, verbose_name="Total"
|
|
),
|
|
),
|
|
(
|
|
"sort_order",
|
|
models.IntegerField(default=0, verbose_name="Sort Order"),
|
|
),
|
|
(
|
|
"created_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="%(class)s_created_by",
|
|
to=settings.AUTH_USER_MODEL,
|
|
verbose_name="Created By",
|
|
),
|
|
),
|
|
(
|
|
"order",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="line_items",
|
|
to="orders.order",
|
|
),
|
|
),
|
|
(
|
|
"org",
|
|
models.ForeignKey(
|
|
help_text="Organization this record belongs to",
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="%(class)s_set",
|
|
to="common.org",
|
|
),
|
|
),
|
|
(
|
|
"product",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="order_line_items",
|
|
to="invoices.product",
|
|
),
|
|
),
|
|
(
|
|
"updated_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="%(class)s_updated_by",
|
|
to=settings.AUTH_USER_MODEL,
|
|
verbose_name="Last Modified By",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "Order Line Item",
|
|
"verbose_name_plural": "Order Line Items",
|
|
"db_table": "order_line_item",
|
|
"ordering": ("sort_order",),
|
|
},
|
|
),
|
|
migrations.AddIndex(
|
|
model_name="order",
|
|
index=models.Index(
|
|
fields=["org", "-created_at"], name="orders_org_id_9026a7_idx"
|
|
),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name="orderlineitem",
|
|
index=models.Index(
|
|
fields=["org", "-created_at"], name="order_line__org_id_444fcc_idx"
|
|
),
|
|
),
|
|
]
|