Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: manage stock location on inventory line requests #885

Open
wants to merge 3 commits into
base: wip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelogs/unreleased/88585.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Inventory line: manage stock location",
"type": "feat",
"packages": "stock"
}
11 changes: 10 additions & 1 deletion packages/apps/stock/src/api/inventory-line-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function searchInventoryLines({
export async function updateInventoryLineDetails({
inventoryLineId,
version,
stockLocationId,
realQty,
description = null,
}) {
Expand All @@ -59,14 +60,19 @@ export async function updateInventoryLineDetails({
method: 'put',
body: {
version,
stockLocationId,
realQty,
description,
},
description: 'update inventory line details',
matchers: {
modelName: 'com.axelor.apps.stock.db.InventoryLine',
id: inventoryLineId,
fields: {description, realQty},
fields: {
stockLocationId: 'stockLocation.id',
description,
realQty,
},
},
});
}
Expand All @@ -75,6 +81,7 @@ export async function createInventoryLine({
inventoryId,
inventoryVersion,
productId,
stockLocationId = null,
trackingNumberId = null,
rack = null,
realQty,
Expand All @@ -86,6 +93,7 @@ export async function createInventoryLine({
inventoryId,
inventoryVersion,
productId,
stockLocationId,
trackingNumberId,
rack,
realQty,
Expand All @@ -96,6 +104,7 @@ export async function createInventoryLine({
id: Date.now(),
fields: {
productId: 'product.id',
stockLocationId: 'stockLocation.id',
trackingNumberId: 'trackingNumber.id',
inventoryId: 'inventory.id',
rack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
const InventoryLineButtons = ({
inventoryLine,
inventory,
stockLocation,
trackingNumber,
rack,
realQty,
Expand All @@ -56,6 +57,7 @@ const InventoryLineButtons = ({
inventoryId: inventory.id,
inventoryVersion: inventory.version,
productId: productFromId?.id,
stockLocationId: stockLocation?.id,
trackingNumberId: trackingNumber?.id,
rack: rack == null || rack === '' ? null : rack,
realQty: realQty,
Expand All @@ -71,6 +73,7 @@ const InventoryLineButtons = ({
productFromId?.id,
rack,
realQty,
stockLocation?.id,
trackingNumber?.id,
]);

Expand All @@ -79,6 +82,7 @@ const InventoryLineButtons = ({
updateInventoryLine({
inventoryLineId: inventoryLine?.id,
version: inventoryLine?.version,
stockLocationId: stockLocation?.id,
realQty: realQty,
description: description,
inventoryId: inventory?.id,
Expand All @@ -93,6 +97,7 @@ const InventoryLineButtons = ({
inventoryLine,
navigation,
realQty,
stockLocation?.id,
]);

if (!visible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface InventoryLineCardProps {
unit: string;
trackingNumber?: {trackingNumberSeq: string};
locker?: string;
stockLocationName?: string;
onPress: () => void;
}

Expand All @@ -45,6 +46,7 @@ const InventoryLineCard = ({
unit,
trackingNumber,
locker,
stockLocationName,
onPress,
}: InventoryLineCardProps) => {
const Colors = useThemeColor();
Expand Down Expand Up @@ -89,6 +91,11 @@ const InventoryLineCard = ({
hideIf: trackingNumber?.trackingNumberSeq == null,
iconName: 'qr-code',
},
{
indicatorText: stockLocationName,
hideIfNull: true,
iconName: 'house',
},
],
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const InventorySearchLineContainer = ({}) => {
unit={item.unit?.name}
locker={item.rack}
trackingNumber={item.trackingNumber}
stockLocationName={item.stockLocation?.name}
onPress={() => handleShowLine(item)}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/apps/stock/src/models/objectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const stock_modelAPI: ObjectFields = {
realQty: schemaContructor.number(),
description: schemaContructor.string(),
rack: schemaContructor.string(),
stockLocation: schemaContructor.subObject('name'),
}),
stock_partner: schemaContructor.object({
partnerSeq: schemaContructor.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ import {
InventoryLineQuantityCard,
InventoryLineButtons,
InventoryLineTrackingNumberSelect,
StockLocationSearchBar,
} from '../../components';
import {fetchInventoryLine} from '../../features/inventoryLineSlice';
import {fetchProductWithId} from '../../features/productSlice';
import {Inventory as InventoryType} from '../../types';

const stockLocationScanKey = 'stock-location_inventory-line-details';

const InventoryLineDetailsScreen = ({route, navigation}) => {
const {inventory, inventoryLineId, productId} = route.params;
const I18n = useTranslator();
Expand All @@ -65,6 +68,7 @@ const InventoryLineDetailsScreen = ({route, navigation}) => {
const [rack, setRack] = useState(null);
const [realQty, setRealQty] = useState(0);
const [description, setDescription] = useState();
const [stockLocation, setStockLocation] = useState();
vhu-axelor marked this conversation as resolved.
Show resolved Hide resolved

const trackingNumber = useMemo(
() => inventoryLine?.trackingNumber ?? route.params.trackingNumber,
Expand All @@ -84,6 +88,7 @@ const InventoryLineDetailsScreen = ({route, navigation}) => {
useEffect(() => {
setRealQty(inventoryLine?.realQty ?? 0);
setDescription(inventoryLine?.description);
setStockLocation(inventoryLine?.stockLocation);
setLoading(false);
}, [inventoryLine]);

Expand Down Expand Up @@ -119,6 +124,7 @@ const InventoryLineDetailsScreen = ({route, navigation}) => {
inventoryLine={inventoryLine}
rack={rack}
realQty={realQty}
stockLocation={stockLocation}
trackingNumber={trackingNumber}
visible={!isTrackingNumberSelectVisible}
/>
Expand Down Expand Up @@ -153,6 +159,13 @@ const InventoryLineDetailsScreen = ({route, navigation}) => {
trackingNumber={trackingNumber?.trackingNumberSeq}
locker={inventoryLine?.rack}
/>
<StockLocationSearchBar
vhu-axelor marked this conversation as resolved.
Show resolved Hide resolved
scanKey={stockLocationScanKey}
placeholderKey="Stock_StockLocation"
defaultStockLocation={inventory.stockLocation}
defaultValue={stockLocation}
onChange={setStockLocation}
/>
<InventoryLineTrackingNumberSelect
product={productFromId}
inventoryLine={inventoryLine}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const InventoryLineListScreen = ({route, navigation}) => {
unit={item.unit?.name}
locker={item.rack}
trackingNumber={item.trackingNumber}
stockLocationName={item.stockLocation?.name}
onPress={() => handleShowLine(item)}
/>
)}
Expand Down