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.
Files changed (381) hide show
  1. package/dist/account_portal/.kosh/bindings.js +1 -1
  2. package/dist/account_portal/.kosh/schema.d.ts +54 -3
  3. package/dist/account_portal/module.d.ts +359 -6
  4. package/dist/accounting/.kosh/bindings.js +1 -1
  5. package/dist/accounting/.kosh/schema.d.ts +54 -3
  6. package/dist/accounting/index.js +214 -2
  7. package/dist/accounting/module.d.ts +217 -5
  8. package/dist/accounting/module.js +23 -2
  9. package/dist/calendar/.kosh/bindings.d.ts +22 -0
  10. package/dist/calendar/.kosh/bindings.js +15 -0
  11. package/dist/calendar/.kosh/schema.d.ts +795 -0
  12. package/dist/calendar/demo.d.ts +6 -0
  13. package/dist/calendar/demo.js +24 -0
  14. package/dist/calendar/index.d.ts +3 -0
  15. package/dist/calendar/index.js +291 -0
  16. package/dist/calendar/module.d.ts +1705 -0
  17. package/dist/calendar/module.js +180 -0
  18. package/dist/cli/init.js +48 -0
  19. package/dist/cli/templates.d.ts +1 -1
  20. package/dist/cli/templates.js +137 -0
  21. package/dist/contacts/.kosh/bindings.js +1 -1
  22. package/dist/contacts/.kosh/schema.d.ts +78 -3
  23. package/dist/contacts/demo.js +30 -1
  24. package/dist/contacts/index.d.ts +1 -1
  25. package/dist/contacts/index.js +155 -9
  26. package/dist/contacts/module.d.ts +338 -2
  27. package/dist/contacts/module.js +82 -5
  28. package/dist/crm/.kosh/bindings.d.ts +22 -0
  29. package/dist/crm/.kosh/bindings.js +15 -0
  30. package/dist/crm/.kosh/schema.d.ts +799 -0
  31. package/dist/crm/demo.d.ts +6 -0
  32. package/dist/crm/demo.js +45 -0
  33. package/dist/crm/index.d.ts +3 -0
  34. package/dist/crm/index.js +361 -0
  35. package/dist/crm/module.d.ts +1843 -0
  36. package/dist/crm/module.js +207 -0
  37. package/dist/event/.kosh/bindings.d.ts +22 -0
  38. package/dist/event/.kosh/bindings.js +15 -0
  39. package/dist/event/.kosh/schema.d.ts +843 -0
  40. package/dist/event/demo.d.ts +6 -0
  41. package/dist/event/demo.js +65 -0
  42. package/dist/event/index.d.ts +14 -0
  43. package/dist/event/index.js +333 -0
  44. package/dist/event/mails.d.ts +15 -0
  45. package/dist/event/mails.js +112 -0
  46. package/dist/event/module.d.ts +2800 -0
  47. package/dist/event/module.js +323 -0
  48. package/dist/event/web/CheckInBox.d.ts +9 -0
  49. package/dist/event/web/CheckInBox.js +87 -0
  50. package/dist/event/web/index.d.ts +11 -0
  51. package/dist/event/web/index.js +16 -0
  52. package/dist/event/web/messages.d.ts +2 -0
  53. package/dist/event/web/messages.js +23 -0
  54. package/dist/event_account/.kosh/bindings.d.ts +22 -0
  55. package/dist/event_account/.kosh/bindings.js +15 -0
  56. package/dist/event_account/.kosh/schema.d.ts +1639 -0
  57. package/dist/event_account/index.d.ts +3 -0
  58. package/dist/event_account/index.js +28 -0
  59. package/dist/event_account/module.d.ts +6968 -0
  60. package/dist/event_account/module.js +90 -0
  61. package/dist/hr/.kosh/bindings.d.ts +22 -0
  62. package/dist/hr/.kosh/bindings.js +15 -0
  63. package/dist/hr/.kosh/schema.d.ts +878 -0
  64. package/dist/hr/demo.d.ts +6 -0
  65. package/dist/hr/demo.js +60 -0
  66. package/dist/hr/index.d.ts +3 -0
  67. package/dist/hr/index.js +483 -0
  68. package/dist/hr/module.d.ts +2611 -0
  69. package/dist/hr/module.js +350 -0
  70. package/dist/l10n_bd/.kosh/bindings.js +1 -1
  71. package/dist/l10n_bd/.kosh/schema.d.ts +54 -3
  72. package/dist/l10n_bd/module.d.ts +359 -6
  73. package/dist/l10n_in/.kosh/bindings.js +1 -1
  74. package/dist/l10n_in/.kosh/schema.d.ts +54 -3
  75. package/dist/l10n_in/module.d.ts +380 -7
  76. package/dist/maintenance/.kosh/bindings.d.ts +22 -0
  77. package/dist/maintenance/.kosh/bindings.js +15 -0
  78. package/dist/maintenance/.kosh/schema.d.ts +911 -0
  79. package/dist/maintenance/demo.d.ts +6 -0
  80. package/dist/maintenance/demo.js +60 -0
  81. package/dist/maintenance/index.d.ts +3 -0
  82. package/dist/maintenance/index.js +422 -0
  83. package/dist/maintenance/module.d.ts +3545 -0
  84. package/dist/maintenance/module.js +446 -0
  85. package/dist/maintenance_stock/.kosh/bindings.d.ts +22 -0
  86. package/dist/maintenance_stock/.kosh/bindings.js +15 -0
  87. package/dist/maintenance_stock/.kosh/schema.d.ts +1371 -0
  88. package/dist/maintenance_stock/index.d.ts +9 -0
  89. package/dist/maintenance_stock/index.js +52 -0
  90. package/dist/maintenance_stock/module.d.ts +6953 -0
  91. package/dist/maintenance_stock/module.js +192 -0
  92. package/dist/modules-sdk/index.d.ts +1 -1
  93. package/dist/modules-sdk/manifest.d.ts +70 -0
  94. package/dist/modules-sdk/manifest.js +35 -1
  95. package/dist/mrp/.kosh/bindings.d.ts +22 -0
  96. package/dist/mrp/.kosh/bindings.js +15 -0
  97. package/dist/mrp/.kosh/schema.d.ts +1378 -0
  98. package/dist/mrp/demo.d.ts +7 -0
  99. package/dist/mrp/demo.js +42 -0
  100. package/dist/mrp/index.d.ts +3 -0
  101. package/dist/mrp/index.js +392 -0
  102. package/dist/mrp/module.d.ts +8608 -0
  103. package/dist/mrp/module.js +695 -0
  104. package/dist/mrp_account/.kosh/bindings.d.ts +22 -0
  105. package/dist/mrp_account/.kosh/bindings.js +15 -0
  106. package/dist/mrp_account/.kosh/schema.d.ts +2106 -0
  107. package/dist/mrp_account/index.d.ts +3 -0
  108. package/dist/mrp_account/index.js +22 -0
  109. package/dist/mrp_account/module.d.ts +20840 -0
  110. package/dist/mrp_account/module.js +123 -0
  111. package/dist/payment/.kosh/bindings.js +1 -1
  112. package/dist/payment/.kosh/schema.d.ts +54 -3
  113. package/dist/payment/module.d.ts +359 -6
  114. package/dist/portal/.kosh/bindings.js +1 -1
  115. package/dist/portal/.kosh/schema.d.ts +78 -3
  116. package/dist/portal/module.d.ts +166 -2
  117. package/dist/pos/.kosh/bindings.d.ts +22 -0
  118. package/dist/pos/.kosh/bindings.js +15 -0
  119. package/dist/pos/.kosh/schema.d.ts +1690 -0
  120. package/dist/pos/accounting.d.ts +10 -0
  121. package/dist/pos/accounting.js +149 -0
  122. package/dist/pos/demo.d.ts +6 -0
  123. package/dist/pos/demo.js +90 -0
  124. package/dist/pos/index.d.ts +9 -0
  125. package/dist/pos/index.js +349 -0
  126. package/dist/pos/module.d.ts +9636 -0
  127. package/dist/pos/module.js +423 -0
  128. package/dist/pos/routes.d.ts +39 -0
  129. package/dist/pos/routes.js +368 -0
  130. package/dist/pos/web/Register.d.ts +9 -0
  131. package/dist/pos/web/Register.js +252 -0
  132. package/dist/pos/web/index.d.ts +11 -0
  133. package/dist/pos/web/index.js +16 -0
  134. package/dist/pos/web/messages.d.ts +2 -0
  135. package/dist/pos/web/messages.js +87 -0
  136. package/dist/pos_stock/.kosh/bindings.d.ts +22 -0
  137. package/dist/pos_stock/.kosh/bindings.js +15 -0
  138. package/dist/pos_stock/.kosh/schema.d.ts +2015 -0
  139. package/dist/pos_stock/index.d.ts +9 -0
  140. package/dist/pos_stock/index.js +35 -0
  141. package/dist/pos_stock/module.d.ts +11935 -0
  142. package/dist/pos_stock/module.js +115 -0
  143. package/dist/product/.kosh/bindings.js +1 -1
  144. package/dist/product/.kosh/schema.d.ts +51 -1
  145. package/dist/product/index.js +81 -4
  146. package/dist/product/module.d.ts +43 -1
  147. package/dist/product/module.js +9 -2
  148. package/dist/project/.kosh/bindings.js +1 -1
  149. package/dist/project/.kosh/schema.d.ts +54 -3
  150. package/dist/project/index.js +147 -7
  151. package/dist/project/module.d.ts +210 -2
  152. package/dist/project/module.js +52 -5
  153. package/dist/project_portal/.kosh/bindings.js +1 -1
  154. package/dist/project_portal/.kosh/schema.d.ts +54 -3
  155. package/dist/project_portal/module.d.ts +353 -4
  156. package/dist/purchase/.kosh/bindings.js +1 -1
  157. package/dist/purchase/.kosh/schema.d.ts +54 -3
  158. package/dist/purchase/index.js +163 -3
  159. package/dist/purchase/module.d.ts +215 -3
  160. package/dist/purchase/module.js +21 -3
  161. package/dist/purchase_account/.kosh/bindings.js +1 -1
  162. package/dist/purchase_account/.kosh/schema.d.ts +55 -3
  163. package/dist/purchase_account/index.js +26 -1
  164. package/dist/purchase_account/module.d.ts +393 -7
  165. package/dist/purchase_portal/.kosh/bindings.js +1 -1
  166. package/dist/purchase_portal/.kosh/schema.d.ts +54 -3
  167. package/dist/purchase_portal/module.d.ts +366 -5
  168. package/dist/purchase_stock/.kosh/bindings.d.ts +22 -0
  169. package/dist/purchase_stock/.kosh/bindings.js +15 -0
  170. package/dist/purchase_stock/.kosh/schema.d.ts +1310 -0
  171. package/dist/purchase_stock/index.d.ts +7 -0
  172. package/dist/purchase_stock/index.js +91 -0
  173. package/dist/purchase_stock/module.d.ts +6763 -0
  174. package/dist/purchase_stock/module.js +144 -0
  175. package/dist/purchase_stock_account/.kosh/bindings.d.ts +22 -0
  176. package/dist/purchase_stock_account/.kosh/bindings.js +15 -0
  177. package/dist/purchase_stock_account/.kosh/schema.d.ts +1959 -0
  178. package/dist/purchase_stock_account/index.d.ts +3 -0
  179. package/dist/purchase_stock_account/index.js +24 -0
  180. package/dist/purchase_stock_account/module.d.ts +35366 -0
  181. package/dist/purchase_stock_account/module.js +162 -0
  182. package/dist/recruitment/.kosh/bindings.d.ts +22 -0
  183. package/dist/recruitment/.kosh/bindings.js +15 -0
  184. package/dist/recruitment/.kosh/schema.d.ts +990 -0
  185. package/dist/recruitment/demo.d.ts +6 -0
  186. package/dist/recruitment/demo.js +45 -0
  187. package/dist/recruitment/index.d.ts +3 -0
  188. package/dist/recruitment/index.js +385 -0
  189. package/dist/recruitment/module.d.ts +3247 -0
  190. package/dist/recruitment/module.js +193 -0
  191. package/dist/recruitment/web/HireButton.d.ts +9 -0
  192. package/dist/recruitment/web/HireButton.js +32 -0
  193. package/dist/recruitment/web/index.d.ts +11 -0
  194. package/dist/recruitment/web/index.js +16 -0
  195. package/dist/recruitment/web/messages.d.ts +2 -0
  196. package/dist/recruitment/web/messages.js +19 -0
  197. package/dist/reporting/documents.d.ts +5 -0
  198. package/dist/reporting/documents.js +28 -1
  199. package/dist/reporting/index.d.ts +1 -1
  200. package/dist/reporting/index.js +4 -2
  201. package/dist/reporting/models.js +9 -0
  202. package/dist/reporting/overviews.d.ts +16 -0
  203. package/dist/reporting/overviews.js +56 -0
  204. package/dist/reporting/routes-documents.js +1 -1
  205. package/dist/reporting/routes.js +138 -80
  206. package/dist/reporting/web/DashboardView.d.ts +11 -0
  207. package/dist/reporting/web/DashboardView.js +2 -2
  208. package/dist/reporting/web/DesignerView.js +5 -0
  209. package/dist/reporting/web/Overview.d.ts +9 -0
  210. package/dist/reporting/web/Overview.js +53 -0
  211. package/dist/reporting/web/index.d.ts +1 -0
  212. package/dist/reporting/web/index.js +4 -1
  213. package/dist/reporting/web/messages.js +9 -0
  214. package/dist/sale_account/.kosh/bindings.js +1 -1
  215. package/dist/sale_account/.kosh/schema.d.ts +59 -3
  216. package/dist/sale_account/index.js +22 -1
  217. package/dist/sale_account/module.d.ts +461 -7
  218. package/dist/sale_portal/.kosh/bindings.js +1 -1
  219. package/dist/sale_portal/.kosh/schema.d.ts +58 -3
  220. package/dist/sale_portal/module.d.ts +434 -5
  221. package/dist/sale_project/.kosh/bindings.js +1 -1
  222. package/dist/sale_project/.kosh/schema.d.ts +60 -3
  223. package/dist/sale_project/module.d.ts +476 -6
  224. package/dist/sale_stock/.kosh/bindings.d.ts +22 -0
  225. package/dist/sale_stock/.kosh/bindings.js +15 -0
  226. package/dist/sale_stock/.kosh/schema.d.ts +1228 -0
  227. package/dist/sale_stock/index.d.ts +7 -0
  228. package/dist/sale_stock/index.js +84 -0
  229. package/dist/sale_stock/module.d.ts +6791 -0
  230. package/dist/sale_stock/module.js +146 -0
  231. package/dist/sales/.kosh/bindings.js +1 -1
  232. package/dist/sales/.kosh/schema.d.ts +58 -3
  233. package/dist/sales/index.js +191 -4
  234. package/dist/sales/module.d.ts +355 -3
  235. package/dist/sales/module.js +78 -3
  236. package/dist/server/api/metadata.d.ts +5 -0
  237. package/dist/server/api/metadata.js +5 -0
  238. package/dist/server/api/rest.js +64 -1
  239. package/dist/server/api/views.js +1 -0
  240. package/dist/server/app-settings.d.ts +7 -0
  241. package/dist/server/app-settings.js +10 -0
  242. package/dist/server/auth/base.js +9 -0
  243. package/dist/server/index.d.ts +1 -0
  244. package/dist/server/index.js +1 -0
  245. package/dist/settings/app-settings.d.ts +2 -0
  246. package/dist/settings/app-settings.js +518 -0
  247. package/dist/settings/index.d.ts +1 -0
  248. package/dist/settings/index.js +15 -0
  249. package/dist/settings/people.js +29 -5
  250. package/dist/settings/web/AppSettingsPage.d.ts +11 -0
  251. package/dist/settings/web/AppSettingsPage.js +210 -0
  252. package/dist/settings/web/OverviewPage.js +16 -3
  253. package/dist/settings/web/PeoplePage.js +20 -6
  254. package/dist/settings/web/index.d.ts +1 -0
  255. package/dist/settings/web/index.js +3 -0
  256. package/dist/settings/web/messages.js +118 -2
  257. package/dist/stock/.kosh/bindings.d.ts +22 -0
  258. package/dist/stock/.kosh/bindings.js +15 -0
  259. package/dist/stock/.kosh/schema.d.ts +1147 -0
  260. package/dist/stock/demo.d.ts +7 -0
  261. package/dist/stock/demo.js +55 -0
  262. package/dist/stock/index.d.ts +3 -0
  263. package/dist/stock/index.js +674 -0
  264. package/dist/stock/module.d.ts +6330 -0
  265. package/dist/stock/module.js +1325 -0
  266. package/dist/stock/web/ScanBox.d.ts +8 -0
  267. package/dist/stock/web/ScanBox.js +90 -0
  268. package/dist/stock/web/index.d.ts +11 -0
  269. package/dist/stock/web/index.js +16 -0
  270. package/dist/stock/web/messages.d.ts +2 -0
  271. package/dist/stock/web/messages.js +25 -0
  272. package/dist/stock_account/.kosh/bindings.d.ts +22 -0
  273. package/dist/stock_account/.kosh/bindings.js +15 -0
  274. package/dist/stock_account/.kosh/schema.d.ts +1875 -0
  275. package/dist/stock_account/index.d.ts +3 -0
  276. package/dist/stock_account/index.js +130 -0
  277. package/dist/stock_account/module.d.ts +10655 -0
  278. package/dist/stock_account/module.js +339 -0
  279. package/dist/storage/attachments.d.ts +5 -0
  280. package/dist/storage/attachments.js +12 -1
  281. package/dist/storage/models.js +3 -0
  282. package/dist/storage/routes.js +13 -2
  283. package/dist/todo/.kosh/bindings.d.ts +22 -0
  284. package/dist/todo/.kosh/bindings.js +15 -0
  285. package/dist/todo/.kosh/schema.d.ts +732 -0
  286. package/dist/todo/demo.d.ts +6 -0
  287. package/dist/todo/demo.js +35 -0
  288. package/dist/todo/index.d.ts +3 -0
  289. package/dist/todo/index.js +187 -0
  290. package/dist/todo/module.d.ts +1180 -0
  291. package/dist/todo/module.js +130 -0
  292. package/dist/trade_finance/.kosh/bindings.d.ts +22 -0
  293. package/dist/trade_finance/.kosh/bindings.js +15 -0
  294. package/dist/trade_finance/.kosh/schema.d.ts +884 -0
  295. package/dist/trade_finance/demo.d.ts +6 -0
  296. package/dist/trade_finance/demo.js +63 -0
  297. package/dist/trade_finance/index.d.ts +3 -0
  298. package/dist/trade_finance/index.js +413 -0
  299. package/dist/trade_finance/module.d.ts +3779 -0
  300. package/dist/trade_finance/module.js +505 -0
  301. package/dist/trade_finance_account/.kosh/bindings.d.ts +22 -0
  302. package/dist/trade_finance_account/.kosh/bindings.js +15 -0
  303. package/dist/trade_finance_account/.kosh/schema.d.ts +1711 -0
  304. package/dist/trade_finance_account/index.d.ts +3 -0
  305. package/dist/trade_finance_account/index.js +92 -0
  306. package/dist/trade_finance_account/module.d.ts +7928 -0
  307. package/dist/trade_finance_account/module.js +244 -0
  308. package/dist/trade_finance_purchase/.kosh/bindings.d.ts +22 -0
  309. package/dist/trade_finance_purchase/.kosh/bindings.js +15 -0
  310. package/dist/trade_finance_purchase/.kosh/schema.d.ts +1153 -0
  311. package/dist/trade_finance_purchase/index.d.ts +8 -0
  312. package/dist/trade_finance_purchase/index.js +50 -0
  313. package/dist/trade_finance_purchase/module.d.ts +4252 -0
  314. package/dist/trade_finance_purchase/module.js +44 -0
  315. package/dist/trade_finance_sale/.kosh/bindings.d.ts +22 -0
  316. package/dist/trade_finance_sale/.kosh/bindings.js +15 -0
  317. package/dist/trade_finance_sale/.kosh/schema.d.ts +1071 -0
  318. package/dist/trade_finance_sale/index.d.ts +8 -0
  319. package/dist/trade_finance_sale/index.js +50 -0
  320. package/dist/trade_finance_sale/module.d.ts +4280 -0
  321. package/dist/trade_finance_sale/module.js +44 -0
  322. package/dist/ui/api.d.ts +2 -1
  323. package/dist/ui/api.js +2 -1
  324. package/dist/ui/app.js +2 -1
  325. package/dist/ui/components/AppIcon.js +23 -1
  326. package/dist/ui/components/primitives.d.ts +2 -0
  327. package/dist/ui/components/primitives.js +7 -1
  328. package/dist/ui/i18n/messages.d.ts +23 -0
  329. package/dist/ui/i18n/messages.js +38 -0
  330. package/dist/ui/index.d.ts +1 -0
  331. package/dist/ui/index.js +1 -0
  332. package/dist/ui/offline/queue.d.ts +5 -1
  333. package/dist/ui/offline/queue.js +2 -0
  334. package/dist/ui/registry.d.ts +5 -0
  335. package/dist/ui/shell/Home.js +55 -4
  336. package/dist/ui/views/FormView.js +98 -17
  337. package/dist/ui/views/KanbanView.d.ts +2 -0
  338. package/dist/ui/views/KanbanView.js +32 -3
  339. package/dist/ui/views/ListView.js +108 -11
  340. package/dist/ui/views/StatsRow.d.ts +14 -0
  341. package/dist/ui/views/StatsRow.js +88 -0
  342. package/dist/ui/views/widgets.d.ts +2 -1
  343. package/dist/ui/views/widgets.js +194 -1
  344. package/dist/views/builders.d.ts +19 -2
  345. package/dist/views/builders.js +21 -1
  346. package/dist/views/condition.d.ts +6 -0
  347. package/dist/views/condition.js +20 -0
  348. package/dist/views/documents.d.ts +8 -0
  349. package/dist/views/extend.d.ts +2 -2
  350. package/dist/views/extend.js +11 -1
  351. package/dist/views/index.d.ts +2 -2
  352. package/dist/views/index.js +2 -2
  353. package/dist/views/types.d.ts +52 -5
  354. package/dist/views/validate.js +39 -1
  355. package/dist/website/.kosh/bindings.d.ts +22 -0
  356. package/dist/website/.kosh/bindings.js +15 -0
  357. package/dist/website/.kosh/schema.d.ts +881 -0
  358. package/dist/website/demo.d.ts +6 -0
  359. package/dist/website/demo.js +115 -0
  360. package/dist/website/index.d.ts +9 -0
  361. package/dist/website/index.js +250 -0
  362. package/dist/website/module.d.ts +2987 -0
  363. package/dist/website/module.js +281 -0
  364. package/dist/website/render.d.ts +45 -0
  365. package/dist/website/render.js +102 -0
  366. package/dist/website/routes.d.ts +12 -0
  367. package/dist/website/routes.js +246 -0
  368. package/dist/website/web/PagePreview.d.ts +7 -0
  369. package/dist/website/web/PagePreview.js +33 -0
  370. package/dist/website/web/index.d.ts +11 -0
  371. package/dist/website/web/index.js +16 -0
  372. package/dist/website/web/messages.d.ts +2 -0
  373. package/dist/website/web/messages.js +15 -0
  374. package/dist/website_crm/.kosh/bindings.d.ts +22 -0
  375. package/dist/website_crm/.kosh/bindings.js +15 -0
  376. package/dist/website_crm/.kosh/schema.d.ts +966 -0
  377. package/dist/website_crm/index.d.ts +3 -0
  378. package/dist/website_crm/index.js +39 -0
  379. package/dist/website_crm/module.d.ts +2955 -0
  380. package/dist/website_crm/module.js +44 -0
  381. 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
+ });