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,192 @@
1
+ /**
2
+ * The data layer of the Asset Care ↔ Stockroom bridge (RFC 0021, Asset Care step 2): a maintenance order lists the
3
+ * spare parts it uses; starting it reserves them in a transfer from the main stock to the Maintenance location,
4
+ * finishing it consumes them (refused while some are short), cancelling it releases them. Parts cost what they cost
5
+ * in stock; with `stock_account` they leave Inventory as a stock adjustment.
6
+ */
7
+ import { maintenanceShutro } from '../maintenance/index.js';
8
+ import { productShutro } from '../product/index.js';
9
+ import { orm } from '../server/orm.js';
10
+ import { defaultLocations, inProductUnit, stockShutro } from '../stock/index.js';
11
+ import { compute, defineModel, defineModule, extendModel, f, onchange, record, } from './.kosh/bindings.js';
12
+ const zero = orm.toDecimal(0);
13
+ export const MaintenancePart = defineModel('maintenance.request.part', {
14
+ label: 'Spare part',
15
+ order: ['id asc'],
16
+ access: {
17
+ 'maintenance.user': ['read', 'write', 'create', 'unlink'],
18
+ 'maintenance.manager': ['read', 'write', 'create', 'unlink', 'export'],
19
+ },
20
+ fields: {
21
+ request: f.many2one('maintenance.request', { required: true, ondelete: 'cascade' }),
22
+ product: f.many2one('product.product', { required: true, ondelete: 'restrict' }),
23
+ quantity: f.decimal({ scale: 4, required: true, default: '1' }),
24
+ uom: f.many2one('uom.uom', { label: 'Unit' }),
25
+ /** The quantity at the product's cost (in the product's unit). */
26
+ cost: f.decimal({
27
+ scale: 2,
28
+ store: true,
29
+ label: 'Cost',
30
+ ...compute('maintenance.request.part', 'cost', [
31
+ 'quantity',
32
+ 'uom.ratio',
33
+ 'uom.category',
34
+ 'uom.name',
35
+ 'uom.rounding',
36
+ 'product.standardPrice',
37
+ 'product.uom.ratio',
38
+ 'product.uom.category',
39
+ 'product.uom.name',
40
+ 'product.uom.rounding',
41
+ ], (parts) => {
42
+ for (const p of parts)
43
+ p.cost = inProductUnit(p.quantity, p.uom ?? null, p.product.uom ?? null)
44
+ .times(p.product.standardPrice)
45
+ .toDecimalPlaces(2);
46
+ }),
47
+ }),
48
+ },
49
+ onchange: {
50
+ product: onchange('maintenance.request.part', async (d) => {
51
+ const p = await d.record('product');
52
+ if (p?.uom)
53
+ d.set('uom', p.uom.id);
54
+ }),
55
+ },
56
+ sqlConstraints: {
57
+ positive: { check: orm.sql `quantity > 0`, message: 'A part is used in a positive quantity.' },
58
+ },
59
+ });
60
+ export const RequestParts = extendModel('maintenance.request', {
61
+ fields: {
62
+ parts: f.one2many('maintenance.request.part', 'request', { label: 'Spare parts' }),
63
+ partsTransfer: f.many2one('stock.picking', { ondelete: 'set null', label: 'Parts transfer' }),
64
+ partsCost: f.decimal({
65
+ scale: 2,
66
+ store: true,
67
+ label: 'Parts cost',
68
+ ...compute('maintenance.request', 'partsCost', ['parts.cost'], (requests) => {
69
+ for (const r of requests)
70
+ r.partsCost = [...r.parts].reduce((s, p) => s.plus(p.cost ?? zero), zero);
71
+ }),
72
+ }),
73
+ },
74
+ overrides: {
75
+ started: async function (next) {
76
+ await next();
77
+ await reserveParts(this);
78
+ },
79
+ finishing: async function (next) {
80
+ await next();
81
+ await consumeParts(this);
82
+ },
83
+ cancelled: async function (next) {
84
+ await next();
85
+ await releaseParts(this);
86
+ },
87
+ },
88
+ });
89
+ /** The orders' parts transfers (made when missing), reserved; as the system (technicians need no stock rights). */
90
+ async function reserveParts(requests) {
91
+ const env = requests.env;
92
+ await env.asSuperuser({ reason: 'maintenance parts' }, async (su) => {
93
+ const maintenance = (await su
94
+ .model('stock.location')
95
+ .search({ where: { usage: 'adjustment', name: 'Maintenance' }, limit: 1 })).ids[0];
96
+ if (maintenance === undefined)
97
+ return;
98
+ for (const r of await su
99
+ .model('maintenance.request')
100
+ .browse(requests.ids)
101
+ .load({ parts: true, partsTransfer: true })) {
102
+ if (r.parts.length === 0)
103
+ continue;
104
+ const transfer = r.partsTransfer;
105
+ if (transfer === null || transfer.state === 'cancel') {
106
+ const from = (await defaultLocations(su, 'internal', null, r.company.id)).source;
107
+ if (from === null)
108
+ continue;
109
+ const made = await su.model('stock.picking').create([
110
+ {
111
+ kind: 'adjustment',
112
+ company: r.company.id,
113
+ source: from,
114
+ destination: maintenance,
115
+ origin: r.name,
116
+ moves: {
117
+ create: [...r.parts].map((p) => ({
118
+ product: p.product.id,
119
+ quantity: p.quantity,
120
+ uom: p.uom?.id ?? null,
121
+ })),
122
+ },
123
+ },
124
+ ]);
125
+ await made.confirm();
126
+ await su
127
+ .model('maintenance.request')
128
+ .browse([r.id])
129
+ .write({ partsTransfer: made.ids[0] ?? null });
130
+ continue;
131
+ }
132
+ if (transfer.state === 'confirmed')
133
+ await su.model('stock.picking').browse([transfer.id]).reserve();
134
+ }
135
+ });
136
+ }
137
+ /** The parts consumed: their transfer validated, refused while some are short. */
138
+ async function consumeParts(requests) {
139
+ await reserveParts(requests);
140
+ const env = requests.env;
141
+ await env.asSuperuser({ reason: 'maintenance parts used' }, async (su) => {
142
+ for (const r of await su
143
+ .model('maintenance.request')
144
+ .browse(requests.ids)
145
+ .load({ partsTransfer: { moves: { product: true } } })) {
146
+ const t = r.partsTransfer;
147
+ if (t === null || t.state === 'done' || t.state === 'cancel')
148
+ continue;
149
+ if (t.availability !== 'full') {
150
+ const short = [...t.moves]
151
+ .filter((m) => (m.reserved ?? zero).lt(m.productQty ?? zero))
152
+ .map((m) => `${m.product.name} (${(m.productQty ?? zero).minus(m.reserved ?? zero).toString()})`);
153
+ throw new orm.ValidationError('maintenance.request', ['parts'], `Parts are short: ${short.join(', ')}.`, 'Wait for them to come in, or use fewer.');
154
+ }
155
+ await su.model('stock.picking').browse([t.id]).validate();
156
+ }
157
+ });
158
+ }
159
+ /** The parts released: their transfer cancelled. */
160
+ async function releaseParts(requests) {
161
+ const env = requests.env;
162
+ await env.asSuperuser({ reason: 'maintenance parts released' }, async (su) => {
163
+ for (const r of await su
164
+ .model('maintenance.request')
165
+ .browse(requests.ids)
166
+ .load({ partsTransfer: true })) {
167
+ const t = r.partsTransfer;
168
+ if (t !== null && (t.state === 'draft' || t.state === 'confirmed'))
169
+ await su
170
+ .model('stock.picking')
171
+ .browse([t.id])
172
+ .cancel();
173
+ }
174
+ });
175
+ }
176
+ export const maintenanceStockShutro = defineModule({
177
+ name: 'maintenance_stock',
178
+ version: '0.1.0',
179
+ depends: [maintenanceShutro, stockShutro, productShutro],
180
+ groups: [
181
+ orm.defineGroup({
182
+ code: 'maintenance_stock.user',
183
+ label: 'Maintenance with spare parts',
184
+ implies: ['maintenance.user', 'product.user'],
185
+ }),
186
+ ],
187
+ models: [MaintenancePart],
188
+ extensions: [RequestParts],
189
+ data: [
190
+ record('stock.location', 'location_maintenance', { name: 'Maintenance', usage: 'adjustment', company: null }, { noupdate: true }),
191
+ ],
192
+ });
@@ -6,5 +6,5 @@ export { type AppChange, type AppPlan, AppPlanError, type AppReason, type AppSta
6
6
  export { idByName, maybeIdByName } from './demo.js';
7
7
  export { ModuleDefinitionError, ModuleLoadError } from './errors.js';
8
8
  export { type LoadedModules, type LoadOptions, loadModules } from './loader.js';
9
- export { type AccessLevel, type ApprovalLevelSpec, type ApprovalSpec, type AppSpec, type AutomationActionSpec, type AutomationRuleSpec, type DemoContext, type DemoUser, type DocumentSpec, defineModule, type EventSpec, type ImportTemplateSpec, type InboundAliasSpec, type InboundCall, type InboundWebhookSpec, type KoshModule, type LocalizationSpec, type MenuSpec, type ModuleHooks, type ModuleInput, type PortalActionSpec, type PortalDocumentSpec, type ShutroModuleShape, } from './manifest.js';
9
+ export { type AccessLevel, type ApprovalLevelSpec, type ApprovalSpec, type AppSpec, type AutomationActionSpec, type AutomationRuleSpec, type DemoContext, type DemoUser, type DocumentSpec, defineModule, type EventSpec, type ImportTemplateSpec, type InboundAliasSpec, type InboundCall, type InboundWebhookSpec, type KoshModule, type LocalizationSpec, type MenuSpec, type ModuleHooks, type ModuleInput, type PortalActionSpec, type PortalDocumentSpec, type SettingFieldSpec, type SettingsSectionSpec, type SettingsSpec, type ShutroModuleShape, } from './manifest.js';
10
10
  export { compareVersions, satisfies } from './semver.js';
@@ -415,12 +415,16 @@ export interface ModuleInput {
415
415
  readonly events?: readonly EventSpec[];
416
416
  /** Endpoints the module receives calls on from outside (RFC 0017 §5.4). */
417
417
  readonly inboundWebhooks?: readonly InboundWebhookSpec[];
418
+ /** The app's own settings, shown in Settings › App settings (RFC 0020). */
419
+ readonly settings?: SettingsSpec;
418
420
  /** What the module shows in the customer and vendor portal (RFC 0015), when `portal` is installed. */
419
421
  readonly portal?: {
420
422
  readonly documents: readonly PortalDocumentSpec[];
421
423
  };
422
424
  /** Import templates for the module's models (RFC 0014 §5.4), offered when `import` is installed. */
423
425
  readonly importTemplates?: readonly ImportTemplateSpec[];
426
+ /** The app's overview page: KPIs, charts and lists on its first menu (RFC 0022 §3.2). Needs `reporting`. */
427
+ readonly overview?: OverviewSpec;
424
428
  /**
425
429
  * Server routes of this module (admin APIs, custom endpoints). Called once at startup with the server context
426
430
  * (`ModuleContext` of `shutro-erp`); typed by the server, so modules declare the parameter type they use.
@@ -430,7 +434,73 @@ export interface ModuleInput {
430
434
  /** Translations per locale, loaded lazily. */
431
435
  readonly i18n?: Readonly<Record<string, () => Promise<unknown>>>;
432
436
  }
437
+ /**
438
+ * A card of an app's overview (RFC 0022 §3.2): a live report query within the viewer's rules — a KPI (with the
439
+ * change against the previous period or last year), a chart, a small pivot, or the top records.
440
+ */
441
+ export interface OverviewCardSpec {
442
+ readonly id: string;
443
+ readonly title: string;
444
+ readonly kind: 'kpi' | 'chart' | 'pivot' | 'list';
445
+ readonly model: string;
446
+ /** `count`, or `op:field` (`sum:amountTotal`, `avg:amountTotal`). */
447
+ readonly measure: string;
448
+ readonly groupBy?: string;
449
+ readonly filter?: Readonly<Record<string, unknown>>;
450
+ /** KPIs: this month against the previous one, or the same month last year, over this date field. */
451
+ readonly comparison?: {
452
+ readonly field: string;
453
+ readonly mode: 'previous' | 'yoy';
454
+ };
455
+ readonly chart?: 'bar' | 'line' | 'area' | 'pie';
456
+ /** Width in twelfths of the page. */
457
+ readonly w: 3 | 4 | 6 | 12;
458
+ }
459
+ /**
460
+ * An app's overview page (RFC 0022 §3.2): installed by `reporting` as a shared dashboard keyed by the module, and
461
+ * opened by the app's first menu (`<module>.action_overview`, generated). The module depends on `reporting`.
462
+ */
463
+ export interface OverviewSpec {
464
+ readonly cards: readonly OverviewCardSpec[];
465
+ }
433
466
  /** A defined module: frozen, with its name and version taken from the Shutro module. */
467
+ /**
468
+ * A setting (RFC 0020 §3.1). In a `company` section, `key` names a `res.company` field the module adds with
469
+ * `extendModel`: its type, label and default come from the field; `help`, bounds and `visibleWhen` add to it. In an
470
+ * `installation` section, the setting is a key / value of its own: `type` and `label` are required.
471
+ */
472
+ export interface SettingFieldSpec {
473
+ readonly key: string;
474
+ readonly type?: 'boolean' | 'integer' | 'decimal' | 'char' | 'text' | 'selection' | 'date';
475
+ readonly label?: string;
476
+ readonly help?: string;
477
+ readonly default?: string | number | boolean | null;
478
+ readonly min?: number;
479
+ readonly max?: number;
480
+ /** Selection options (installation settings): value → label. */
481
+ readonly options?: Readonly<Record<string, string>>;
482
+ /** Shown only when another setting of the section has this value. */
483
+ readonly visibleWhen?: {
484
+ readonly key: string;
485
+ readonly equals: string | number | boolean;
486
+ };
487
+ }
488
+ /** A section of an app's settings (RFC 0020 §3.1). */
489
+ export interface SettingsSectionSpec {
490
+ readonly key: string;
491
+ readonly label: string;
492
+ readonly description?: string;
493
+ /** Words the Settings search also finds it by. */
494
+ readonly keywords?: string;
495
+ /** Per company (`res.company` fields) or for the whole installation. */
496
+ readonly scope: 'company' | 'installation';
497
+ /** Groups whose holders may change it; Administrators always may. Empty: administrators only. */
498
+ readonly editors?: readonly string[];
499
+ readonly fields: readonly SettingFieldSpec[];
500
+ }
501
+ export interface SettingsSpec {
502
+ readonly sections: readonly SettingsSectionSpec[];
503
+ }
434
504
  export interface KoshModule extends Omit<ModuleInput, 'depends'> {
435
505
  readonly name: string;
436
506
  readonly version: string;
@@ -95,12 +95,46 @@ export function defineModule(input) {
95
95
  if (template.columns.length === 0)
96
96
  fail(`import template '${template.key}' has no columns.`, 'List the columns of the file.');
97
97
  }
98
+ // The overview (RFC 0022 §3.2): an action and a menu of its own, generated; reporting installs the dashboard.
99
+ const overviewActions = {};
100
+ const overviewMenus = [];
101
+ if (input.overview !== undefined) {
102
+ if (input.app === undefined)
103
+ fail('declares an overview without an app.', 'An overview is the first page of an app.');
104
+ if (!(input.depends ?? []).some((d) => d.name === 'reporting'))
105
+ fail('declares an overview without depending on reporting.', "Add `reporting` (from '../reporting/index.js') to `depends`.");
106
+ if (input.overview.cards.length === 0)
107
+ fail('declares an overview with no cards.', 'Give at least one KPI, chart, pivot or list card.');
108
+ const cardIds = new Set();
109
+ for (const card of input.overview.cards) {
110
+ if (!LEVEL.test(card.id) || cardIds.has(card.id))
111
+ fail(`overview card id '${card.id}' is not a unique snake_case name.`, "Use e.g. id: 'sales_month'.");
112
+ cardIds.add(card.id);
113
+ if (!/^(count|(sum|avg|min|max):[A-Za-z_][A-Za-z0-9_]*)$/.test(card.measure))
114
+ fail(`overview card '${card.id}' has the measure '${card.measure}'.`, "Use 'count' or 'sum:field'.");
115
+ }
116
+ overviewActions[`${name}.action_overview`] = {
117
+ type: 'client',
118
+ page: 'reporting.Overview',
119
+ label: 'Overview',
120
+ };
121
+ const root = (input.menus ?? []).find((menu) => menu.parent === undefined && menu.app !== undefined);
122
+ if (root !== undefined)
123
+ overviewMenus.push({
124
+ id: `${name}.overview`,
125
+ parent: root.id,
126
+ label: 'Overview',
127
+ action: `${name}.action_overview`,
128
+ sequence: 0,
129
+ });
130
+ }
98
131
  return Object.freeze({
99
132
  ...input,
100
133
  name,
101
134
  version: input.shutro.version,
102
135
  depends: Object.freeze([...(input.depends ?? [])]),
103
136
  accessLevels: Object.freeze({ ...input.accessLevels }),
104
- menus: Object.freeze([...(input.menus ?? [])]),
137
+ actions: Object.freeze({ ...overviewActions, ...(input.actions ?? {}) }),
138
+ menus: Object.freeze([...(input.menus ?? []), ...overviewMenus]),
105
139
  });
106
140
  }
@@ -0,0 +1,22 @@
1
+ export { defineModel, defineModule, extendModel, f, replace } from '../../server/orm.js';
2
+ import { type DefinitionHelpers } from '../../server/orm.js';
3
+ import type { DefaultLoaded, Env as CoreEnv, RecordSet as CoreRecordSet, Shutro as CoreShutro } from '../../server/orm.js';
4
+ import type { SchemaView } from './schema.js';
5
+ export type { SchemaView };
6
+ /** Every model visible in this view. */
7
+ export type ModelName = keyof SchemaView & string;
8
+ /** `Env` typed to this view. */
9
+ export type Env = CoreEnv<SchemaView>;
10
+ /** `Shutro` typed to this view. */
11
+ export type Shutro = CoreShutro<SchemaView>;
12
+ /** A recordset of `M`, with the default loaded shape unless `L` is given. */
13
+ export type Records<M extends ModelName, L = DefaultLoaded<SchemaView, M>> = CoreRecordSet<SchemaView, M, L>;
14
+ export declare const compute: DefinitionHelpers<SchemaView>['compute'];
15
+ export declare const check: DefinitionHelpers<SchemaView>['check'];
16
+ export declare const onchange: DefinitionHelpers<SchemaView>['onchange'];
17
+ export declare const records: DefinitionHelpers<SchemaView>['records'];
18
+ export declare const method: DefinitionHelpers<SchemaView>['method'];
19
+ /** Module data (RFC 0017): records, overrides of dependencies' records, and references, typed like creates. */
20
+ export declare const record: DefinitionHelpers<SchemaView>['record'];
21
+ export declare const override: DefinitionHelpers<SchemaView>['override'];
22
+ export declare const ref: DefinitionHelpers<SchemaView>['ref'];
@@ -0,0 +1,15 @@
1
+ // GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: ea6308794cf1f163
2
+ // Bindings of module `mrp`: import the definition API from here to get types scoped to what it can see.
3
+ export { defineModel, defineModule, extendModel, f, replace } from '../../server/orm.js';
4
+ import { definitions } from '../../server/orm.js';
5
+ /** Definition callbacks typed against this module's view: no casts in computes, checks, onchange, methods. */
6
+ const helpers = definitions();
7
+ export const compute = helpers.compute;
8
+ export const check = helpers.check;
9
+ export const onchange = helpers.onchange;
10
+ export const records = helpers.records;
11
+ export const method = helpers.method;
12
+ /** Module data (RFC 0017): records, overrides of dependencies' records, and references, typed like creates. */
13
+ export const record = helpers.record;
14
+ export const override = helpers.override;
15
+ export const ref = helpers.ref;