def edit(self, xfer): obj_pstcd = xfer.get_components('postal_code') obj_pstcd.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) obj_city = xfer.get_components('city') postalcode_current = obj_pstcd.value list_postalcode = PostalCode.objects.filter( postal_code=postalcode_current) if len(list_postalcode) > 0: self._change_city_select(xfer, list_postalcode, obj_city) obj_cmt = xfer.get_components('comment') xfer.tab = obj_cmt.tab CustomField.edit_fields(xfer, obj_cmt.col) row = xfer.get_max_row() upload = XferCompUpLoad('uploadlogo') upload.set_value('') upload.description = _('image') upload.add_filter('.jpg') upload.add_filter('.gif') upload.add_filter('.png') upload.add_filter('.bmp') upload.set_location(obj_cmt.col, row + 10, obj_cmt.colspan, 1) xfer.add_component(upload) return
def edit(self, xfer): if xfer.item.id is None: new_account = [] if Params.getvalue("condominium-old-accounting"): new_account.append( Params.getvalue("condominium-default-owner-account")) else: for num_account in LIST_DEFAULT_ACCOUNTS: new_account.append( Params.getvalue("condominium-default-owner-account%d" % num_account)) sel = XferCompSelect('third') sel.needed = True sel.description = _('third') sel.set_location(1, 0) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.filter( accountthird__code__regex=current_system_account( ).get_societary_mask()).exclude( id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: str(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url( 'accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'new_account': ';'.join(new_account)}) xfer.add_component(btn) xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"]) else: old_item = xfer.item xfer.item = old_item.third.contact.get_final_child() xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item.third.get_final_child() xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"])
def edit(self, xfer): if xfer.item.id is None: sel = XferCompSelect('third') sel.needed = True sel.description = _('third') sel.set_location(1, 0) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.all().exclude( id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: six.text_type(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action( xfer.request, ActionsManage.get_action_url('accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={ 'new_account': Params.getvalue('condominium-default-owner-account') }) xfer.add_component(btn) xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"]) else: old_item = xfer.item xfer.item = old_item.third.contact.get_final_child() xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item.third.get_final_child() xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"])
def _fill_customfield(self): self.new_tab(_("Custom field")) img = XferCompImage('imgField') img.set_value(get_icon_path('lucterios.contacts/images/fields.png')) img.set_location(0, 0) self.add_component(img) img = XferCompLabelForm('titleField') img.set_value_as_title(_('custom field list')) img.set_location(1, 0) self.add_component(img) self.fill_grid(0, CustomField, "custom_field", CustomField.get_filter(AbstractContact))