Improve form support for view supplements
this seems a bit hacky yet but works for now.. cf. field logic for Vendor -> Quickbooks Bank Accounts, which requires this
This commit is contained in:
parent
c35c0f8b61
commit
0d9c5a078b
3 changed files with 55 additions and 7 deletions
|
@ -2695,8 +2695,15 @@ class MasterView(View):
|
|||
|
||||
context.update(data)
|
||||
context.update(self.template_kwargs(**context))
|
||||
if hasattr(self, 'template_kwargs_{}'.format(template)):
|
||||
context.update(getattr(self, 'template_kwargs_{}'.format(template))(**context))
|
||||
|
||||
method_name = f'template_kwargs_{template}'
|
||||
if hasattr(self, method_name):
|
||||
context.update(getattr(self, method_name)(**context))
|
||||
for supp in self.iter_view_supplements():
|
||||
if hasattr(supp, 'template_kwargs'):
|
||||
context.update(getattr(supp, 'template_kwargs')(**context))
|
||||
if hasattr(supp, method_name):
|
||||
context.update(getattr(supp, method_name)(**context))
|
||||
|
||||
# First try the template path most specific to the view.
|
||||
mako_path = '{}/{}.mako'.format(self.get_template_prefix(), template)
|
||||
|
@ -4441,6 +4448,9 @@ class MasterView(View):
|
|||
if not self.has_perm('view_global'):
|
||||
obj.local_only = True
|
||||
|
||||
for supp in self.iter_view_supplements():
|
||||
obj = supp.objectify(obj, form, data)
|
||||
|
||||
return obj
|
||||
|
||||
def objectify_contact(self, contact, data):
|
||||
|
@ -5892,6 +5902,9 @@ class ViewSupplement(object):
|
|||
renderers, default values etc. for them.
|
||||
"""
|
||||
|
||||
def objectify(self, obj, form, data):
|
||||
return obj
|
||||
|
||||
def get_xref_buttons(self, obj):
|
||||
return []
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue