Changeset 69ecb3a in rattail


Ignore:
Timestamp:
07/06/20 21:07:45 (6 weeks ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
60c52f1
Parents:
8128747
Message:

Don't create empty department, when importing subdepartment

i.e. if department_number is null

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/importing/model.py

    r8128747 r69ecb3a  
    12901290    def update_object(self, subdepartment, data, local_data=None):
    12911291        subdepartment = super(SubdepartmentImporter, self).update_object(subdepartment, data, local_data)
     1292
    12921293        if 'department_number' in self.fields:
    1293             dept = self.get_department(data['department_number'])
    1294             if not dept:
    1295                 dept = model.Department()
    1296                 dept.number = data['department_number']
    1297                 self.session.add(dept)
    1298                 self.departments[dept.number] = dept
    1299             subdepartment.department = dept
     1294            department_number = data['department_number']
     1295            if department_number is not None:
     1296                dept = self.get_department(department_number)
     1297                if not dept:
     1298                    dept = model.Department()
     1299                    dept.number = department_number
     1300                    self.session.add(dept)
     1301                    self.departments[dept.number] = dept
     1302                subdepartment.department = dept
     1303            elif subdepartment.department:
     1304                subdepartment.department = None
     1305
    13001306        return subdepartment
    13011307
Note: See TracChangeset for help on using the changeset viewer.