Changeset 69585ad in tailbone-corepos


Ignore:
Timestamp:
08/02/2020 09:28:53 PM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
fdb63fc
Parents:
acf6764
Message:

Fix handling of corepos_account_id field when editing customers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone_corepos/views/customers.py

    racf6764 r69585ad  
    5454        g.set_filter('corepos_account_id', model.CoreCustomer.corepos_account_id)
    5555
     56    def configure_form(self, f):
     57        super(CustomerView, self).configure_form(f)
     58        f.set_required('corepos_account_id', False)
     59
     60    def objectify(self, form, data=None):
     61        if data is None:
     62            data = form.validated
     63        customer = form.model_instance
     64
     65        # this field lives in an extension table, but the column does not allow
     66        # null, which means we don't want to pass an empty value along unless
     67        # there is already an extension record in place for this customer
     68        if 'corepos_account_id' in data and data['corepos_account_id'] is None:
     69            if self.creating:
     70                data.pop('corepos_account_id')
     71            elif self.editing and not customer._corepos:
     72                data.pop('corepos_account_id')
     73
     74        return super(CustomerView, self).objectify(form, data)
     75
    5676    def get_version_child_classes(self):
    5777        model = self.rattail_config.get_model()
Note: See TracChangeset for help on using the changeset viewer.