def main_entity(main_ent): from sagas.ofbiz.entities import OfEntity as e from sagas.ofbiz.services import OfService as s, create_service_data_frame, MetaService show_entity_flds = st.sidebar.checkbox(label="Show entity fields", value=False) # srv_name='createPerson' srvs = get_model_services(main_ent) for srv_name in srvs: model = model = MetaService(srv_name).model default_ent = model.getDefaultEntityName() if default_ent != '': st.markdown(f"*{srv_name}*, has default entity **{default_ent}**") else: st.markdown(f"*Service Meta*: {srv_name}") st.text(f"{model.getDescription()}") df_srv = create_service_data_frame(srv_name, show_internal=False, show_entity_flds=show_entity_flds) st.table(df_srv) st.markdown("*Entity Meta*") df_ent = e('meta').Person st.dataframe(df_ent) st.markdown("*Entity Relations*") df_rels = e('relations').Person st.dataframe(df_rels)
def test_render(self): from sagas.ofbiz.entities import OfEntity as e oc.import_package('org.apache.ofbiz.base.util.UtilMisc') oc.import_package('com.sagas.meta.PropertiesManager') oc.import_package('org.apache.ofbiz.widget.renderer.fo.FoFormRenderer') oc.import_package('org.apache.ofbiz.widget.renderer.FormRenderer') ffr = oc.j.FoFormRenderer() forms = oc.component('form_mgr') loc = 'component://product/widget/catalog/ProductForms.xml' # form_name='FindProduct' form_name = 'EditProduct' form = forms.getModelForm(form_name, loc) fr = oc.j.FormRenderer(form, ffr) writer = oc.j.StringBuilder() locale = oc.j.UtilMisc.ensureLocale(None) ctx = oc.jmap(locale=locale) ctx.put('product', e().refProduct('GZ-2002')) oc.j.PropertiesManager.execPropertyMap(ctx, "ContentUiLabels", "uiLabelMap", True) fr.render(writer, ctx) print(writer.toString())
def users(self): """ $ python -m sagas.ofbiz.tools users :return: """ from sagas.ofbiz.entities import OfEntity as e, oc rs = e().allUserLogin() for r in rs: print(r['userLoginId'])
def price_from_date(id, dt): props=e().getProductPrice(productId=id, productPriceTypeId='AVERAGE_COST', productPricePurposeId='COMPONENT_PRICE', productStoreGroupId='Test_group', currencyUomId='USD', fromDate=oc.j.Timestamp.valueOf(str(dt))) # st.table(sagas.dict_df(props)) output_rec(props, False)
def notes(): """ $ curl "http://localhost:5000/notes?_start=1&_limit=5" | json :return: """ start = request.args.get('_start', '0', type=int) limit = request.args.get('_limit', '10', type=int) print("get", start, limit) return e('json').listNoteData(_offset=start,_limit=limit), 200
def e(self, dialect=None): """ >>> from sagas.nlu.warehouse import warehouse as wh >>> wh.e('dict').refPerson('10000') :param dialect: :return: """ from sagas.ofbiz.entities import OfEntity as e return e(dialect)
def create_demo_run(self): admin = e().refUserLogin('TestManufAdmin') productId = 'PROD_MANUF' facilityId = 'WebStoreWarehouse' # quantity=oc.j.BigDecimal(5.0) quantity = 5.0 # productionRunStartDate=DateTime.now_timestamp() productionRunStartDate = "2019-02-26 02:12:01.785642" createProductionRun(userLogin=admin, productId=productId, pRQuantity=quantity, startDate=productionRunStartDate, facilityId=facilityId)
def ent(self): from sagas.ofbiz.entities import OfEntity as e return e()
def render_ep(self): from sagas.ofbiz.forms import render_form params = oc.jmap(product=e().refProduct("GZ-2002")) form_name = 'EditProduct' render_form(form_name, locale='zh_CN', params=params)
async def notes(*, start, limit): logging.info("getting notes from %d with limit %d", start, limit) return e('json').listNoteData(_offset=start, _limit=limit)