This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add coupon sf opp line item attribute
- Loading branch information
1 parent
2f1437e
commit fd5f0c2
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
ecommerce/extensions/catalogue/migrations/0055_sf_opp_line_item_ent_attr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from django.db import migrations | ||
from oscar.core.loading import get_model | ||
|
||
from ecommerce.core.constants import COUPON_PRODUCT_CLASS_NAME | ||
|
||
ProductAttribute = get_model("catalogue", "ProductAttribute") | ||
ProductClass = get_model("catalogue", "ProductClass") | ||
|
||
SF_LINE_ITEM_ATTRIBUTE_CODE = 'salesforce_opportunity_line_item' | ||
|
||
|
||
def create_sf_opp_line_item_attribute(apps, schema_editor): | ||
"""Create enterprise coupon salesforce_opportunity_line_item product attribute.""" | ||
ProductAttribute.skip_history_when_saving = True | ||
coupon = ProductClass.objects.get(name=COUPON_PRODUCT_CLASS_NAME) | ||
pa = ProductAttribute( | ||
product_class=coupon, | ||
name='Salesforce Opportunity Line Item', | ||
code=SF_LINE_ITEM_ATTRIBUTE_CODE, | ||
type='text', | ||
required=True, | ||
) | ||
pa.save() | ||
|
||
|
||
def remove_sf_opp_line_item_attribute(apps, schema_editor): | ||
"""Remove enterprise coupon salesforce_opportunity_line_item product attribute.""" | ||
coupon = ProductClass.objects.get(name=COUPON_PRODUCT_CLASS_NAME) | ||
ProductAttribute.skip_history_when_saving = True | ||
ProductAttribute.objects.get(product_class=coupon, code=SF_LINE_ITEM_ATTRIBUTE_CODE).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalogue', '0054_add_variant_id_product_attr') | ||
] | ||
operations = [ | ||
migrations.RunPython( | ||
create_sf_opp_line_item_attribute, | ||
remove_sf_opp_line_item_attribute, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters