diff --git a/packages/apps/purchase/src/api/index.ts b/packages/apps/purchase/src/api/index.ts index e7d036217..fae530922 100644 --- a/packages/apps/purchase/src/api/index.ts +++ b/packages/apps/purchase/src/api/index.ts @@ -16,5 +16,9 @@ * along with this program. If not, see . */ -export {searchPurchaseRequest as searchPurchaseRequestApi} from './purchase-request-api'; +export { + getPurchaseRequest as getPurchaseRequestApi, + searchPurchaseRequest as searchPurchaseRequestApi, +} from './purchase-request-api'; +export {searchPurchaseRequestLine as searchPurchaseRequestLineApi} from './purchase-request-line-api'; export {searchSupplier as searchSupplierApi} from './supplier-api'; diff --git a/packages/apps/purchase/src/api/purchase-request-api.js b/packages/apps/purchase/src/api/purchase-request-api.js index 14b05ae0b..accd6a100 100644 --- a/packages/apps/purchase/src/api/purchase-request-api.js +++ b/packages/apps/purchase/src/api/purchase-request-api.js @@ -17,6 +17,7 @@ */ import { + createStandardFetch, createStandardSearch, getSearchCriterias, } from '@axelor/aos-mobile-core'; @@ -66,3 +67,11 @@ export async function searchPurchaseRequest({ page, }); } + +export async function getPurchaseRequest({id}) { + return createStandardFetch({ + model: 'com.axelor.apps.purchase.db.PurchaseRequest', + id, + fieldKey: 'purchase_purchaseRequest', + }); +} diff --git a/packages/apps/purchase/src/api/purchase-request-line-api.js b/packages/apps/purchase/src/api/purchase-request-line-api.js new file mode 100644 index 000000000..19079848b --- /dev/null +++ b/packages/apps/purchase/src/api/purchase-request-line-api.js @@ -0,0 +1,39 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import {createStandardSearch} from '@axelor/aos-mobile-core'; + +const createPurchaseRequestLineCriteria = purchaseRequestId => { + return [ + { + fieldName: 'purchaseRequest.id', + operator: '=', + value: purchaseRequestId, + }, + ]; +}; + +export async function searchPurchaseRequestLine({page = 0, purchaseRequestId}) { + return createStandardSearch({ + model: 'com.axelor.apps.purchase.db.PurchaseRequestLine', + criteria: createPurchaseRequestLineCriteria(purchaseRequestId), + fieldKey: 'purchase_purchaseRequestLine', + sortKey: 'purchase_purchaseRequestLine', + page, + }); +} diff --git a/packages/apps/purchase/src/components/atoms/DropdownRequestCharacteristics/DropdownRequestCharacteristics.tsx b/packages/apps/purchase/src/components/atoms/DropdownRequestCharacteristics/DropdownRequestCharacteristics.tsx new file mode 100644 index 000000000..e4dfa256a --- /dev/null +++ b/packages/apps/purchase/src/components/atoms/DropdownRequestCharacteristics/DropdownRequestCharacteristics.tsx @@ -0,0 +1,80 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import React from 'react'; +import {View} from 'react-native'; +import {checkNullString, Label, LabelText} from '@axelor/aos-mobile-ui'; +import {useSelector, useTranslator} from '@axelor/aos-mobile-core'; + +const DropdownRequestCharacteristics = () => { + const I18n = useTranslator(); + + const {purchaseRequest} = useSelector( + state => state.purchase_purchaseRequest, + ); + + if ( + checkNullString(purchaseRequest.supplierPartner?.fullName) && + checkNullString(purchaseRequest.stockLocation?.name) && + checkNullString(purchaseRequest.requesterUser?.fullName) && + checkNullString(purchaseRequest.validatorUser?.fullName) + ) { + return ( +