#NEWLINE# def update_price_estimate_on_resource_spl_change( sender , instance , created = False , **kwargs ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# is_changed = ( ( not created ) and ( instance . service_project_link_id != instance . _old_values [ 'service_project_link' ] ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# is_changed = False #NEWLINE# #UNINDENT# if is_changed : #NEWLINE# #INDENT# spl_model = SupportedServices . get_related_models ( instance ) [ 'service_project_link' ] #NEWLINE# spl_old = spl_model . objects . get ( pk = instance . _old_values [ 'service_project_link' ] ) #NEWLINE# old_family_scope = ( [ spl_old ] + spl_old . get_ancestors ( ) ) #NEWLINE# for estimate in models . PriceEstimate . filter ( scope = instance , is_manually_input = False ) : #NEWLINE# #INDENT# qs = models . PriceEstimate . objects . filter ( scope__in = old_family_scope , month = estimate . month , year = estimate . year ) #NEWLINE# for parent_estimate in qs : #NEWLINE# #INDENT# parent_estimate . leaf_estimates . remove ( estimate ) #NEWLINE# parent_estimate . update_from_leaf ( ) #NEWLINE# #UNINDENT# #UNINDENT# models . PriceEstimate . update_ancestors_for_resource ( instance , force = True )