Delete product costs for vendor when deleting vendor.
This commit is contained in:
parent
b119ccff7d
commit
be2a1ba862
9
tailbone/views/vendors/core.py
vendored
9
tailbone/views/vendors/core.py
vendored
|
@ -29,6 +29,7 @@ from __future__ import unicode_literals
|
|||
from rattail.db import model
|
||||
from rattail.db.model import Vendor
|
||||
|
||||
from tailbone.db import Session
|
||||
from tailbone.views import SearchableAlchemyGridView, CrudView, AutocompleteView
|
||||
from tailbone.views.continuum import VersionView, version_defaults
|
||||
from tailbone.forms import AssociationProxyField, PersonFieldRenderer
|
||||
|
@ -97,6 +98,14 @@ class VendorCrud(CrudView):
|
|||
])
|
||||
return fs
|
||||
|
||||
def pre_delete(self, vendor):
|
||||
|
||||
# Remove all product costs.
|
||||
q = Session.query(model.ProductCost).filter(
|
||||
model.ProductCost.vendor == vendor)
|
||||
for cost in q:
|
||||
Session.delete(cost)
|
||||
|
||||
|
||||
class VendorVersionView(VersionView):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue