示例#1
0
文件: signals.py 项目: rokj/sellout
def register_updated(instance, **kwargs):  # see comments for company_updated
    from common.functions import compare_objects, copy_data

    last_object = BillRegister.objects.filter(register=instance).order_by('-datetime_updated')[:1]

    if len(last_object) > 0:
        last_object = last_object[0]
        if compare_objects(last_object, instance) is True:
            return

    bill_register = BillRegister(
        created_by=instance.created_by,
        register=instance
    )
    copy_data(instance, bill_register)
    bill_register.save()
示例#2
0
文件: signals.py 项目: rokj/sellout
def contact_updated(instance, **kwargs):
    from common.functions import compare_objects, copy_data

    last_object = BillContact.objects.filter(contact=instance).order_by('-datetime_updated')[:1]

    if len(last_object) > 0:
        last_object = last_object[0]
        if compare_objects(last_object, instance) is True:
            return

    bill_contact = BillContact(
        contact=instance,
        created_by=instance.created_by
    )
    copy_data(instance, bill_contact)
    bill_contact.save()
示例#3
0
文件: signals.py 项目: rokj/sellout
def company_updated(instance, **kwargs):
    from common.functions import compare_objects, copy_data

    # get the last saved object from that table and see if anything has changed
    last_object = BillCompany.objects.filter(company=instance).order_by('-datetime_created')[:1]

    if len(last_object) > 0:
        last_object = last_object[0]
        if compare_objects(last_object, instance) is True:
            # there are no changes, there's nothing to be done
            return

    # something has changed, create a new copy of instance in model
    # create a new BillCompany
    bill_company = BillCompany(
        created_by=instance.created_by,
        company=instance
    )

    copy_data(instance, bill_company)
    bill_company.save()