shutro-erp 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account_portal/.kosh/bindings.js +1 -1
- package/dist/account_portal/.kosh/schema.d.ts +54 -3
- package/dist/account_portal/module.d.ts +359 -6
- package/dist/accounting/.kosh/bindings.js +1 -1
- package/dist/accounting/.kosh/schema.d.ts +54 -3
- package/dist/accounting/index.js +214 -2
- package/dist/accounting/module.d.ts +217 -5
- package/dist/accounting/module.js +23 -2
- package/dist/calendar/.kosh/bindings.d.ts +22 -0
- package/dist/calendar/.kosh/bindings.js +15 -0
- package/dist/calendar/.kosh/schema.d.ts +795 -0
- package/dist/calendar/demo.d.ts +6 -0
- package/dist/calendar/demo.js +24 -0
- package/dist/calendar/index.d.ts +3 -0
- package/dist/calendar/index.js +291 -0
- package/dist/calendar/module.d.ts +1705 -0
- package/dist/calendar/module.js +180 -0
- package/dist/cli/init.js +48 -0
- package/dist/cli/templates.d.ts +1 -1
- package/dist/cli/templates.js +137 -0
- package/dist/contacts/.kosh/bindings.js +1 -1
- package/dist/contacts/.kosh/schema.d.ts +78 -3
- package/dist/contacts/demo.js +30 -1
- package/dist/contacts/index.d.ts +1 -1
- package/dist/contacts/index.js +155 -9
- package/dist/contacts/module.d.ts +338 -2
- package/dist/contacts/module.js +82 -5
- package/dist/crm/.kosh/bindings.d.ts +22 -0
- package/dist/crm/.kosh/bindings.js +15 -0
- package/dist/crm/.kosh/schema.d.ts +799 -0
- package/dist/crm/demo.d.ts +6 -0
- package/dist/crm/demo.js +45 -0
- package/dist/crm/index.d.ts +3 -0
- package/dist/crm/index.js +361 -0
- package/dist/crm/module.d.ts +1843 -0
- package/dist/crm/module.js +207 -0
- package/dist/event/.kosh/bindings.d.ts +22 -0
- package/dist/event/.kosh/bindings.js +15 -0
- package/dist/event/.kosh/schema.d.ts +843 -0
- package/dist/event/demo.d.ts +6 -0
- package/dist/event/demo.js +65 -0
- package/dist/event/index.d.ts +14 -0
- package/dist/event/index.js +333 -0
- package/dist/event/mails.d.ts +15 -0
- package/dist/event/mails.js +112 -0
- package/dist/event/module.d.ts +2800 -0
- package/dist/event/module.js +323 -0
- package/dist/event/web/CheckInBox.d.ts +9 -0
- package/dist/event/web/CheckInBox.js +87 -0
- package/dist/event/web/index.d.ts +11 -0
- package/dist/event/web/index.js +16 -0
- package/dist/event/web/messages.d.ts +2 -0
- package/dist/event/web/messages.js +23 -0
- package/dist/event_account/.kosh/bindings.d.ts +22 -0
- package/dist/event_account/.kosh/bindings.js +15 -0
- package/dist/event_account/.kosh/schema.d.ts +1639 -0
- package/dist/event_account/index.d.ts +3 -0
- package/dist/event_account/index.js +28 -0
- package/dist/event_account/module.d.ts +6968 -0
- package/dist/event_account/module.js +90 -0
- package/dist/hr/.kosh/bindings.d.ts +22 -0
- package/dist/hr/.kosh/bindings.js +15 -0
- package/dist/hr/.kosh/schema.d.ts +878 -0
- package/dist/hr/demo.d.ts +6 -0
- package/dist/hr/demo.js +60 -0
- package/dist/hr/index.d.ts +3 -0
- package/dist/hr/index.js +483 -0
- package/dist/hr/module.d.ts +2611 -0
- package/dist/hr/module.js +350 -0
- package/dist/l10n_bd/.kosh/bindings.js +1 -1
- package/dist/l10n_bd/.kosh/schema.d.ts +54 -3
- package/dist/l10n_bd/module.d.ts +359 -6
- package/dist/l10n_in/.kosh/bindings.js +1 -1
- package/dist/l10n_in/.kosh/schema.d.ts +54 -3
- package/dist/l10n_in/module.d.ts +380 -7
- package/dist/maintenance/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance/.kosh/bindings.js +15 -0
- package/dist/maintenance/.kosh/schema.d.ts +911 -0
- package/dist/maintenance/demo.d.ts +6 -0
- package/dist/maintenance/demo.js +60 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.js +422 -0
- package/dist/maintenance/module.d.ts +3545 -0
- package/dist/maintenance/module.js +446 -0
- package/dist/maintenance_stock/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance_stock/.kosh/bindings.js +15 -0
- package/dist/maintenance_stock/.kosh/schema.d.ts +1371 -0
- package/dist/maintenance_stock/index.d.ts +9 -0
- package/dist/maintenance_stock/index.js +52 -0
- package/dist/maintenance_stock/module.d.ts +6953 -0
- package/dist/maintenance_stock/module.js +192 -0
- package/dist/modules-sdk/index.d.ts +1 -1
- package/dist/modules-sdk/manifest.d.ts +70 -0
- package/dist/modules-sdk/manifest.js +35 -1
- package/dist/mrp/.kosh/bindings.d.ts +22 -0
- package/dist/mrp/.kosh/bindings.js +15 -0
- package/dist/mrp/.kosh/schema.d.ts +1378 -0
- package/dist/mrp/demo.d.ts +7 -0
- package/dist/mrp/demo.js +42 -0
- package/dist/mrp/index.d.ts +3 -0
- package/dist/mrp/index.js +392 -0
- package/dist/mrp/module.d.ts +8608 -0
- package/dist/mrp/module.js +695 -0
- package/dist/mrp_account/.kosh/bindings.d.ts +22 -0
- package/dist/mrp_account/.kosh/bindings.js +15 -0
- package/dist/mrp_account/.kosh/schema.d.ts +2106 -0
- package/dist/mrp_account/index.d.ts +3 -0
- package/dist/mrp_account/index.js +22 -0
- package/dist/mrp_account/module.d.ts +20840 -0
- package/dist/mrp_account/module.js +123 -0
- package/dist/payment/.kosh/bindings.js +1 -1
- package/dist/payment/.kosh/schema.d.ts +54 -3
- package/dist/payment/module.d.ts +359 -6
- package/dist/portal/.kosh/bindings.js +1 -1
- package/dist/portal/.kosh/schema.d.ts +78 -3
- package/dist/portal/module.d.ts +166 -2
- package/dist/pos/.kosh/bindings.d.ts +22 -0
- package/dist/pos/.kosh/bindings.js +15 -0
- package/dist/pos/.kosh/schema.d.ts +1690 -0
- package/dist/pos/accounting.d.ts +10 -0
- package/dist/pos/accounting.js +149 -0
- package/dist/pos/demo.d.ts +6 -0
- package/dist/pos/demo.js +90 -0
- package/dist/pos/index.d.ts +9 -0
- package/dist/pos/index.js +349 -0
- package/dist/pos/module.d.ts +9636 -0
- package/dist/pos/module.js +423 -0
- package/dist/pos/routes.d.ts +39 -0
- package/dist/pos/routes.js +368 -0
- package/dist/pos/web/Register.d.ts +9 -0
- package/dist/pos/web/Register.js +252 -0
- package/dist/pos/web/index.d.ts +11 -0
- package/dist/pos/web/index.js +16 -0
- package/dist/pos/web/messages.d.ts +2 -0
- package/dist/pos/web/messages.js +87 -0
- package/dist/pos_stock/.kosh/bindings.d.ts +22 -0
- package/dist/pos_stock/.kosh/bindings.js +15 -0
- package/dist/pos_stock/.kosh/schema.d.ts +2015 -0
- package/dist/pos_stock/index.d.ts +9 -0
- package/dist/pos_stock/index.js +35 -0
- package/dist/pos_stock/module.d.ts +11935 -0
- package/dist/pos_stock/module.js +115 -0
- package/dist/product/.kosh/bindings.js +1 -1
- package/dist/product/.kosh/schema.d.ts +51 -1
- package/dist/product/index.js +81 -4
- package/dist/product/module.d.ts +43 -1
- package/dist/product/module.js +9 -2
- package/dist/project/.kosh/bindings.js +1 -1
- package/dist/project/.kosh/schema.d.ts +54 -3
- package/dist/project/index.js +147 -7
- package/dist/project/module.d.ts +210 -2
- package/dist/project/module.js +52 -5
- package/dist/project_portal/.kosh/bindings.js +1 -1
- package/dist/project_portal/.kosh/schema.d.ts +54 -3
- package/dist/project_portal/module.d.ts +353 -4
- package/dist/purchase/.kosh/bindings.js +1 -1
- package/dist/purchase/.kosh/schema.d.ts +54 -3
- package/dist/purchase/index.js +163 -3
- package/dist/purchase/module.d.ts +215 -3
- package/dist/purchase/module.js +21 -3
- package/dist/purchase_account/.kosh/bindings.js +1 -1
- package/dist/purchase_account/.kosh/schema.d.ts +55 -3
- package/dist/purchase_account/index.js +26 -1
- package/dist/purchase_account/module.d.ts +393 -7
- package/dist/purchase_portal/.kosh/bindings.js +1 -1
- package/dist/purchase_portal/.kosh/schema.d.ts +54 -3
- package/dist/purchase_portal/module.d.ts +366 -5
- package/dist/purchase_stock/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock/.kosh/bindings.js +15 -0
- package/dist/purchase_stock/.kosh/schema.d.ts +1310 -0
- package/dist/purchase_stock/index.d.ts +7 -0
- package/dist/purchase_stock/index.js +91 -0
- package/dist/purchase_stock/module.d.ts +6763 -0
- package/dist/purchase_stock/module.js +144 -0
- package/dist/purchase_stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock_account/.kosh/bindings.js +15 -0
- package/dist/purchase_stock_account/.kosh/schema.d.ts +1959 -0
- package/dist/purchase_stock_account/index.d.ts +3 -0
- package/dist/purchase_stock_account/index.js +24 -0
- package/dist/purchase_stock_account/module.d.ts +35366 -0
- package/dist/purchase_stock_account/module.js +162 -0
- package/dist/recruitment/.kosh/bindings.d.ts +22 -0
- package/dist/recruitment/.kosh/bindings.js +15 -0
- package/dist/recruitment/.kosh/schema.d.ts +990 -0
- package/dist/recruitment/demo.d.ts +6 -0
- package/dist/recruitment/demo.js +45 -0
- package/dist/recruitment/index.d.ts +3 -0
- package/dist/recruitment/index.js +385 -0
- package/dist/recruitment/module.d.ts +3247 -0
- package/dist/recruitment/module.js +193 -0
- package/dist/recruitment/web/HireButton.d.ts +9 -0
- package/dist/recruitment/web/HireButton.js +32 -0
- package/dist/recruitment/web/index.d.ts +11 -0
- package/dist/recruitment/web/index.js +16 -0
- package/dist/recruitment/web/messages.d.ts +2 -0
- package/dist/recruitment/web/messages.js +19 -0
- package/dist/reporting/documents.d.ts +5 -0
- package/dist/reporting/documents.js +28 -1
- package/dist/reporting/index.d.ts +1 -1
- package/dist/reporting/index.js +4 -2
- package/dist/reporting/models.js +9 -0
- package/dist/reporting/overviews.d.ts +16 -0
- package/dist/reporting/overviews.js +56 -0
- package/dist/reporting/routes-documents.js +1 -1
- package/dist/reporting/routes.js +138 -80
- package/dist/reporting/web/DashboardView.d.ts +11 -0
- package/dist/reporting/web/DashboardView.js +2 -2
- package/dist/reporting/web/DesignerView.js +5 -0
- package/dist/reporting/web/Overview.d.ts +9 -0
- package/dist/reporting/web/Overview.js +53 -0
- package/dist/reporting/web/index.d.ts +1 -0
- package/dist/reporting/web/index.js +4 -1
- package/dist/reporting/web/messages.js +9 -0
- package/dist/sale_account/.kosh/bindings.js +1 -1
- package/dist/sale_account/.kosh/schema.d.ts +59 -3
- package/dist/sale_account/index.js +22 -1
- package/dist/sale_account/module.d.ts +461 -7
- package/dist/sale_portal/.kosh/bindings.js +1 -1
- package/dist/sale_portal/.kosh/schema.d.ts +58 -3
- package/dist/sale_portal/module.d.ts +434 -5
- package/dist/sale_project/.kosh/bindings.js +1 -1
- package/dist/sale_project/.kosh/schema.d.ts +60 -3
- package/dist/sale_project/module.d.ts +476 -6
- package/dist/sale_stock/.kosh/bindings.d.ts +22 -0
- package/dist/sale_stock/.kosh/bindings.js +15 -0
- package/dist/sale_stock/.kosh/schema.d.ts +1228 -0
- package/dist/sale_stock/index.d.ts +7 -0
- package/dist/sale_stock/index.js +84 -0
- package/dist/sale_stock/module.d.ts +6791 -0
- package/dist/sale_stock/module.js +146 -0
- package/dist/sales/.kosh/bindings.js +1 -1
- package/dist/sales/.kosh/schema.d.ts +58 -3
- package/dist/sales/index.js +191 -4
- package/dist/sales/module.d.ts +355 -3
- package/dist/sales/module.js +78 -3
- package/dist/server/api/metadata.d.ts +5 -0
- package/dist/server/api/metadata.js +5 -0
- package/dist/server/api/rest.js +64 -1
- package/dist/server/api/views.js +1 -0
- package/dist/server/app-settings.d.ts +7 -0
- package/dist/server/app-settings.js +10 -0
- package/dist/server/auth/base.js +9 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/settings/app-settings.d.ts +2 -0
- package/dist/settings/app-settings.js +518 -0
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.js +15 -0
- package/dist/settings/people.js +29 -5
- package/dist/settings/web/AppSettingsPage.d.ts +11 -0
- package/dist/settings/web/AppSettingsPage.js +210 -0
- package/dist/settings/web/OverviewPage.js +16 -3
- package/dist/settings/web/PeoplePage.js +20 -6
- package/dist/settings/web/index.d.ts +1 -0
- package/dist/settings/web/index.js +3 -0
- package/dist/settings/web/messages.js +118 -2
- package/dist/stock/.kosh/bindings.d.ts +22 -0
- package/dist/stock/.kosh/bindings.js +15 -0
- package/dist/stock/.kosh/schema.d.ts +1147 -0
- package/dist/stock/demo.d.ts +7 -0
- package/dist/stock/demo.js +55 -0
- package/dist/stock/index.d.ts +3 -0
- package/dist/stock/index.js +674 -0
- package/dist/stock/module.d.ts +6330 -0
- package/dist/stock/module.js +1325 -0
- package/dist/stock/web/ScanBox.d.ts +8 -0
- package/dist/stock/web/ScanBox.js +90 -0
- package/dist/stock/web/index.d.ts +11 -0
- package/dist/stock/web/index.js +16 -0
- package/dist/stock/web/messages.d.ts +2 -0
- package/dist/stock/web/messages.js +25 -0
- package/dist/stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/stock_account/.kosh/bindings.js +15 -0
- package/dist/stock_account/.kosh/schema.d.ts +1875 -0
- package/dist/stock_account/index.d.ts +3 -0
- package/dist/stock_account/index.js +130 -0
- package/dist/stock_account/module.d.ts +10655 -0
- package/dist/stock_account/module.js +339 -0
- package/dist/storage/attachments.d.ts +5 -0
- package/dist/storage/attachments.js +12 -1
- package/dist/storage/models.js +3 -0
- package/dist/storage/routes.js +13 -2
- package/dist/todo/.kosh/bindings.d.ts +22 -0
- package/dist/todo/.kosh/bindings.js +15 -0
- package/dist/todo/.kosh/schema.d.ts +732 -0
- package/dist/todo/demo.d.ts +6 -0
- package/dist/todo/demo.js +35 -0
- package/dist/todo/index.d.ts +3 -0
- package/dist/todo/index.js +187 -0
- package/dist/todo/module.d.ts +1180 -0
- package/dist/todo/module.js +130 -0
- package/dist/trade_finance/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance/.kosh/bindings.js +15 -0
- package/dist/trade_finance/.kosh/schema.d.ts +884 -0
- package/dist/trade_finance/demo.d.ts +6 -0
- package/dist/trade_finance/demo.js +63 -0
- package/dist/trade_finance/index.d.ts +3 -0
- package/dist/trade_finance/index.js +413 -0
- package/dist/trade_finance/module.d.ts +3779 -0
- package/dist/trade_finance/module.js +505 -0
- package/dist/trade_finance_account/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_account/.kosh/bindings.js +15 -0
- package/dist/trade_finance_account/.kosh/schema.d.ts +1711 -0
- package/dist/trade_finance_account/index.d.ts +3 -0
- package/dist/trade_finance_account/index.js +92 -0
- package/dist/trade_finance_account/module.d.ts +7928 -0
- package/dist/trade_finance_account/module.js +244 -0
- package/dist/trade_finance_purchase/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_purchase/.kosh/bindings.js +15 -0
- package/dist/trade_finance_purchase/.kosh/schema.d.ts +1153 -0
- package/dist/trade_finance_purchase/index.d.ts +8 -0
- package/dist/trade_finance_purchase/index.js +50 -0
- package/dist/trade_finance_purchase/module.d.ts +4252 -0
- package/dist/trade_finance_purchase/module.js +44 -0
- package/dist/trade_finance_sale/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_sale/.kosh/bindings.js +15 -0
- package/dist/trade_finance_sale/.kosh/schema.d.ts +1071 -0
- package/dist/trade_finance_sale/index.d.ts +8 -0
- package/dist/trade_finance_sale/index.js +50 -0
- package/dist/trade_finance_sale/module.d.ts +4280 -0
- package/dist/trade_finance_sale/module.js +44 -0
- package/dist/ui/api.d.ts +2 -1
- package/dist/ui/api.js +2 -1
- package/dist/ui/app.js +2 -1
- package/dist/ui/components/AppIcon.js +23 -1
- package/dist/ui/components/primitives.d.ts +2 -0
- package/dist/ui/components/primitives.js +7 -1
- package/dist/ui/i18n/messages.d.ts +23 -0
- package/dist/ui/i18n/messages.js +38 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/offline/queue.d.ts +5 -1
- package/dist/ui/offline/queue.js +2 -0
- package/dist/ui/registry.d.ts +5 -0
- package/dist/ui/shell/Home.js +55 -4
- package/dist/ui/views/FormView.js +98 -17
- package/dist/ui/views/KanbanView.d.ts +2 -0
- package/dist/ui/views/KanbanView.js +32 -3
- package/dist/ui/views/ListView.js +108 -11
- package/dist/ui/views/StatsRow.d.ts +14 -0
- package/dist/ui/views/StatsRow.js +88 -0
- package/dist/ui/views/widgets.d.ts +2 -1
- package/dist/ui/views/widgets.js +194 -1
- package/dist/views/builders.d.ts +19 -2
- package/dist/views/builders.js +21 -1
- package/dist/views/condition.d.ts +6 -0
- package/dist/views/condition.js +20 -0
- package/dist/views/documents.d.ts +8 -0
- package/dist/views/extend.d.ts +2 -2
- package/dist/views/extend.js +11 -1
- package/dist/views/index.d.ts +2 -2
- package/dist/views/index.js +2 -2
- package/dist/views/types.d.ts +52 -5
- package/dist/views/validate.js +39 -1
- package/dist/website/.kosh/bindings.d.ts +22 -0
- package/dist/website/.kosh/bindings.js +15 -0
- package/dist/website/.kosh/schema.d.ts +881 -0
- package/dist/website/demo.d.ts +6 -0
- package/dist/website/demo.js +115 -0
- package/dist/website/index.d.ts +9 -0
- package/dist/website/index.js +250 -0
- package/dist/website/module.d.ts +2987 -0
- package/dist/website/module.js +281 -0
- package/dist/website/render.d.ts +45 -0
- package/dist/website/render.js +102 -0
- package/dist/website/routes.d.ts +12 -0
- package/dist/website/routes.js +246 -0
- package/dist/website/web/PagePreview.d.ts +7 -0
- package/dist/website/web/PagePreview.js +33 -0
- package/dist/website/web/index.d.ts +11 -0
- package/dist/website/web/index.js +16 -0
- package/dist/website/web/messages.d.ts +2 -0
- package/dist/website/web/messages.js +15 -0
- package/dist/website_crm/.kosh/bindings.d.ts +22 -0
- package/dist/website_crm/.kosh/bindings.js +15 -0
- package/dist/website_crm/.kosh/schema.d.ts +966 -0
- package/dist/website_crm/index.d.ts +3 -0
- package/dist/website_crm/index.js +39 -0
- package/dist/website_crm/module.d.ts +2955 -0
- package/dist/website_crm/module.js +44 -0
- package/package.json +118 -1
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `shutro-erp/stock` (RFC 0021): the **Stockroom** app. Warehouses and a tree of locations; the Transfer — one document
|
|
4
|
+
* for receipts, deliveries and internal moves — with one status chip (Draft, Waiting, Ready, Done, Cancelled);
|
|
5
|
+
* reservations that say what they are for; units converted exactly; stock that never goes below zero. Every company
|
|
6
|
+
* gets its main warehouse (`WH`, `WH/Stock`) when the app is installed or the company is created.
|
|
7
|
+
*/
|
|
8
|
+
import { contacts } from '../contacts/index.js';
|
|
9
|
+
import { messaging } from '../messaging/index.js';
|
|
10
|
+
import { defineModule } from '../modules-sdk/index.js';
|
|
11
|
+
import { product } from '../product/index.js';
|
|
12
|
+
import { reporting } from '../reporting/index.js';
|
|
13
|
+
import { HttpProblem } from '../server/index.js';
|
|
14
|
+
import { orm } from '../server/orm.js';
|
|
15
|
+
import { action, field, form, kanban, list, search, stat } from '../views/index.js';
|
|
16
|
+
import { stockDemo } from './demo.js';
|
|
17
|
+
import { onHandIn, StockCount, StockCountLine, StockLocation, StockLot, StockLotLine, StockMove, StockPicking, StockQuant, StockReservation, StockScrap, StockWarehouse, stockShutro, } from './module.js';
|
|
18
|
+
export { defaultLocations, inProductUnit, onHandIn, ProductStock, reserveOnConfirm, SCRAP_REASONS, StockCount, StockCountLine, StockLocation, StockLot, StockLotLine, StockMove, StockPicking, StockQuant, StockReservation, StockScrap, StockWarehouse, stockShutro, } from './module.js';
|
|
19
|
+
/** Every company without a warehouse gets its main one, `WH`, with its stock location `WH/Stock`. */
|
|
20
|
+
async function mainWarehouses(env) {
|
|
21
|
+
const companies = await env.model('res.company').search({});
|
|
22
|
+
let made = 0;
|
|
23
|
+
for (const company of companies.ids) {
|
|
24
|
+
const any = await env
|
|
25
|
+
.withFlags({ activeTest: false })
|
|
26
|
+
.model('stock.warehouse')
|
|
27
|
+
.search({ where: { company }, limit: 1 });
|
|
28
|
+
if (any.length > 0)
|
|
29
|
+
continue;
|
|
30
|
+
const warehouse = (await env.model('stock.warehouse').create([{ name: 'Main warehouse', code: 'WH', company }])).ids[0];
|
|
31
|
+
if (warehouse === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
await env
|
|
34
|
+
.model('stock.location')
|
|
35
|
+
.create([{ name: 'Stock', usage: 'internal', warehouse, company }]);
|
|
36
|
+
made += 1;
|
|
37
|
+
}
|
|
38
|
+
// Checked here, in this scope (the caller's flush would run the checks without its rights).
|
|
39
|
+
await env.flush();
|
|
40
|
+
return made === 0 ? undefined : `${made} main warehouse(s) made`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Counting from a phone: each scan adds to what is counted (one, or the quantity sent) — a lot or serial number's
|
|
44
|
+
* name counts that lot, a product's barcode the product — on the count's line, made with what is expected when it
|
|
45
|
+
* was not listed. As the user: their rights apply; the count must be counting.
|
|
46
|
+
*/
|
|
47
|
+
function registerCountRoutes({ app }) {
|
|
48
|
+
app.post('/api/v1/stockroom/counts/:id/scan', async (request) => {
|
|
49
|
+
const id = Number(request.params.id);
|
|
50
|
+
if (!Number.isSafeInteger(id) || id <= 0)
|
|
51
|
+
throw new HttpProblem(400, 'invalid-id', 'Invalid id', 'A count id.');
|
|
52
|
+
const body = (request.body ?? {});
|
|
53
|
+
const barcode = typeof body.barcode === 'string' ? body.barcode.trim() : '';
|
|
54
|
+
if (barcode === '')
|
|
55
|
+
throw new HttpProblem(400, 'invalid-barcode', 'No barcode', 'Send the scanned barcode.');
|
|
56
|
+
let quantity = orm.toDecimal(1);
|
|
57
|
+
if (body.quantity !== undefined)
|
|
58
|
+
try {
|
|
59
|
+
quantity = orm.toDecimal(String(body.quantity));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
throw new HttpProblem(400, 'invalid-quantity', 'Invalid quantity', 'A positive number.');
|
|
63
|
+
}
|
|
64
|
+
if (quantity.lte(0))
|
|
65
|
+
throw new HttpProblem(400, 'invalid-quantity', 'Invalid quantity', 'A positive number.');
|
|
66
|
+
return request.env(async (raw) => {
|
|
67
|
+
const env = raw;
|
|
68
|
+
const [count] = await (await env
|
|
69
|
+
.model('stock.count')
|
|
70
|
+
.search({ where: { id: orm.asId(id, 'stock.count') }, limit: 1 })).load({ location: true });
|
|
71
|
+
if (count === undefined)
|
|
72
|
+
throw new HttpProblem(404, 'missing-record', 'Not found', `There is no count ${id}.`);
|
|
73
|
+
if (count.state !== 'counting')
|
|
74
|
+
throw new HttpProblem(409, 'not-counting', 'Not counting', 'Start the count first.');
|
|
75
|
+
const [scannedLot] = await (await env.model('stock.lot').search({ where: { name: barcode }, limit: 1 })).load({ product: true });
|
|
76
|
+
const lot = scannedLot?.id ?? null;
|
|
77
|
+
const [found] = scannedLot !== undefined
|
|
78
|
+
? [scannedLot.product]
|
|
79
|
+
: await (await env.model('product.product').search({ where: { barcode }, limit: 1 })).load(['name', 'kind']);
|
|
80
|
+
if (found === undefined)
|
|
81
|
+
throw new HttpProblem(404, 'unknown-barcode', 'Unknown barcode', `No product has the barcode ${barcode}.`);
|
|
82
|
+
const product = found.id;
|
|
83
|
+
const [line] = await (await env.model('stock.count.line').search({
|
|
84
|
+
where: { count: count.id, product, lot: lot === null ? { isNull: true } : lot },
|
|
85
|
+
limit: 1,
|
|
86
|
+
})).load(['counted', 'expected']);
|
|
87
|
+
const counted = (line?.counted ?? orm.toDecimal(0)).plus(quantity);
|
|
88
|
+
if (line !== undefined)
|
|
89
|
+
await line.write({ counted });
|
|
90
|
+
else
|
|
91
|
+
await env.model('stock.count.line').create([
|
|
92
|
+
{
|
|
93
|
+
count: count.id,
|
|
94
|
+
product,
|
|
95
|
+
lot,
|
|
96
|
+
expected: await onHandIn(env, product, count.location.id, lot),
|
|
97
|
+
counted,
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
await env.flush();
|
|
101
|
+
return {
|
|
102
|
+
product: found.name,
|
|
103
|
+
...(scannedLot === undefined ? {} : { lot: scannedLot.name }),
|
|
104
|
+
counted: counted.toString(),
|
|
105
|
+
};
|
|
106
|
+
}, { write: true });
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export const stock = defineModule({
|
|
110
|
+
shutro: stockShutro,
|
|
111
|
+
kosh: '^0.1.0',
|
|
112
|
+
hooks: {
|
|
113
|
+
defaults: async (env) => env.asSuperuser({ reason: 'main warehouses' }, (su) => mainWarehouses(su)),
|
|
114
|
+
demo: stockDemo,
|
|
115
|
+
},
|
|
116
|
+
depends: [product, contacts, messaging, reporting],
|
|
117
|
+
app: {
|
|
118
|
+
code: 'stockroom',
|
|
119
|
+
label: 'Stockroom',
|
|
120
|
+
icon: 'stockroom',
|
|
121
|
+
sequence: 12,
|
|
122
|
+
category: 'Operations',
|
|
123
|
+
summary: 'Warehouses, transfers with one clear status, reservations that say what they are for',
|
|
124
|
+
},
|
|
125
|
+
accessLevels: {
|
|
126
|
+
user: { label: 'User (transfers, stock)', groups: ['stock.user'] },
|
|
127
|
+
manager: {
|
|
128
|
+
label: 'Manager (warehouses, locations, everything)',
|
|
129
|
+
groups: ['stock.manager'],
|
|
130
|
+
implies: ['user'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
routes: (context) => registerCountRoutes(context),
|
|
134
|
+
settings: {
|
|
135
|
+
sections: [
|
|
136
|
+
{
|
|
137
|
+
key: 'reservations',
|
|
138
|
+
label: 'Reservations',
|
|
139
|
+
description: 'When transfers hold the stock they take.',
|
|
140
|
+
keywords: 'reserve reservation availability transfer delivery',
|
|
141
|
+
scope: 'installation',
|
|
142
|
+
editors: ['stock.manager'],
|
|
143
|
+
fields: [
|
|
144
|
+
{
|
|
145
|
+
key: 'reserveOnConfirm',
|
|
146
|
+
type: 'boolean',
|
|
147
|
+
label: 'Reserve when a transfer is confirmed',
|
|
148
|
+
default: true,
|
|
149
|
+
help: 'Off: stock is reserved only with Check availability.',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
// The Overview (RFC 0022 step 2).
|
|
156
|
+
overview: {
|
|
157
|
+
cards: [
|
|
158
|
+
{
|
|
159
|
+
id: 'receipts_todo',
|
|
160
|
+
title: 'Receipts to do',
|
|
161
|
+
kind: 'kpi',
|
|
162
|
+
model: 'stock.picking',
|
|
163
|
+
measure: 'count',
|
|
164
|
+
filter: { kind: 'receipt', status: { in: ['waiting', 'ready'] } },
|
|
165
|
+
w: 3,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'deliveries_todo',
|
|
169
|
+
title: 'Deliveries to do',
|
|
170
|
+
kind: 'kpi',
|
|
171
|
+
model: 'stock.picking',
|
|
172
|
+
measure: 'count',
|
|
173
|
+
filter: { kind: 'delivery', status: { in: ['waiting', 'ready'] } },
|
|
174
|
+
w: 3,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: 'done_month',
|
|
178
|
+
title: 'Transfers done this month',
|
|
179
|
+
kind: 'kpi',
|
|
180
|
+
model: 'stock.picking',
|
|
181
|
+
measure: 'count',
|
|
182
|
+
filter: { status: 'done' },
|
|
183
|
+
comparison: { field: 'scheduledDate', mode: 'previous' },
|
|
184
|
+
w: 3,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'reservations',
|
|
188
|
+
title: 'Reservations',
|
|
189
|
+
kind: 'kpi',
|
|
190
|
+
model: 'stock.reservation',
|
|
191
|
+
measure: 'count',
|
|
192
|
+
w: 3,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'by_status',
|
|
196
|
+
title: 'Transfers by status',
|
|
197
|
+
kind: 'chart',
|
|
198
|
+
model: 'stock.picking',
|
|
199
|
+
measure: 'count',
|
|
200
|
+
groupBy: 'status',
|
|
201
|
+
chart: 'bar',
|
|
202
|
+
w: 6,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'on_hand_by_location',
|
|
206
|
+
title: 'On hand by location',
|
|
207
|
+
kind: 'chart',
|
|
208
|
+
model: 'stock.quant',
|
|
209
|
+
measure: 'sum:quantity',
|
|
210
|
+
groupBy: 'location',
|
|
211
|
+
filter: { quantity: { gt: 0 } },
|
|
212
|
+
chart: 'bar',
|
|
213
|
+
w: 6,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: 'most_stocked',
|
|
217
|
+
title: 'Most stocked products',
|
|
218
|
+
kind: 'pivot',
|
|
219
|
+
model: 'stock.quant',
|
|
220
|
+
measure: 'sum:quantity',
|
|
221
|
+
groupBy: 'product',
|
|
222
|
+
filter: { quantity: { gt: 0 } },
|
|
223
|
+
w: 6,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: 'late',
|
|
227
|
+
title: 'Scheduled transfers',
|
|
228
|
+
kind: 'list',
|
|
229
|
+
model: 'stock.picking',
|
|
230
|
+
measure: 'count',
|
|
231
|
+
filter: { status: { in: ['waiting', 'ready'] } },
|
|
232
|
+
w: 6,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
actions: {
|
|
237
|
+
'stockroom.action_transfers': action(StockPicking, {
|
|
238
|
+
label: 'Transfers',
|
|
239
|
+
views: ['list', 'kanban', 'form'],
|
|
240
|
+
defaults: { kind: 'internal' },
|
|
241
|
+
defaultFilters: ['open'],
|
|
242
|
+
}),
|
|
243
|
+
'stockroom.action_receipts': action(StockPicking, {
|
|
244
|
+
label: 'Receipts',
|
|
245
|
+
views: ['list', 'kanban', 'form'],
|
|
246
|
+
defaults: { kind: 'receipt' },
|
|
247
|
+
defaultFilters: ['receipts', 'open'],
|
|
248
|
+
}),
|
|
249
|
+
'stockroom.action_deliveries': action(StockPicking, {
|
|
250
|
+
label: 'Deliveries',
|
|
251
|
+
views: ['list', 'kanban', 'form'],
|
|
252
|
+
defaults: { kind: 'delivery' },
|
|
253
|
+
defaultFilters: ['deliveries', 'open'],
|
|
254
|
+
}),
|
|
255
|
+
'stockroom.action_stock': action(StockQuant, {
|
|
256
|
+
label: 'Stock',
|
|
257
|
+
views: ['list', 'form'],
|
|
258
|
+
defaultFilters: ['in_stock'],
|
|
259
|
+
}),
|
|
260
|
+
'stockroom.action_reservations': action(StockReservation, {
|
|
261
|
+
label: 'Reservations',
|
|
262
|
+
views: ['list'],
|
|
263
|
+
}),
|
|
264
|
+
'stockroom.action_lots': action(StockLot, {
|
|
265
|
+
label: 'Lots and serial numbers',
|
|
266
|
+
views: ['list', 'form'],
|
|
267
|
+
defaultFilters: ['in_stock'],
|
|
268
|
+
}),
|
|
269
|
+
'stockroom.action_scraps': action(StockScrap, {
|
|
270
|
+
label: 'Scrap',
|
|
271
|
+
views: ['list', 'form'],
|
|
272
|
+
}),
|
|
273
|
+
'stockroom.action_counts': action(StockCount, {
|
|
274
|
+
label: 'Counts',
|
|
275
|
+
views: ['list', 'form'],
|
|
276
|
+
defaultFilters: ['open'],
|
|
277
|
+
}),
|
|
278
|
+
'stockroom.action_warehouses': action(StockWarehouse, {
|
|
279
|
+
label: 'Warehouses',
|
|
280
|
+
views: ['list', 'form'],
|
|
281
|
+
}),
|
|
282
|
+
'stockroom.action_locations': action(StockLocation, {
|
|
283
|
+
label: 'Locations',
|
|
284
|
+
views: ['list', 'form'],
|
|
285
|
+
defaultFilters: ['internal'],
|
|
286
|
+
}),
|
|
287
|
+
},
|
|
288
|
+
menus: [
|
|
289
|
+
{ id: 'stockroom.root', label: 'Stockroom', app: 'stockroom' },
|
|
290
|
+
{
|
|
291
|
+
id: 'stockroom.transfers',
|
|
292
|
+
parent: 'stockroom.root',
|
|
293
|
+
label: 'Transfers',
|
|
294
|
+
action: 'stockroom.action_transfers',
|
|
295
|
+
sequence: 1,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 'stockroom.receipts',
|
|
299
|
+
parent: 'stockroom.root',
|
|
300
|
+
label: 'Receipts',
|
|
301
|
+
action: 'stockroom.action_receipts',
|
|
302
|
+
sequence: 2,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: 'stockroom.deliveries',
|
|
306
|
+
parent: 'stockroom.root',
|
|
307
|
+
label: 'Deliveries',
|
|
308
|
+
action: 'stockroom.action_deliveries',
|
|
309
|
+
sequence: 3,
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: 'stockroom.stock',
|
|
313
|
+
parent: 'stockroom.root',
|
|
314
|
+
label: 'Stock',
|
|
315
|
+
action: 'stockroom.action_stock',
|
|
316
|
+
sequence: 4,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: 'stockroom.reservations',
|
|
320
|
+
parent: 'stockroom.root',
|
|
321
|
+
label: 'Reservations',
|
|
322
|
+
action: 'stockroom.action_reservations',
|
|
323
|
+
sequence: 5,
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
id: 'stockroom.lots',
|
|
327
|
+
parent: 'stockroom.root',
|
|
328
|
+
label: 'Lots and serial numbers',
|
|
329
|
+
action: 'stockroom.action_lots',
|
|
330
|
+
sequence: 5,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
id: 'stockroom.counts',
|
|
334
|
+
parent: 'stockroom.root',
|
|
335
|
+
label: 'Counts',
|
|
336
|
+
action: 'stockroom.action_counts',
|
|
337
|
+
sequence: 6,
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
id: 'stockroom.scraps',
|
|
341
|
+
parent: 'stockroom.root',
|
|
342
|
+
label: 'Scrap',
|
|
343
|
+
action: 'stockroom.action_scraps',
|
|
344
|
+
sequence: 8,
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
id: 'stockroom.configuration',
|
|
348
|
+
parent: 'stockroom.root',
|
|
349
|
+
label: 'Configuration',
|
|
350
|
+
sequence: 9,
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
id: 'stockroom.warehouses',
|
|
354
|
+
parent: 'stockroom.configuration',
|
|
355
|
+
label: 'Warehouses',
|
|
356
|
+
action: 'stockroom.action_warehouses',
|
|
357
|
+
sequence: 1,
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
id: 'stockroom.locations',
|
|
361
|
+
parent: 'stockroom.configuration',
|
|
362
|
+
label: 'Locations',
|
|
363
|
+
action: 'stockroom.action_locations',
|
|
364
|
+
sequence: 2,
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
views: {
|
|
368
|
+
'stock.picking.list': list(StockPicking, {
|
|
369
|
+
columns: [
|
|
370
|
+
'name',
|
|
371
|
+
'kind',
|
|
372
|
+
'partner',
|
|
373
|
+
'source',
|
|
374
|
+
'destination',
|
|
375
|
+
{ field: 'scheduledDate', widget: 'daysLeft' },
|
|
376
|
+
'origin',
|
|
377
|
+
{ field: 'status', widget: 'badge' },
|
|
378
|
+
],
|
|
379
|
+
decorations: {
|
|
380
|
+
success: { status: 'done' },
|
|
381
|
+
warning: { status: 'waiting' },
|
|
382
|
+
neutral: { status: 'cancelled' },
|
|
383
|
+
},
|
|
384
|
+
}),
|
|
385
|
+
'stock.picking.kanban': kanban(StockPicking, {
|
|
386
|
+
groupBy: 'status',
|
|
387
|
+
card: {
|
|
388
|
+
title: 'name',
|
|
389
|
+
subtitle: 'partner',
|
|
390
|
+
color: 'kind',
|
|
391
|
+
footer: [{ field: 'scheduledDate', widget: 'daysLeft' }, 'origin'],
|
|
392
|
+
badges: [{ field: 'kind', widget: 'badge' }],
|
|
393
|
+
},
|
|
394
|
+
}),
|
|
395
|
+
'stock.picking.form': form(StockPicking, (k) => ({
|
|
396
|
+
header: {
|
|
397
|
+
statusbar: 'state',
|
|
398
|
+
buttons: [
|
|
399
|
+
k.button('confirm', { primary: true, label: 'Confirm' }),
|
|
400
|
+
k.button('reserve', { label: 'Check availability' }),
|
|
401
|
+
k.button('validate', { primary: true, label: 'Validate' }),
|
|
402
|
+
k.button('unreserve', { label: 'Unreserve' }),
|
|
403
|
+
k.button('cancel', {
|
|
404
|
+
label: 'Cancel',
|
|
405
|
+
confirm: 'Cancel this transfer? Its reservations are released.',
|
|
406
|
+
}),
|
|
407
|
+
k.button('redraft', { label: 'Back to draft' }),
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
sheet: [
|
|
411
|
+
k.group('main', ['kind', 'partner', 'warehouse', 'source', 'destination']),
|
|
412
|
+
k.group('when', [
|
|
413
|
+
'scheduledDate',
|
|
414
|
+
'doneDate',
|
|
415
|
+
'origin',
|
|
416
|
+
'status',
|
|
417
|
+
'availability',
|
|
418
|
+
'backorderOf',
|
|
419
|
+
]),
|
|
420
|
+
k.lines('moves', [
|
|
421
|
+
'product',
|
|
422
|
+
'name',
|
|
423
|
+
'quantity',
|
|
424
|
+
'uom',
|
|
425
|
+
{ field: 'reserved', id: 'move_reserved' },
|
|
426
|
+
{ field: 'quantityDone', id: 'move_done' },
|
|
427
|
+
{ field: 'restrictLot', id: 'move_restrict_lot' },
|
|
428
|
+
]),
|
|
429
|
+
k.lines('lotLines', [
|
|
430
|
+
{ field: 'product', id: 'lot_line_product' },
|
|
431
|
+
{ field: 'lot', id: 'lot_line_lot' },
|
|
432
|
+
{ field: 'lotName', id: 'lot_line_name' },
|
|
433
|
+
{ field: 'quantity', id: 'lot_line_quantity' },
|
|
434
|
+
]),
|
|
435
|
+
k.group('about', ['note'], { columns: 1 }),
|
|
436
|
+
],
|
|
437
|
+
chatter: true,
|
|
438
|
+
})),
|
|
439
|
+
'stock.quant.list': list(StockQuant, {
|
|
440
|
+
columns: ['product', 'location', 'lot', 'quantity', 'reserved', 'available'],
|
|
441
|
+
}),
|
|
442
|
+
'stock.lot.list': list(StockLot, {
|
|
443
|
+
columns: ['name', 'product', 'expiryDate', 'qtyOnHand'],
|
|
444
|
+
}),
|
|
445
|
+
'stock.lot.form': form(StockLot, (k) => ({
|
|
446
|
+
header: { buttons: [] },
|
|
447
|
+
sheet: [
|
|
448
|
+
k.group('main', ['name', 'product', 'expiryDate', 'qtyOnHand']),
|
|
449
|
+
k.lines('quants', [
|
|
450
|
+
{ field: 'location', id: 'lot_quant_location' },
|
|
451
|
+
{ field: 'quantity', id: 'lot_quant_quantity' },
|
|
452
|
+
{ field: 'reserved', id: 'lot_quant_reserved' },
|
|
453
|
+
]),
|
|
454
|
+
k.lines('history', [
|
|
455
|
+
{ field: 'picking', id: 'lot_history_picking' },
|
|
456
|
+
{ field: 'quantity', id: 'lot_history_quantity' },
|
|
457
|
+
]),
|
|
458
|
+
k.group('about', ['note'], { columns: 1 }),
|
|
459
|
+
],
|
|
460
|
+
chatter: true,
|
|
461
|
+
})),
|
|
462
|
+
'stock.lot.line.list': list(StockLotLine, {
|
|
463
|
+
columns: ['picking', 'product', 'lot', 'lotName', 'quantity'],
|
|
464
|
+
}),
|
|
465
|
+
'stock.quant.form': form(StockQuant, (k) => ({
|
|
466
|
+
header: { buttons: [] },
|
|
467
|
+
sheet: [
|
|
468
|
+
k.group('main', ['product', 'location', 'lot']),
|
|
469
|
+
k.group('quantities', ['quantity', 'reserved', 'available']),
|
|
470
|
+
k.lines('reservations', [{ field: 'label', id: 'reservation_label' }]),
|
|
471
|
+
],
|
|
472
|
+
})),
|
|
473
|
+
'stock.reservation.list': list(StockReservation, {
|
|
474
|
+
columns: ['label', 'quant', 'quantity', 'move'],
|
|
475
|
+
}),
|
|
476
|
+
'stock.scrap.list': list(StockScrap, {
|
|
477
|
+
columns: [
|
|
478
|
+
'name',
|
|
479
|
+
'date',
|
|
480
|
+
'product',
|
|
481
|
+
'quantity',
|
|
482
|
+
'reason',
|
|
483
|
+
{ field: 'state', widget: 'badge' },
|
|
484
|
+
],
|
|
485
|
+
}),
|
|
486
|
+
'stock.scrap.form': form(StockScrap, (k) => ({
|
|
487
|
+
header: {
|
|
488
|
+
statusbar: 'state',
|
|
489
|
+
buttons: [
|
|
490
|
+
k.button('validate', {
|
|
491
|
+
primary: true,
|
|
492
|
+
label: 'Scrap',
|
|
493
|
+
confirm: 'Scrap it? The stock leaves for the Scrap location.',
|
|
494
|
+
}),
|
|
495
|
+
k.button('cancel', { label: 'Cancel' }),
|
|
496
|
+
],
|
|
497
|
+
},
|
|
498
|
+
sheet: [
|
|
499
|
+
k.group('main', ['product', 'quantity', 'location', 'lot']),
|
|
500
|
+
k.group('why', ['reason', 'date', 'picking']),
|
|
501
|
+
k.group('about', ['note'], { columns: 1 }),
|
|
502
|
+
],
|
|
503
|
+
chatter: true,
|
|
504
|
+
})),
|
|
505
|
+
'stock.count.list': list(StockCount, {
|
|
506
|
+
columns: ['name', 'location', 'date', 'user', { field: 'state', widget: 'badge' }],
|
|
507
|
+
}),
|
|
508
|
+
'stock.count.form': form(StockCount, (k) => ({
|
|
509
|
+
header: {
|
|
510
|
+
statusbar: 'state',
|
|
511
|
+
buttons: [
|
|
512
|
+
k.button('start', { primary: true, label: 'Start counting' }),
|
|
513
|
+
k.button('apply', {
|
|
514
|
+
primary: true,
|
|
515
|
+
label: 'Apply',
|
|
516
|
+
confirm: 'Apply this count? Stock is adjusted to what was counted.',
|
|
517
|
+
}),
|
|
518
|
+
k.button('cancel', { label: 'Cancel' }),
|
|
519
|
+
k.button('redraft', { label: 'Back to draft' }),
|
|
520
|
+
],
|
|
521
|
+
},
|
|
522
|
+
sheet: [
|
|
523
|
+
k.group('main', ['location', 'date', 'user']),
|
|
524
|
+
k.component('scan', 'stock.Scan'),
|
|
525
|
+
k.lines('lines', [
|
|
526
|
+
{ field: 'product', id: 'count_product' },
|
|
527
|
+
{ field: 'lot', id: 'count_lot' },
|
|
528
|
+
{ field: 'expected', id: 'count_expected' },
|
|
529
|
+
{ field: 'counted', id: 'count_counted' },
|
|
530
|
+
{ field: 'difference', id: 'count_difference' },
|
|
531
|
+
]),
|
|
532
|
+
k.group('about', ['note'], { columns: 1 }),
|
|
533
|
+
],
|
|
534
|
+
chatter: true,
|
|
535
|
+
})),
|
|
536
|
+
'stock.count.line.list': list(StockCountLine, {
|
|
537
|
+
columns: ['count', 'product', 'expected', 'counted', 'difference'],
|
|
538
|
+
}),
|
|
539
|
+
'stock.warehouse.list': list(StockWarehouse, { columns: ['name', 'code', 'address'] }),
|
|
540
|
+
'stock.warehouse.form': form(StockWarehouse, (k) => ({
|
|
541
|
+
header: { buttons: [] },
|
|
542
|
+
sheet: [
|
|
543
|
+
k.group('main', ['name', 'code', 'address']),
|
|
544
|
+
k.lines('locations', [
|
|
545
|
+
{ field: 'name', id: 'location_name' },
|
|
546
|
+
{ field: 'usage', id: 'location_usage' },
|
|
547
|
+
{ field: 'parent', id: 'location_parent' },
|
|
548
|
+
]),
|
|
549
|
+
],
|
|
550
|
+
})),
|
|
551
|
+
'stock.location.list': list(StockLocation, {
|
|
552
|
+
columns: ['fullName', 'usage', 'warehouse'],
|
|
553
|
+
}),
|
|
554
|
+
'stock.location.form': form(StockLocation, (k) => ({
|
|
555
|
+
header: { buttons: [] },
|
|
556
|
+
sheet: [k.group('main', ['name', 'parent', 'warehouse', 'usage', 'fullName'])],
|
|
557
|
+
})),
|
|
558
|
+
'stock.move.list': list(StockMove, {
|
|
559
|
+
columns: ['picking', 'product', 'quantity', 'uom', 'reserved'],
|
|
560
|
+
}),
|
|
561
|
+
},
|
|
562
|
+
search: {
|
|
563
|
+
'stock.picking': search(StockPicking, {
|
|
564
|
+
fields: ['name', 'origin', 'partner.name', 'moves.product.name'],
|
|
565
|
+
filters: {
|
|
566
|
+
open: {
|
|
567
|
+
label: 'To do',
|
|
568
|
+
domain: { state: { in: ['draft', 'confirmed'] } },
|
|
569
|
+
group: 'state',
|
|
570
|
+
},
|
|
571
|
+
ready: { label: 'Ready', domain: { status: 'ready' }, group: 'state' },
|
|
572
|
+
waiting: { label: 'Waiting', domain: { status: 'waiting' }, group: 'state' },
|
|
573
|
+
done: { label: 'Done', domain: { state: 'done' }, group: 'state' },
|
|
574
|
+
receipts: { label: 'Receipts', domain: { kind: 'receipt' }, group: 'kind' },
|
|
575
|
+
deliveries: { label: 'Deliveries', domain: { kind: 'delivery' }, group: 'kind' },
|
|
576
|
+
internal: { label: 'Internal moves', domain: { kind: 'internal' }, group: 'kind' },
|
|
577
|
+
},
|
|
578
|
+
groupBy: ['kind', 'status', 'partner', 'scheduledDate'],
|
|
579
|
+
}),
|
|
580
|
+
'stock.quant': search(StockQuant, {
|
|
581
|
+
fields: ['product.name', 'location.fullName'],
|
|
582
|
+
filters: {
|
|
583
|
+
in_stock: { label: 'In stock', domain: { quantity: { gt: 0 } } },
|
|
584
|
+
reserved: { label: 'Reserved', domain: { reserved: { gt: 0 } } },
|
|
585
|
+
},
|
|
586
|
+
groupBy: ['product', 'location'],
|
|
587
|
+
}),
|
|
588
|
+
'stock.reservation': search(StockReservation, {
|
|
589
|
+
fields: ['label', 'quant.product.name'],
|
|
590
|
+
groupBy: ['quant'],
|
|
591
|
+
}),
|
|
592
|
+
'stock.warehouse': search(StockWarehouse, { fields: ['name', 'code'] }),
|
|
593
|
+
'stock.count': search(StockCount, {
|
|
594
|
+
fields: ['name', 'location.fullName'],
|
|
595
|
+
filters: {
|
|
596
|
+
open: { label: 'To do', domain: { state: { in: ['draft', 'counting'] } } },
|
|
597
|
+
applied: { label: 'Applied', domain: { state: 'done' } },
|
|
598
|
+
},
|
|
599
|
+
groupBy: ['location', 'user'],
|
|
600
|
+
}),
|
|
601
|
+
'stock.scrap': search(StockScrap, {
|
|
602
|
+
fields: ['name', 'product.name'],
|
|
603
|
+
groupBy: ['reason', 'product', 'date'],
|
|
604
|
+
}),
|
|
605
|
+
'stock.count.line': search(StockCountLine, { fields: ['product.name', 'count.name'] }),
|
|
606
|
+
'stock.lot': search(StockLot, {
|
|
607
|
+
fields: ['name', 'product.name'],
|
|
608
|
+
filters: {
|
|
609
|
+
in_stock: { label: 'In stock', domain: { qtyOnHand: { gt: 0 } } },
|
|
610
|
+
},
|
|
611
|
+
groupBy: ['product', 'expiryDate'],
|
|
612
|
+
}),
|
|
613
|
+
'stock.lot.line': search(StockLotLine, {
|
|
614
|
+
fields: ['lot.name', 'product.name', 'picking.name'],
|
|
615
|
+
}),
|
|
616
|
+
'stock.location': search(StockLocation, {
|
|
617
|
+
fields: ['fullName'],
|
|
618
|
+
filters: { internal: { label: 'Internal', domain: { usage: 'internal' } } },
|
|
619
|
+
groupBy: ['warehouse', 'usage'],
|
|
620
|
+
}),
|
|
621
|
+
'stock.move': search(StockMove, { fields: ['product.name', 'picking.name'] }),
|
|
622
|
+
},
|
|
623
|
+
// Products show what they have in stock, where, and what is reserved.
|
|
624
|
+
viewExtensions: [
|
|
625
|
+
{
|
|
626
|
+
view: 'product.product.form',
|
|
627
|
+
operations: [
|
|
628
|
+
{
|
|
629
|
+
append: 'related',
|
|
630
|
+
nodes: [
|
|
631
|
+
stat({
|
|
632
|
+
id: 'product_on_hand',
|
|
633
|
+
label: 'On hand',
|
|
634
|
+
model: 'stock.quant',
|
|
635
|
+
where: { product: { $record: 'id' }, 'location.usage': 'internal' },
|
|
636
|
+
measure: { sum: 'quantity' },
|
|
637
|
+
action: 'stockroom.action_stock',
|
|
638
|
+
}),
|
|
639
|
+
],
|
|
640
|
+
},
|
|
641
|
+
],
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
view: 'product.product.form',
|
|
645
|
+
operations: [
|
|
646
|
+
{
|
|
647
|
+
insertAfter: 'prices',
|
|
648
|
+
nodes: [
|
|
649
|
+
{
|
|
650
|
+
kind: 'group',
|
|
651
|
+
id: 'stock_quantities',
|
|
652
|
+
label: 'Stock',
|
|
653
|
+
children: [
|
|
654
|
+
field({ field: 'tracking', id: 'stock_tracking' }),
|
|
655
|
+
field({ field: 'qtyOnHand', id: 'stock_on_hand' }),
|
|
656
|
+
field({ field: 'qtyReserved', id: 'stock_reserved' }),
|
|
657
|
+
field({ field: 'qtyAvailable', id: 'stock_available' }),
|
|
658
|
+
],
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
},
|
|
662
|
+
],
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
view: 'product.product.list',
|
|
666
|
+
operations: [
|
|
667
|
+
{
|
|
668
|
+
insertAfter: 'listPrice',
|
|
669
|
+
nodes: [field({ field: 'qtyAvailable', id: 'stock_list_available' })],
|
|
670
|
+
},
|
|
671
|
+
],
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
});
|