Beispiel #1
0
    def save_model(self, obj):
        try:
            if not obj.id:
                waybill = WayBillReturnService.create(
                    obj.pointsale_id, obj.receiver_id, obj.date, obj.date_to,
                    obj.type, obj.typeRec, obj.returninst_id)
            else:
                super(WayBillReturnCanon, self).save_model(obj)
                waybill = obj
            if obj.waybill_items:
                try:
                    items = WayBillReturnService.build_retail_items(
                        obj.waybill_items)
                except Exception as exc:
                    debug(u"Ошибка сохранения накладной %s. " + unicode(
                        exc) % obj)
                    raise WayBillReturnCanon.WayBillCanonException(unicode(exc))
                WayBillReturnService.upgrade_items(waybill, items)
        except WayBillReturnService.WayBillReturnServiceExc as exc:
            debug(u"Сохранение накладной %s не удалось." % obj)
            raise WayBillReturnCanon.WayBillCanonException(unicode(exc))

        return waybill