Commit 318f73a8 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: force default use/base_contribution on Software Product

Didn't find another way to do it (init script requires data migration)
parent ded6d79d
......@@ -58,3 +58,34 @@ class SoftwareProduct(ERP5SoftwareProduct):
variation_base_category_list = ('software_release', 'software_type', )
default_category_list = (
'base_contribution/base_amount/invoicing/discounted',
'base_contribution/base_amount/invoicing/taxable',
'use/trade/sale'
)
def __getattribute__(self, name):
result = super(SoftwareProduct, self).__getattribute__(name)
if name == 'categories':
# Force getting default_category_list
# if not category from this base_category is set
base_category_dict = {}
for category in SoftwareProduct.default_category_list:
base_category = category.split('/', 1)[0]
if base_category in base_category_dict:
base_category_dict[base_category].append(category)
else:
base_category_dict[base_category] = [category]
for category in result:
base_category_dict.pop(category.split('/', 1)[0], None)
if base_category_dict:
new_result = [x for x in result]
for v in base_category_dict.values():
new_result.extend(v)
return new_result
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment