shutro-erp 0.3.5 → 0.3.7

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 (768) hide show
  1. package/dist/account_asset/.kosh/bindings.js +15 -0
  2. package/dist/{mrp_account → account_asset}/.kosh/schema.d.ts +785 -614
  3. package/dist/account_asset/board.d.ts +61 -0
  4. package/dist/account_asset/board.js +86 -0
  5. package/dist/account_asset/books.d.ts +42 -0
  6. package/dist/account_asset/books.js +398 -0
  7. package/dist/account_asset/demo.d.ts +7 -0
  8. package/dist/account_asset/demo.js +72 -0
  9. package/dist/account_asset/i18n/bn.d.ts +2 -0
  10. package/dist/account_asset/i18n/bn.js +97 -0
  11. package/dist/account_asset/index.d.ts +9 -0
  12. package/dist/account_asset/index.js +337 -0
  13. package/dist/account_asset/module.d.ts +11076 -0
  14. package/dist/account_asset/module.js +230 -0
  15. package/dist/account_budget/.kosh/bindings.js +15 -0
  16. package/dist/account_budget/.kosh/schema.d.ts +2841 -0
  17. package/dist/account_budget/budget.d.ts +5 -0
  18. package/dist/account_budget/budget.js +142 -0
  19. package/dist/account_budget/demo.d.ts +6 -0
  20. package/dist/account_budget/demo.js +30 -0
  21. package/dist/account_budget/i18n/bn.d.ts +2 -0
  22. package/dist/account_budget/i18n/bn.js +63 -0
  23. package/dist/account_budget/index.d.ts +4 -0
  24. package/dist/account_budget/index.js +237 -0
  25. package/dist/account_budget/module.d.ts +27289 -0
  26. package/dist/account_budget/module.js +182 -0
  27. package/dist/account_portal/.kosh/bindings.js +1 -1
  28. package/dist/account_portal/.kosh/schema.d.ts +651 -10
  29. package/dist/account_portal/i18n/bn.d.ts +2 -0
  30. package/dist/account_portal/i18n/bn.js +6 -0
  31. package/dist/account_portal/index.js +2 -0
  32. package/dist/account_portal/module.d.ts +5212 -1592
  33. package/dist/accounting/.kosh/bindings.js +1 -1
  34. package/dist/accounting/.kosh/schema.d.ts +651 -10
  35. package/dist/accounting/closing.js +1 -0
  36. package/dist/accounting/fiscal.d.ts +578 -0
  37. package/dist/accounting/fiscal.js +401 -0
  38. package/dist/accounting/followups.d.ts +618 -0
  39. package/dist/accounting/followups.js +420 -0
  40. package/dist/accounting/i18n/bn.d.ts +2 -0
  41. package/dist/accounting/i18n/bn.js +425 -0
  42. package/dist/accounting/index.d.ts +3 -1
  43. package/dist/accounting/index.js +780 -5
  44. package/dist/accounting/module.d.ts +5386 -1543
  45. package/dist/accounting/module.js +155 -18
  46. package/dist/accounting/statements.d.ts +878 -0
  47. package/dist/accounting/statements.js +728 -0
  48. package/dist/accounting/web/BankReconcilePage.d.ts +9 -0
  49. package/dist/accounting/web/BankReconcilePage.js +138 -0
  50. package/dist/accounting/web/FollowupsPage.d.ts +8 -0
  51. package/dist/accounting/web/FollowupsPage.js +54 -0
  52. package/dist/accounting/web/PostingPreview.d.ts +8 -0
  53. package/dist/accounting/web/PostingPreview.js +26 -0
  54. package/dist/accounting/web/index.d.ts +3 -0
  55. package/dist/accounting/web/index.js +9 -0
  56. package/dist/accounting/web/messages.js +140 -0
  57. package/dist/approvals/.kosh/bindings.d.ts +22 -0
  58. package/dist/approvals/.kosh/bindings.js +15 -0
  59. package/dist/approvals/.kosh/schema.d.ts +879 -0
  60. package/dist/approvals/demo.d.ts +7 -0
  61. package/dist/approvals/demo.js +41 -0
  62. package/dist/approvals/i18n/bn.d.ts +2 -0
  63. package/dist/approvals/i18n/bn.js +133 -0
  64. package/dist/approvals/index.d.ts +36 -0
  65. package/dist/approvals/index.js +772 -0
  66. package/dist/approvals/mails.d.ts +30 -0
  67. package/dist/approvals/mails.js +87 -0
  68. package/dist/approvals/module.d.ts +2930 -0
  69. package/dist/approvals/module.js +473 -0
  70. package/dist/approvals/web/Config.d.ts +12 -0
  71. package/dist/approvals/web/Config.js +60 -0
  72. package/dist/approvals/web/History.d.ts +4 -0
  73. package/dist/approvals/web/History.js +13 -0
  74. package/dist/approvals/web/Inbox.d.ts +9 -0
  75. package/dist/approvals/web/Inbox.js +114 -0
  76. package/dist/approvals/web/Matrix.d.ts +9 -0
  77. package/dist/approvals/web/Matrix.js +26 -0
  78. package/dist/approvals/web/Mine.d.ts +7 -0
  79. package/dist/approvals/web/Mine.js +27 -0
  80. package/dist/approvals/web/index.d.ts +15 -0
  81. package/dist/approvals/web/index.js +29 -0
  82. package/dist/approvals/web/messages.d.ts +2 -0
  83. package/dist/approvals/web/messages.js +211 -0
  84. package/dist/approvals/web/shared.d.ts +59 -0
  85. package/dist/approvals/web/shared.js +46 -0
  86. package/dist/approvals_purchase/.kosh/bindings.d.ts +22 -0
  87. package/dist/approvals_purchase/.kosh/bindings.js +15 -0
  88. package/dist/approvals_purchase/.kosh/schema.d.ts +1997 -0
  89. package/dist/approvals_purchase/i18n/bn.d.ts +2 -0
  90. package/dist/approvals_purchase/i18n/bn.js +5 -0
  91. package/dist/approvals_purchase/index.d.ts +3 -0
  92. package/dist/approvals_purchase/index.js +47 -0
  93. package/dist/approvals_purchase/module.d.ts +12670 -0
  94. package/dist/approvals_purchase/module.js +84 -0
  95. package/dist/attendance/.kosh/bindings.d.ts +22 -0
  96. package/dist/attendance/.kosh/bindings.js +15 -0
  97. package/dist/attendance/.kosh/schema.d.ts +1106 -0
  98. package/dist/attendance/days.d.ts +96 -0
  99. package/dist/attendance/days.js +430 -0
  100. package/dist/attendance/demo.d.ts +7 -0
  101. package/dist/attendance/demo.js +58 -0
  102. package/dist/attendance/i18n/bn.d.ts +2 -0
  103. package/dist/attendance/i18n/bn.js +147 -0
  104. package/dist/attendance/index.d.ts +4 -0
  105. package/dist/attendance/index.js +515 -0
  106. package/dist/attendance/module.d.ts +4413 -0
  107. package/dist/attendance/module.js +412 -0
  108. package/dist/attendance/routes.d.ts +16 -0
  109. package/dist/attendance/routes.js +266 -0
  110. package/dist/attendance/web/Check.d.ts +8 -0
  111. package/dist/attendance/web/Check.js +40 -0
  112. package/dist/attendance/web/Kiosk.d.ts +8 -0
  113. package/dist/attendance/web/Kiosk.js +62 -0
  114. package/dist/attendance/web/PinButton.d.ts +7 -0
  115. package/dist/attendance/web/PinButton.js +29 -0
  116. package/dist/attendance/web/index.d.ts +13 -0
  117. package/dist/attendance/web/index.js +22 -0
  118. package/dist/attendance/web/messages.d.ts +2 -0
  119. package/dist/attendance/web/messages.js +61 -0
  120. package/dist/automation/engine.js +1 -1
  121. package/dist/calendar/.kosh/bindings.js +1 -1
  122. package/dist/calendar/.kosh/schema.d.ts +2 -1
  123. package/dist/calendar/i18n/bn.d.ts +2 -0
  124. package/dist/calendar/i18n/bn.js +80 -0
  125. package/dist/calendar/index.js +77 -0
  126. package/dist/calendar/module.d.ts +26 -0
  127. package/dist/calendar/module.js +14 -4
  128. package/dist/cli/apps.js +25 -5
  129. package/dist/cli/init.js +46 -4
  130. package/dist/cli/templates.d.ts +1 -1
  131. package/dist/cli/templates.js +123 -5
  132. package/dist/contacts/.kosh/bindings.js +1 -1
  133. package/dist/contacts/.kosh/schema.d.ts +2 -1
  134. package/dist/contacts/i18n/bn.d.ts +2 -0
  135. package/dist/contacts/i18n/bn.js +67 -0
  136. package/dist/contacts/index.js +3 -0
  137. package/dist/contacts/module.d.ts +42 -0
  138. package/dist/contacts/module.js +19 -3
  139. package/dist/crm/.kosh/bindings.js +1 -1
  140. package/dist/crm/.kosh/schema.d.ts +3 -1
  141. package/dist/crm/i18n/bn.d.ts +2 -0
  142. package/dist/crm/i18n/bn.js +80 -0
  143. package/dist/crm/index.js +22 -0
  144. package/dist/crm/module.d.ts +22 -0
  145. package/dist/crm/module.js +6 -3
  146. package/dist/documents/.kosh/bindings.d.ts +22 -0
  147. package/dist/documents/.kosh/bindings.js +15 -0
  148. package/dist/documents/.kosh/schema.d.ts +863 -0
  149. package/dist/documents/demo.d.ts +6 -0
  150. package/dist/documents/demo.js +22 -0
  151. package/dist/documents/documents.d.ts +98 -0
  152. package/dist/documents/documents.js +318 -0
  153. package/dist/documents/i18n/bn.d.ts +2 -0
  154. package/dist/documents/i18n/bn.js +83 -0
  155. package/dist/documents/index.d.ts +30 -0
  156. package/dist/documents/index.js +569 -0
  157. package/dist/documents/module.d.ts +2801 -0
  158. package/dist/documents/module.js +215 -0
  159. package/dist/documents/web/Versions.d.ts +7 -0
  160. package/dist/documents/web/Versions.js +45 -0
  161. package/dist/documents/web/index.d.ts +11 -0
  162. package/dist/documents/web/index.js +16 -0
  163. package/dist/documents/web/messages.d.ts +2 -0
  164. package/dist/documents/web/messages.js +21 -0
  165. package/dist/event/.kosh/bindings.js +1 -1
  166. package/dist/event/.kosh/schema.d.ts +2 -1
  167. package/dist/event/i18n/bn.d.ts +2 -0
  168. package/dist/event/i18n/bn.js +101 -0
  169. package/dist/event/index.js +66 -0
  170. package/dist/event/module.d.ts +20 -0
  171. package/dist/event/module.js +8 -1
  172. package/dist/event_account/.kosh/bindings.js +1 -1
  173. package/dist/event_account/.kosh/schema.d.ts +651 -10
  174. package/dist/event_account/i18n/bn.d.ts +2 -0
  175. package/dist/event_account/i18n/bn.js +5 -0
  176. package/dist/event_account/index.js +2 -0
  177. package/dist/event_account/module.d.ts +5133 -1513
  178. package/dist/expense/.kosh/bindings.d.ts +22 -0
  179. package/dist/expense/.kosh/bindings.js +15 -0
  180. package/dist/expense/.kosh/schema.d.ts +1620 -0
  181. package/dist/expense/demo.d.ts +7 -0
  182. package/dist/expense/demo.js +69 -0
  183. package/dist/expense/i18n/bn.d.ts +2 -0
  184. package/dist/expense/i18n/bn.js +155 -0
  185. package/dist/expense/index.d.ts +3 -0
  186. package/dist/expense/index.js +502 -0
  187. package/dist/expense/module.d.ts +6768 -0
  188. package/dist/expense/module.js +649 -0
  189. package/dist/expense_account/.kosh/bindings.d.ts +22 -0
  190. package/dist/expense_account/.kosh/bindings.js +15 -0
  191. package/dist/expense_account/.kosh/schema.d.ts +2515 -0
  192. package/dist/expense_account/i18n/bn.d.ts +2 -0
  193. package/dist/expense_account/i18n/bn.js +15 -0
  194. package/dist/expense_account/index.d.ts +3 -0
  195. package/dist/expense_account/index.js +76 -0
  196. package/dist/expense_account/module.d.ts +14628 -0
  197. package/dist/expense_account/module.js +318 -0
  198. package/dist/helpdesk/.kosh/bindings.d.ts +22 -0
  199. package/dist/helpdesk/.kosh/bindings.js +15 -0
  200. package/dist/helpdesk/.kosh/schema.d.ts +886 -0
  201. package/dist/helpdesk/demo.d.ts +7 -0
  202. package/dist/helpdesk/demo.js +65 -0
  203. package/dist/helpdesk/hours.d.ts +17 -0
  204. package/dist/helpdesk/hours.js +94 -0
  205. package/dist/helpdesk/i18n/bn.d.ts +2 -0
  206. package/dist/helpdesk/i18n/bn.js +127 -0
  207. package/dist/helpdesk/index.d.ts +10 -0
  208. package/dist/helpdesk/index.js +463 -0
  209. package/dist/helpdesk/module.d.ts +2960 -0
  210. package/dist/helpdesk/module.js +326 -0
  211. package/dist/helpdesk/routes.d.ts +12 -0
  212. package/dist/helpdesk/routes.js +132 -0
  213. package/dist/helpdesk/sla.d.ts +37 -0
  214. package/dist/helpdesk/sla.js +226 -0
  215. package/dist/hr/.kosh/bindings.js +1 -1
  216. package/dist/hr/.kosh/schema.d.ts +59 -1
  217. package/dist/hr/demo.js +11 -1
  218. package/dist/hr/i18n/bn.d.ts +2 -0
  219. package/dist/hr/i18n/bn.js +126 -0
  220. package/dist/hr/index.d.ts +1 -1
  221. package/dist/hr/index.js +158 -12
  222. package/dist/hr/module.d.ts +932 -59
  223. package/dist/hr/module.js +114 -17
  224. package/dist/indent/.kosh/bindings.d.ts +22 -0
  225. package/dist/indent/.kosh/bindings.js +15 -0
  226. package/dist/indent/.kosh/schema.d.ts +2084 -0
  227. package/dist/indent/demo.d.ts +7 -0
  228. package/dist/indent/demo.js +48 -0
  229. package/dist/indent/i18n/bn.d.ts +2 -0
  230. package/dist/indent/i18n/bn.js +143 -0
  231. package/dist/indent/index.d.ts +3 -0
  232. package/dist/indent/index.js +450 -0
  233. package/dist/indent/module.d.ts +13424 -0
  234. package/dist/indent/module.js +792 -0
  235. package/dist/indent_purchase/.kosh/bindings.d.ts +22 -0
  236. package/dist/indent_purchase/.kosh/bindings.js +15 -0
  237. package/dist/indent_purchase/.kosh/schema.d.ts +2710 -0
  238. package/dist/indent_purchase/i18n/bn.d.ts +2 -0
  239. package/dist/indent_purchase/i18n/bn.js +13 -0
  240. package/dist/indent_purchase/index.d.ts +3 -0
  241. package/dist/indent_purchase/index.js +61 -0
  242. package/dist/indent_purchase/module.d.ts +27950 -0
  243. package/dist/indent_purchase/module.js +163 -0
  244. package/dist/l10n_bd/.kosh/bindings.js +1 -1
  245. package/dist/l10n_bd/.kosh/schema.d.ts +651 -10
  246. package/dist/l10n_bd/i18n/bn.d.ts +2 -0
  247. package/dist/l10n_bd/i18n/bn.js +69 -0
  248. package/dist/l10n_bd/index.js +2 -0
  249. package/dist/l10n_bd/module.d.ts +5212 -1592
  250. package/dist/l10n_bd_payroll/.kosh/bindings.d.ts +22 -0
  251. package/dist/l10n_bd_payroll/.kosh/bindings.js +15 -0
  252. package/dist/l10n_bd_payroll/.kosh/schema.d.ts +2891 -0
  253. package/dist/l10n_bd_payroll/data.d.ts +47 -0
  254. package/dist/l10n_bd_payroll/data.js +347 -0
  255. package/dist/l10n_bd_payroll/i18n/bn.d.ts +2 -0
  256. package/dist/l10n_bd_payroll/i18n/bn.js +4 -0
  257. package/dist/l10n_bd_payroll/index.d.ts +4 -0
  258. package/dist/l10n_bd_payroll/index.js +26 -0
  259. package/dist/l10n_bd_payroll/module.d.ts +17294 -0
  260. package/dist/l10n_bd_payroll/module.js +86 -0
  261. package/dist/l10n_bd_pos/.kosh/bindings.d.ts +22 -0
  262. package/dist/{mrp_account → l10n_bd_pos}/.kosh/bindings.js +2 -2
  263. package/dist/l10n_bd_pos/.kosh/schema.d.ts +2341 -0
  264. package/dist/l10n_bd_pos/i18n/bn.d.ts +2 -0
  265. package/dist/l10n_bd_pos/i18n/bn.js +32 -0
  266. package/dist/l10n_bd_pos/index.d.ts +3 -0
  267. package/dist/l10n_bd_pos/index.js +111 -0
  268. package/dist/{mrp_account → l10n_bd_pos}/module.d.ts +9047 -6981
  269. package/dist/l10n_bd_pos/module.js +43 -0
  270. package/dist/l10n_in/.kosh/bindings.js +1 -1
  271. package/dist/l10n_in/.kosh/schema.d.ts +651 -10
  272. package/dist/l10n_in/i18n/bn.d.ts +2 -0
  273. package/dist/l10n_in/i18n/bn.js +95 -0
  274. package/dist/l10n_in/index.js +2 -0
  275. package/dist/l10n_in/module.d.ts +6778 -1580
  276. package/dist/l10n_in/module.js +25 -5
  277. package/dist/l10n_in/web/GstSettings.js +2 -2
  278. package/dist/mail/inbound/handle.js +8 -5
  279. package/dist/mail/inbound/models.js +5 -3
  280. package/dist/mail/index.d.ts +12 -1
  281. package/dist/mail/index.js +139 -2
  282. package/dist/mail/send.d.ts +56 -0
  283. package/dist/mail/send.js +394 -0
  284. package/dist/mail/web/SendButton.d.ts +9 -0
  285. package/dist/mail/web/SendButton.js +71 -0
  286. package/dist/mail/web/SendSelected.d.ts +8 -0
  287. package/dist/mail/web/SendSelected.js +33 -0
  288. package/dist/mail/web/index.d.ts +2 -0
  289. package/dist/mail/web/index.js +6 -0
  290. package/dist/mail/web/messages.js +36 -0
  291. package/dist/maintenance/.kosh/bindings.js +1 -1
  292. package/dist/maintenance/.kosh/schema.d.ts +2 -1
  293. package/dist/maintenance/i18n/bn.d.ts +2 -0
  294. package/dist/maintenance/i18n/bn.js +132 -0
  295. package/dist/maintenance/index.js +85 -0
  296. package/dist/maintenance/module.d.ts +25 -0
  297. package/dist/maintenance/module.js +27 -9
  298. package/dist/maintenance_stock/.kosh/bindings.js +1 -1
  299. package/dist/maintenance_stock/.kosh/schema.d.ts +374 -3
  300. package/dist/maintenance_stock/i18n/bn.d.ts +2 -0
  301. package/dist/maintenance_stock/i18n/bn.js +21 -0
  302. package/dist/maintenance_stock/index.js +2 -0
  303. package/dist/maintenance_stock/module.d.ts +6095 -1327
  304. package/dist/maintenance_stock/module.js +1 -0
  305. package/dist/modules-sdk/apps.d.ts +10 -0
  306. package/dist/modules-sdk/apps.js +32 -0
  307. package/dist/modules-sdk/index.d.ts +1 -1
  308. package/dist/modules-sdk/manifest.d.ts +105 -2
  309. package/dist/payment/.kosh/bindings.js +1 -1
  310. package/dist/payment/.kosh/schema.d.ts +653 -11
  311. package/dist/payment/i18n/bn.d.ts +2 -0
  312. package/dist/payment/i18n/bn.js +59 -0
  313. package/dist/payment/index.d.ts +41 -0
  314. package/dist/payment/index.js +216 -74
  315. package/dist/payment/module.d.ts +5353 -1675
  316. package/dist/payment/module.js +36 -6
  317. package/dist/payment/settle.js +11 -1
  318. package/dist/payroll/.kosh/bindings.d.ts +22 -0
  319. package/dist/payroll/.kosh/bindings.js +15 -0
  320. package/dist/payroll/.kosh/schema.d.ts +1448 -0
  321. package/dist/payroll/compute.d.ts +35 -0
  322. package/dist/payroll/compute.js +398 -0
  323. package/dist/payroll/demo.d.ts +55 -0
  324. package/dist/payroll/demo.js +121 -0
  325. package/dist/payroll/formula.d.ts +62 -0
  326. package/dist/payroll/formula.js +320 -0
  327. package/dist/payroll/i18n/bn.d.ts +2 -0
  328. package/dist/payroll/i18n/bn.js +206 -0
  329. package/dist/payroll/index.d.ts +230 -0
  330. package/dist/payroll/index.js +715 -0
  331. package/dist/{mrp → payroll}/module.d.ts +4294 -2624
  332. package/dist/payroll/module.js +606 -0
  333. package/dist/payroll/routes.d.ts +10 -0
  334. package/dist/payroll/routes.js +112 -0
  335. package/dist/payroll_account/.kosh/bindings.d.ts +22 -0
  336. package/dist/payroll_account/.kosh/bindings.js +15 -0
  337. package/dist/payroll_account/.kosh/schema.d.ts +2887 -0
  338. package/dist/payroll_account/i18n/bn.d.ts +2 -0
  339. package/dist/payroll_account/i18n/bn.js +10 -0
  340. package/dist/payroll_account/index.d.ts +3 -0
  341. package/dist/payroll_account/index.js +42 -0
  342. package/dist/payroll_account/module.d.ts +16738 -0
  343. package/dist/payroll_account/module.js +256 -0
  344. package/dist/permissions/approvals.d.ts +227 -12
  345. package/dist/permissions/approvals.js +1421 -67
  346. package/dist/permissions/index.d.ts +1 -1
  347. package/dist/permissions/index.js +2 -2
  348. package/dist/permissions/models.js +364 -13
  349. package/dist/permissions/routes.d.ts +9 -1
  350. package/dist/permissions/routes.js +72 -5
  351. package/dist/permissions/web/ApprovalPanel.d.ts +5 -4
  352. package/dist/permissions/web/ApprovalPanel.js +75 -11
  353. package/dist/permissions/web/index.d.ts +6 -4
  354. package/dist/permissions/web/index.js +13 -4
  355. package/dist/permissions/web/messages.d.ts +2 -0
  356. package/dist/permissions/web/messages.js +95 -0
  357. package/dist/portal/.kosh/bindings.js +1 -1
  358. package/dist/portal/.kosh/schema.d.ts +2 -1
  359. package/dist/portal/documents.d.ts +3 -0
  360. package/dist/portal/documents.js +21 -1
  361. package/dist/portal/i18n/bn.d.ts +2 -0
  362. package/dist/portal/i18n/bn.js +33 -0
  363. package/dist/portal/index.js +3 -1
  364. package/dist/portal/module.d.ts +20 -0
  365. package/dist/portal/routes-documents.js +76 -0
  366. package/dist/pos/.kosh/bindings.js +1 -1
  367. package/dist/pos/.kosh/schema.d.ts +652 -10
  368. package/dist/pos/i18n/bn.d.ts +2 -0
  369. package/dist/pos/i18n/bn.js +133 -0
  370. package/dist/pos/index.js +87 -1
  371. package/dist/pos/module.d.ts +6967 -1709
  372. package/dist/pos/module.js +49 -5
  373. package/dist/pos/routes.js +80 -7
  374. package/dist/pos/web/Register.js +2 -5
  375. package/dist/pos_stock/.kosh/bindings.js +1 -1
  376. package/dist/pos_stock/.kosh/schema.d.ts +822 -12
  377. package/dist/pos_stock/i18n/bn.d.ts +2 -0
  378. package/dist/pos_stock/i18n/bn.js +6 -0
  379. package/dist/pos_stock/index.js +2 -0
  380. package/dist/pos_stock/module.d.ts +11241 -2851
  381. package/dist/product/.kosh/bindings.js +1 -1
  382. package/dist/product/.kosh/schema.d.ts +203 -1
  383. package/dist/product/i18n/bn.d.ts +2 -0
  384. package/dist/product/i18n/bn.js +175 -0
  385. package/dist/product/index.d.ts +1 -0
  386. package/dist/product/index.js +301 -1
  387. package/dist/product/module.d.ts +1727 -0
  388. package/dist/product/module.js +67 -6
  389. package/dist/product/pricelist.d.ts +575 -0
  390. package/dist/product/pricelist.js +257 -0
  391. package/dist/product/variants.d.ts +908 -0
  392. package/dist/product/variants.js +251 -0
  393. package/dist/production/.kosh/bindings.d.ts +22 -0
  394. package/dist/production/.kosh/bindings.js +15 -0
  395. package/dist/production/.kosh/schema.d.ts +2345 -0
  396. package/dist/{mrp → production}/demo.d.ts +1 -1
  397. package/dist/{mrp → production}/demo.js +5 -5
  398. package/dist/production/depth.d.ts +790 -0
  399. package/dist/production/depth.js +262 -0
  400. package/dist/production/i18n/bn.d.ts +2 -0
  401. package/dist/production/i18n/bn.js +350 -0
  402. package/dist/production/index.d.ts +6 -0
  403. package/dist/production/index.js +1256 -0
  404. package/dist/production/module.d.ts +17327 -0
  405. package/dist/production/module.js +1333 -0
  406. package/dist/production/plan.d.ts +921 -0
  407. package/dist/production/plan.js +511 -0
  408. package/dist/production/schedule.d.ts +656 -0
  409. package/dist/production/schedule.js +309 -0
  410. package/dist/production_account/.kosh/bindings.d.ts +22 -0
  411. package/dist/production_account/.kosh/bindings.js +15 -0
  412. package/dist/production_account/.kosh/schema.d.ts +3496 -0
  413. package/dist/production_account/i18n/bn.d.ts +2 -0
  414. package/dist/production_account/i18n/bn.js +93 -0
  415. package/dist/production_account/index.d.ts +4 -0
  416. package/dist/production_account/index.js +246 -0
  417. package/dist/production_account/module.d.ts +1192 -0
  418. package/dist/{mrp_account → production_account}/module.js +72 -18
  419. package/dist/production_account/overhead.d.ts +1195 -0
  420. package/dist/production_account/overhead.js +554 -0
  421. package/dist/project/.kosh/bindings.js +1 -1
  422. package/dist/project/.kosh/schema.d.ts +735 -1
  423. package/dist/project/i18n/bn.d.ts +2 -0
  424. package/dist/project/i18n/bn.js +383 -0
  425. package/dist/project/index.d.ts +3 -1
  426. package/dist/project/index.js +1024 -14
  427. package/dist/project/module.d.ts +9912 -390
  428. package/dist/project/module.js +1590 -14
  429. package/dist/project/routes.d.ts +44 -0
  430. package/dist/project/routes.js +314 -0
  431. package/dist/project/schedule.d.ts +72 -0
  432. package/dist/project/schedule.js +192 -0
  433. package/dist/project/web/Refresh.d.ts +8 -0
  434. package/dist/project/web/Refresh.js +29 -0
  435. package/dist/project/web/Schedule.d.ts +9 -0
  436. package/dist/project/web/Schedule.js +93 -0
  437. package/dist/project/web/Structure.d.ts +8 -0
  438. package/dist/project/web/Structure.js +86 -0
  439. package/dist/project/web/Workload.d.ts +8 -0
  440. package/dist/project/web/Workload.js +43 -0
  441. package/dist/project/web/index.d.ts +14 -0
  442. package/dist/project/web/index.js +25 -0
  443. package/dist/project/web/messages.d.ts +2 -0
  444. package/dist/project/web/messages.js +85 -0
  445. package/dist/project_account/.kosh/bindings.d.ts +22 -0
  446. package/dist/project_account/.kosh/bindings.js +15 -0
  447. package/dist/project_account/.kosh/schema.d.ts +2763 -0
  448. package/dist/project_account/i18n/bn.d.ts +2 -0
  449. package/dist/project_account/i18n/bn.js +6 -0
  450. package/dist/project_account/index.d.ts +3 -0
  451. package/dist/project_account/index.js +29 -0
  452. package/dist/project_account/module.d.ts +15013 -0
  453. package/dist/project_account/module.js +76 -0
  454. package/dist/project_portal/.kosh/bindings.js +1 -1
  455. package/dist/project_portal/.kosh/schema.d.ts +735 -1
  456. package/dist/project_portal/i18n/bn.d.ts +2 -0
  457. package/dist/project_portal/i18n/bn.js +6 -0
  458. package/dist/project_portal/index.js +2 -0
  459. package/dist/project_portal/module.d.ts +4796 -87
  460. package/dist/project_purchase/.kosh/bindings.d.ts +22 -0
  461. package/dist/project_purchase/.kosh/bindings.js +15 -0
  462. package/dist/project_purchase/.kosh/schema.d.ts +3393 -0
  463. package/dist/project_purchase/i18n/bn.d.ts +2 -0
  464. package/dist/project_purchase/i18n/bn.js +4 -0
  465. package/dist/project_purchase/index.d.ts +9 -0
  466. package/dist/project_purchase/index.js +24 -0
  467. package/dist/project_purchase/module.d.ts +38613 -0
  468. package/dist/project_purchase/module.js +56 -0
  469. package/dist/purchase/.kosh/bindings.js +1 -1
  470. package/dist/purchase/.kosh/schema.d.ts +908 -5
  471. package/dist/purchase/comparison.d.ts +993 -0
  472. package/dist/purchase/comparison.js +415 -0
  473. package/dist/purchase/extras.d.ts +1509 -0
  474. package/dist/purchase/extras.js +445 -0
  475. package/dist/purchase/i18n/bn.d.ts +2 -0
  476. package/dist/purchase/i18n/bn.js +413 -0
  477. package/dist/purchase/index.d.ts +5 -0
  478. package/dist/purchase/index.js +1280 -4
  479. package/dist/purchase/module.d.ts +7147 -395
  480. package/dist/purchase/module.js +303 -10
  481. package/dist/purchase/request.d.ts +696 -0
  482. package/dist/purchase/request.js +446 -0
  483. package/dist/purchase/tender.d.ts +1208 -0
  484. package/dist/purchase/tender.js +507 -0
  485. package/dist/purchase/vendorprice.d.ts +340 -0
  486. package/dist/purchase/vendorprice.js +153 -0
  487. package/dist/purchase_account/.kosh/bindings.js +1 -1
  488. package/dist/purchase_account/.kosh/schema.d.ts +1209 -16
  489. package/dist/purchase_account/i18n/bn.d.ts +2 -0
  490. package/dist/purchase_account/i18n/bn.js +22 -0
  491. package/dist/purchase_account/index.js +20 -0
  492. package/dist/purchase_account/module.d.ts +12232 -2028
  493. package/dist/purchase_account/module.js +252 -9
  494. package/dist/purchase_portal/.kosh/bindings.js +1 -1
  495. package/dist/purchase_portal/.kosh/schema.d.ts +908 -5
  496. package/dist/purchase_portal/i18n/bn.d.ts +2 -0
  497. package/dist/purchase_portal/i18n/bn.js +5 -0
  498. package/dist/purchase_portal/index.js +2 -0
  499. package/dist/purchase_portal/module.d.ts +6853 -352
  500. package/dist/purchase_stock/.kosh/bindings.js +1 -1
  501. package/dist/purchase_stock/.kosh/schema.d.ts +1096 -21
  502. package/dist/purchase_stock/i18n/bn.d.ts +2 -0
  503. package/dist/purchase_stock/i18n/bn.js +19 -0
  504. package/dist/purchase_stock/index.d.ts +2 -2
  505. package/dist/purchase_stock/index.js +38 -2
  506. package/dist/purchase_stock/module.d.ts +12930 -1612
  507. package/dist/purchase_stock/module.js +317 -9
  508. package/dist/purchase_stock/scorecard.d.ts +22 -0
  509. package/dist/purchase_stock/scorecard.js +77 -0
  510. package/dist/purchase_stock/web/Scorecard.d.ts +7 -0
  511. package/dist/purchase_stock/web/Scorecard.js +22 -0
  512. package/dist/purchase_stock/web/index.d.ts +11 -0
  513. package/dist/purchase_stock/web/index.js +16 -0
  514. package/dist/purchase_stock/web/messages.d.ts +2 -0
  515. package/dist/purchase_stock/web/messages.js +27 -0
  516. package/dist/purchase_stock_account/.kosh/bindings.js +1 -1
  517. package/dist/purchase_stock_account/.kosh/schema.d.ts +1444 -20
  518. package/dist/purchase_stock_account/i18n/bn.d.ts +2 -0
  519. package/dist/purchase_stock_account/i18n/bn.js +8 -0
  520. package/dist/purchase_stock_account/index.js +18 -0
  521. package/dist/purchase_stock_account/module.d.ts +7 -35346
  522. package/dist/purchase_stock_account/module.js +35 -8
  523. package/dist/recruitment/.kosh/bindings.js +1 -1
  524. package/dist/recruitment/.kosh/schema.d.ts +60 -1
  525. package/dist/recruitment/i18n/bn.d.ts +2 -0
  526. package/dist/recruitment/i18n/bn.js +93 -0
  527. package/dist/recruitment/index.js +64 -0
  528. package/dist/recruitment/module.d.ts +460 -8
  529. package/dist/recruitment/module.js +13 -4
  530. package/dist/reporting/documents.d.ts +5 -0
  531. package/dist/reporting/documents.js +11 -1
  532. package/dist/reporting/index.d.ts +1 -1
  533. package/dist/reporting/index.js +1 -1
  534. package/dist/reporting/web/CalendarView.d.ts +18 -5
  535. package/dist/reporting/web/CalendarView.js +163 -29
  536. package/dist/reporting/web/messages.js +18 -0
  537. package/dist/sale_account/.kosh/bindings.js +1 -1
  538. package/dist/sale_account/.kosh/schema.d.ts +763 -18
  539. package/dist/sale_account/i18n/bn.d.ts +2 -0
  540. package/dist/sale_account/i18n/bn.js +48 -0
  541. package/dist/sale_account/index.d.ts +1 -1
  542. package/dist/sale_account/index.js +102 -4
  543. package/dist/sale_account/module.d.ts +8241 -2052
  544. package/dist/sale_account/module.js +535 -46
  545. package/dist/sale_crm/.kosh/bindings.d.ts +22 -0
  546. package/dist/sale_crm/.kosh/bindings.js +15 -0
  547. package/dist/{mrp → sale_crm}/.kosh/schema.d.ts +391 -494
  548. package/dist/sale_crm/i18n/bn.d.ts +2 -0
  549. package/dist/sale_crm/i18n/bn.js +9 -0
  550. package/dist/sale_crm/index.d.ts +7 -0
  551. package/dist/sale_crm/index.js +104 -0
  552. package/dist/sale_crm/module.d.ts +5609 -0
  553. package/dist/sale_crm/module.js +73 -0
  554. package/dist/sale_portal/.kosh/bindings.js +1 -1
  555. package/dist/sale_portal/.kosh/schema.d.ts +292 -4
  556. package/dist/sale_portal/i18n/bn.d.ts +2 -0
  557. package/dist/sale_portal/i18n/bn.js +7 -0
  558. package/dist/sale_portal/index.js +10 -0
  559. package/dist/sale_portal/module.d.ts +2563 -292
  560. package/dist/sale_project/.kosh/bindings.js +1 -1
  561. package/dist/sale_project/.kosh/schema.d.ts +1025 -4
  562. package/dist/sale_project/i18n/bn.d.ts +2 -0
  563. package/dist/sale_project/i18n/bn.js +12 -0
  564. package/dist/sale_project/index.js +2 -0
  565. package/dist/sale_project/module.d.ts +9280 -762
  566. package/dist/sale_project/module.js +17 -1
  567. package/dist/sale_stock/.kosh/bindings.js +1 -1
  568. package/dist/sale_stock/.kosh/schema.d.ts +463 -6
  569. package/dist/sale_stock/i18n/bn.d.ts +2 -0
  570. package/dist/sale_stock/i18n/bn.js +15 -0
  571. package/dist/sale_stock/index.js +2 -0
  572. package/dist/sale_stock/module.d.ts +8355 -1334
  573. package/dist/sale_stock/module.js +20 -3
  574. package/dist/sales/.kosh/bindings.js +1 -1
  575. package/dist/sales/.kosh/schema.d.ts +292 -4
  576. package/dist/sales/i18n/bn.d.ts +2 -0
  577. package/dist/sales/i18n/bn.js +128 -0
  578. package/dist/sales/index.js +124 -5
  579. package/dist/sales/module.d.ts +3568 -633
  580. package/dist/sales/module.js +306 -11
  581. package/dist/server/api/duplicate.d.ts +14 -0
  582. package/dist/server/api/duplicate.js +75 -0
  583. package/dist/server/api/explain.d.ts +70 -0
  584. package/dist/server/api/explain.js +111 -0
  585. package/dist/server/api/metadata.d.ts +2 -0
  586. package/dist/server/api/metadata.js +9 -0
  587. package/dist/server/api/openapi.js +15 -0
  588. package/dist/server/api/rest.d.ts +1 -0
  589. package/dist/server/api/rest.js +76 -12
  590. package/dist/server/api/views.js +1 -1
  591. package/dist/server/apps.d.ts +16 -1
  592. package/dist/server/apps.js +164 -2
  593. package/dist/server/auth/base.js +2 -0
  594. package/dist/server/auth/service.d.ts +8 -0
  595. package/dist/server/auth/service.js +19 -0
  596. package/dist/server/events.d.ts +13 -0
  597. package/dist/server/events.js +22 -0
  598. package/dist/server/i18n.d.ts +27 -0
  599. package/dist/server/i18n.js +143 -0
  600. package/dist/server/index.d.ts +2 -0
  601. package/dist/server/index.js +2 -0
  602. package/dist/server/server.js +6 -0
  603. package/dist/settings/company.d.ts +3 -1
  604. package/dist/settings/company.js +26 -5
  605. package/dist/settings/routes.d.ts +10 -0
  606. package/dist/settings/routes.js +19 -3
  607. package/dist/settings/web/AppsPage.d.ts +3 -2
  608. package/dist/settings/web/AppsPage.js +26 -8
  609. package/dist/settings/web/CompaniesPage.js +91 -6
  610. package/dist/settings/web/messages.js +64 -0
  611. package/dist/sign/.kosh/bindings.d.ts +22 -0
  612. package/dist/{mrp → sign}/.kosh/bindings.js +2 -2
  613. package/dist/sign/.kosh/schema.d.ts +991 -0
  614. package/dist/sign/i18n/bn.d.ts +2 -0
  615. package/dist/sign/i18n/bn.js +97 -0
  616. package/dist/sign/index.d.ts +29 -0
  617. package/dist/sign/index.js +478 -0
  618. package/dist/sign/module.d.ts +4518 -0
  619. package/dist/sign/module.js +167 -0
  620. package/dist/sign/sign.d.ts +82 -0
  621. package/dist/sign/sign.js +474 -0
  622. package/dist/stock/.kosh/bindings.js +1 -1
  623. package/dist/stock/.kosh/schema.d.ts +374 -3
  624. package/dist/stock/demo.d.ts +2 -1
  625. package/dist/stock/demo.js +28 -1
  626. package/dist/stock/i18n/bn.d.ts +2 -0
  627. package/dist/stock/i18n/bn.js +311 -0
  628. package/dist/stock/index.d.ts +4 -1
  629. package/dist/stock/index.js +674 -6
  630. package/dist/stock/ledger.d.ts +78 -0
  631. package/dist/stock/ledger.js +582 -0
  632. package/dist/stock/module.d.ts +6142 -1380
  633. package/dist/stock/module.js +780 -26
  634. package/dist/stock/replenish.d.ts +38 -0
  635. package/dist/stock/replenish.js +191 -0
  636. package/dist/stock/returns.d.ts +157 -0
  637. package/dist/stock/returns.js +163 -0
  638. package/dist/stock/web/Ledger.d.ts +9 -0
  639. package/dist/stock/web/Ledger.js +108 -0
  640. package/dist/stock/web/Operations.d.ts +8 -0
  641. package/dist/stock/web/Operations.js +33 -0
  642. package/dist/stock/web/Replenishment.d.ts +8 -0
  643. package/dist/stock/web/Replenishment.js +84 -0
  644. package/dist/stock/web/ReturnButton.d.ts +7 -0
  645. package/dist/stock/web/ReturnButton.js +62 -0
  646. package/dist/stock/web/index.d.ts +7 -2
  647. package/dist/stock/web/index.js +15 -2
  648. package/dist/stock/web/messages.js +206 -0
  649. package/dist/stock_account/.kosh/bindings.js +1 -1
  650. package/dist/stock_account/.kosh/schema.d.ts +878 -12
  651. package/dist/stock_account/i18n/bn.d.ts +2 -0
  652. package/dist/stock_account/i18n/bn.js +73 -0
  653. package/dist/stock_account/index.d.ts +1 -0
  654. package/dist/stock_account/index.js +141 -3
  655. package/dist/stock_account/landed.d.ts +429 -0
  656. package/dist/stock_account/landed.js +335 -0
  657. package/dist/stock_account/module.d.ts +12143 -3391
  658. package/dist/stock_account/module.js +135 -6
  659. package/dist/stock_account/web/LandedPreview.d.ts +7 -0
  660. package/dist/stock_account/web/LandedPreview.js +23 -0
  661. package/dist/stock_account/web/index.d.ts +11 -0
  662. package/dist/stock_account/web/index.js +16 -0
  663. package/dist/stock_account/web/messages.d.ts +2 -0
  664. package/dist/stock_account/web/messages.js +27 -0
  665. package/dist/todo/i18n/bn.d.ts +2 -0
  666. package/dist/todo/i18n/bn.js +66 -0
  667. package/dist/todo/index.js +59 -0
  668. package/dist/todo/module.d.ts +5 -0
  669. package/dist/todo/module.js +5 -3
  670. package/dist/trade_finance/.kosh/bindings.js +1 -1
  671. package/dist/trade_finance/.kosh/schema.d.ts +2 -1
  672. package/dist/trade_finance/i18n/bn.d.ts +2 -0
  673. package/dist/trade_finance/i18n/bn.js +162 -0
  674. package/dist/trade_finance/index.js +95 -0
  675. package/dist/trade_finance/module.d.ts +26 -0
  676. package/dist/trade_finance/module.js +29 -8
  677. package/dist/trade_finance_account/.kosh/bindings.js +1 -1
  678. package/dist/trade_finance_account/.kosh/schema.d.ts +651 -10
  679. package/dist/trade_finance_account/i18n/bn.d.ts +2 -0
  680. package/dist/trade_finance_account/i18n/bn.js +27 -0
  681. package/dist/trade_finance_account/index.js +3 -0
  682. package/dist/trade_finance_account/module.d.ts +5129 -1509
  683. package/dist/trade_finance_account/module.js +2 -0
  684. package/dist/trade_finance_purchase/.kosh/bindings.js +1 -1
  685. package/dist/trade_finance_purchase/.kosh/schema.d.ts +908 -5
  686. package/dist/trade_finance_purchase/i18n/bn.d.ts +2 -0
  687. package/dist/trade_finance_purchase/i18n/bn.js +6 -0
  688. package/dist/trade_finance_purchase/index.js +2 -0
  689. package/dist/trade_finance_purchase/module.d.ts +6909 -408
  690. package/dist/trade_finance_sale/.kosh/bindings.js +1 -1
  691. package/dist/trade_finance_sale/.kosh/schema.d.ts +292 -4
  692. package/dist/trade_finance_sale/i18n/bn.d.ts +2 -0
  693. package/dist/trade_finance_sale/i18n/bn.js +6 -0
  694. package/dist/trade_finance_sale/index.js +2 -0
  695. package/dist/trade_finance_sale/module.d.ts +2602 -331
  696. package/dist/ui/api.d.ts +2 -0
  697. package/dist/ui/app.d.ts +9 -0
  698. package/dist/ui/app.js +47 -15
  699. package/dist/ui/components/AppIcon.js +9 -2
  700. package/dist/ui/components/Explain.d.ts +69 -0
  701. package/dist/ui/components/Explain.js +62 -0
  702. package/dist/ui/context.d.ts +8 -1
  703. package/dist/ui/context.js +34 -1
  704. package/dist/ui/i18n/messages.d.ts +40 -0
  705. package/dist/ui/i18n/messages.js +80 -0
  706. package/dist/ui/index.d.ts +2 -1
  707. package/dist/ui/index.js +1 -0
  708. package/dist/ui/registry.d.ts +14 -0
  709. package/dist/ui/registry.js +10 -0
  710. package/dist/ui/views/FormView.d.ts +6 -0
  711. package/dist/ui/views/FormView.js +51 -12
  712. package/dist/ui/views/KanbanView.js +9 -1
  713. package/dist/ui/views/ListView.d.ts +8 -0
  714. package/dist/ui/views/ListView.js +14 -5
  715. package/dist/ui/views/StatsRow.js +2 -1
  716. package/dist/ui/views/widgets.js +7 -1
  717. package/dist/views/extend.js +12 -0
  718. package/dist/views/types.d.ts +13 -2
  719. package/dist/views/validate.js +8 -1
  720. package/dist/website/.kosh/bindings.js +1 -1
  721. package/dist/website/.kosh/schema.d.ts +2 -1
  722. package/dist/website/i18n/bn.d.ts +2 -0
  723. package/dist/website/i18n/bn.js +113 -0
  724. package/dist/website/index.js +37 -0
  725. package/dist/website/module.d.ts +20 -0
  726. package/dist/website/module.js +30 -5
  727. package/dist/website_crm/.kosh/bindings.js +1 -1
  728. package/dist/website_crm/.kosh/schema.d.ts +3 -1
  729. package/dist/website_crm/i18n/bn.d.ts +2 -0
  730. package/dist/website_crm/i18n/bn.js +5 -0
  731. package/dist/website_crm/index.js +2 -0
  732. package/dist/website_crm/module.d.ts +41 -0
  733. package/dist/website_sale/.kosh/bindings.d.ts +22 -0
  734. package/dist/website_sale/.kosh/bindings.js +15 -0
  735. package/dist/website_sale/.kosh/schema.d.ts +2909 -0
  736. package/dist/website_sale/couriers.d.ts +50 -0
  737. package/dist/website_sale/couriers.js +59 -0
  738. package/dist/website_sale/demo.d.ts +7 -0
  739. package/dist/website_sale/demo.js +90 -0
  740. package/dist/website_sale/growth.d.ts +31 -0
  741. package/dist/website_sale/growth.js +163 -0
  742. package/dist/website_sale/i18n/bn.d.ts +2 -0
  743. package/dist/website_sale/i18n/bn.js +132 -0
  744. package/dist/website_sale/index.d.ts +49 -0
  745. package/dist/website_sale/index.js +620 -0
  746. package/dist/website_sale/module.d.ts +35182 -0
  747. package/dist/website_sale/module.js +419 -0
  748. package/dist/website_sale/shipments.d.ts +16 -0
  749. package/dist/website_sale/shipments.js +113 -0
  750. package/dist/website_sale/shop.d.ts +81 -0
  751. package/dist/website_sale/shop.js +662 -0
  752. package/dist/website_sale_stock/.kosh/bindings.d.ts +22 -0
  753. package/dist/website_sale_stock/.kosh/bindings.js +15 -0
  754. package/dist/website_sale_stock/.kosh/schema.d.ts +3400 -0
  755. package/dist/website_sale_stock/i18n/bn.d.ts +2 -0
  756. package/dist/website_sale_stock/i18n/bn.js +4 -0
  757. package/dist/website_sale_stock/index.d.ts +9 -0
  758. package/dist/website_sale_stock/index.js +22 -0
  759. package/dist/website_sale_stock/module.d.ts +11 -0
  760. package/dist/website_sale_stock/module.js +32 -0
  761. package/package.json +117 -8
  762. package/dist/mrp/index.d.ts +0 -3
  763. package/dist/mrp/index.js +0 -392
  764. package/dist/mrp/module.js +0 -695
  765. package/dist/mrp_account/index.d.ts +0 -3
  766. package/dist/mrp_account/index.js +0 -22
  767. /package/dist/{mrp → account_asset}/.kosh/bindings.d.ts +0 -0
  768. /package/dist/{mrp_account → account_budget}/.kosh/bindings.d.ts +0 -0
@@ -9,9 +9,10 @@
9
9
  import { contactsShutro } from '../contacts/index.js';
10
10
  import { messagingShutro } from '../messaging/index.js';
11
11
  import { productShutro } from '../product/index.js';
12
- import { installationSetting } from '../server/index.js';
12
+ import { emitting, installationSetting } from '../server/index.js';
13
13
  import { orm } from '../server/orm.js';
14
14
  import { check, compute, defineModel, defineModule, extendModel, f, method, onchange, record, records, } from './.kosh/bindings.js';
15
+ import { StockReturnReason } from './returns.js';
15
16
  const READ = ['read'];
16
17
  const ALL = ['read', 'write', 'create', 'unlink'];
17
18
  const zero = orm.toDecimal(0);
@@ -44,19 +45,33 @@ export async function defaultLocations(env, kind, warehouse,
44
45
  forCompany) {
45
46
  const company = forCompany ?? env.companyId;
46
47
  const wh = warehouse ??
47
- (await env.model('stock.warehouse').search({ where: { company }, limit: 1 })).ids[0] ??
48
+ (await env.model('stock.warehouse').search({ where: { company }, order: ['id asc'], limit: 1 }))
49
+ .ids[0] ??
48
50
  null;
49
- const stock = wh === null
50
- ? null
51
- : ((await env.model('stock.location').search({
52
- where: { warehouse: wh, usage: 'internal', parent: { isNull: true } },
53
- limit: 1,
54
- })).ids[0] ?? null);
51
+ const stock = wh === null ? null : await stockRoot(env, wh);
55
52
  const shared = async (usage) => (await env.model('stock.location').search({ where: { usage }, limit: 1 })).ids[0] ?? null;
53
+ // In a warehouse with steps, receipts go into Input and deliveries leave from Output (once they exist; confirming
54
+ // routes them there in any case).
55
+ const [steps] = wh === null ? [] : await env.model('stock.warehouse').browse([wh]).load({});
56
+ const step = async (name) => wh === null
57
+ ? null
58
+ : ((await env
59
+ .model('stock.location')
60
+ .search({ where: { warehouse: wh, step: name }, limit: 1 })).ids[0] ?? null);
56
61
  if (kind === 'receipt')
57
- return { warehouse: wh, source: await shared('vendor'), destination: stock };
62
+ return {
63
+ warehouse: wh,
64
+ source: await shared('vendor'),
65
+ destination: (steps !== undefined && steps.receptionSteps !== 'one' ? await step('input') : null) ??
66
+ stock,
67
+ };
58
68
  if (kind === 'delivery')
59
- return { warehouse: wh, source: stock, destination: await shared('customer') };
69
+ return {
70
+ warehouse: wh,
71
+ source: (steps !== undefined && steps.deliverySteps !== 'one' ? await step('output') : null) ??
72
+ stock,
73
+ destination: await shared('customer'),
74
+ };
60
75
  return { warehouse: wh, source: stock, destination: stock };
61
76
  }
62
77
  export const StockWarehouse = defineModel('stock.warehouse', {
@@ -72,6 +87,20 @@ export const StockWarehouse = defineModel('stock.warehouse', {
72
87
  code: f.char({ required: true, label: 'Short code' }),
73
88
  locations: f.one2many('stock.location', 'warehouse'),
74
89
  address: f.many2one('res.partner', { ondelete: 'set null' }),
90
+ /** Receipts in one step (into stock), two (Input, then stock) or three (Input, Quality control, then stock). */
91
+ receptionSteps: f.selection({ one: 'In one step', two: 'Input, then stock', three: 'Input, quality control, then stock' }, {
92
+ required: true,
93
+ default: 'one',
94
+ label: 'Receipts',
95
+ help: 'How many steps incoming goods go through before they reach stock.',
96
+ }),
97
+ /** Deliveries in one step, two (a pick into Output, then the delivery) or three (pick, pack, deliver). */
98
+ deliverySteps: f.selection({ one: 'In one step', two: 'Pick, then deliver', three: 'Pick, pack, then deliver' }, {
99
+ required: true,
100
+ default: 'one',
101
+ label: 'Deliveries',
102
+ help: 'How many steps outgoing goods go through: picked, packed and delivered.',
103
+ }),
75
104
  },
76
105
  sqlConstraints: {
77
106
  oneCode: { unique: ['company', 'code'], message: 'Another warehouse has this short code.' },
@@ -99,7 +128,23 @@ export const StockLocation = defineModel('stock.location', {
99
128
  adjustment: 'Inventory adjustment',
100
129
  production: 'Production',
101
130
  transit: 'In transit',
102
- }, { required: true, default: 'internal' }),
131
+ consumption: 'Internal use (consumed)',
132
+ }, {
133
+ required: true,
134
+ default: 'internal',
135
+ help: 'Only internal locations hold stock; the others are where goods come from or go to.',
136
+ }),
137
+ /** Goods on the road between warehouses (RFC 0032 §3.3): held as stock, not counted in the warehouse's. */
138
+ transit: f.boolean({
139
+ default: false,
140
+ label: 'Goods in transit',
141
+ help: 'Holds goods shipped from this warehouse to another and not received yet: the company’s stock, not counted in the warehouse’s.',
142
+ }),
143
+ /** The step of the warehouse's routes this location is for (its Input, Quality control, Packing or Output). */
144
+ step: f.selection({ input: 'Input', quality: 'Quality control', packing: 'Packing', output: 'Output' }, {
145
+ label: 'Step',
146
+ help: 'The step of the warehouse’s receipts or deliveries this location is used for.',
147
+ }),
103
148
  /**
104
149
  * `WH/Stock/Shelf 1`: the warehouse code and the names from the top (four levels by name; deeper ones start
105
150
  * with `…`). Shutro refuses a computed field that depends on itself, so it reads the stored names.
@@ -141,6 +186,7 @@ export const StockLocation = defineModel('stock.location', {
141
186
  });
142
187
  export const StockLot = defineModel('stock.lot', {
143
188
  label: 'Lot / serial number',
189
+ archivable: true,
144
190
  recName: 'name',
145
191
  order: ['expiryDate asc', 'name asc'],
146
192
  companyScoped: { required: true },
@@ -158,6 +204,7 @@ export const StockLot = defineModel('stock.lot', {
158
204
  scale: 4,
159
205
  store: true,
160
206
  label: 'On hand',
207
+ help: 'The quantity of this lot or serial number held in every location.',
161
208
  ...compute('stock.lot', 'qtyOnHand', ['quants.quantity'], (lots) => {
162
209
  for (const l of lots)
163
210
  l.qtyOnHand = [...l.quants].reduce((s, q) => s.plus(q.quantity), zero);
@@ -192,6 +239,7 @@ export const StockQuant = defineModel('stock.quant', {
192
239
  scale: 4,
193
240
  store: true,
194
241
  label: 'Reserved',
242
+ help: 'The part of the quantity on hand held for transfers waiting to go out.',
195
243
  ...compute('stock.quant', 'reserved', ['reservations.quantity'], (quants) => {
196
244
  for (const q of quants)
197
245
  q.reserved = [...q.reservations].reduce((s, r) => s.plus(r.quantity), zero);
@@ -201,6 +249,7 @@ export const StockQuant = defineModel('stock.quant', {
201
249
  scale: 4,
202
250
  store: true,
203
251
  label: 'Available',
252
+ help: 'The quantity on hand less what is reserved.',
204
253
  ...compute('stock.quant', 'available', ['quantity', 'reserved'], (quants) => {
205
254
  for (const q of quants)
206
255
  q.available = q.quantity.minus(q.reserved ?? zero);
@@ -279,6 +328,7 @@ export const StockMove = defineModel('stock.move', {
279
328
  scale: 4,
280
329
  store: true,
281
330
  label: 'In the product’s unit',
331
+ help: 'The line’s quantity converted to the product’s unit, as stock is counted.',
282
332
  ...compute('stock.move', 'productQty', [
283
333
  'quantity',
284
334
  'uom.name',
@@ -305,11 +355,15 @@ export const StockMove = defineModel('stock.move', {
305
355
  * quantity validates part of the line; the rest goes to a backorder.
306
356
  */
307
357
  quantityDone: f.decimal({ scale: 4, label: 'Done' }),
358
+ /** The line of the original transfer this one returns (RFC 0030 §3.2). */
359
+ returnOf: f.many2one('stock.move', { ondelete: 'restrict', label: 'Returns line' }),
360
+ returns: f.one2many('stock.move', 'returnOf', { label: 'Returned by' }),
308
361
  /** The done quantity in the product's unit. */
309
362
  doneQty: f.decimal({
310
363
  scale: 4,
311
364
  store: true,
312
365
  label: 'Done in the product’s unit',
366
+ help: 'The quantity actually moved, or the whole line when none is entered, in the product’s unit.',
313
367
  ...compute('stock.move', 'doneQty', [
314
368
  'quantity',
315
369
  'quantityDone',
@@ -335,11 +389,16 @@ export const StockMove = defineModel('stock.move', {
335
389
  }),
336
390
  /** Take this lot only (a customer's batch, a count's loss); otherwise the lots that expire first. */
337
391
  restrictLot: f.many2one('stock.lot', { ondelete: 'set null', label: 'Lot to take' }),
392
+ /** The document ordered for this line (make to order: `PO/2026/00012`, `MO/2026/00007`, `TR/2026/00031`). */
393
+ procurement: f.char({ label: 'Ordered on' }),
394
+ /** Where this line is put away inside the transfer's destination (a putaway rule's, or chosen). */
395
+ destination: f.many2one('stock.location', { ondelete: 'set null', label: 'Put away in' }),
338
396
  reservations: f.one2many('stock.reservation', 'move'),
339
397
  reserved: f.decimal({
340
398
  scale: 4,
341
399
  store: true,
342
400
  label: 'Reserved',
401
+ help: 'How much of this line is already set aside from stock.',
343
402
  ...compute('stock.move', 'reserved', ['reservations.quantity'], (moves) => {
344
403
  for (const m of moves)
345
404
  m.reserved = [...m.reservations].reduce((s, r) => s.plus(r.quantity), zero);
@@ -347,6 +406,11 @@ export const StockMove = defineModel('stock.move', {
347
406
  }),
348
407
  },
349
408
  methods: {
409
+ /**
410
+ * Each of these lines' stock value as it moved, by line, as a signed decimal string (positive in, negative out),
411
+ * for the stock ledger (RFC 0032 §3.3). Nothing here; `stock_account` overrides it with its valuation layers.
412
+ */
413
+ moveValues: method('stock.move', async () => new Map()),
350
414
  /**
351
415
  * What a backorder's line copies from each of these lines: the product, description and unit. A bridge adds
352
416
  * its link by overriding it (`sale_stock`: the order line), so the rest of a line stays tied to its origin.
@@ -481,7 +545,7 @@ async function applyMoves(ids, env) {
481
545
  source: true,
482
546
  destination: true,
483
547
  company: true,
484
- moves: { product: true, reservations: { quant: true } },
548
+ moves: { product: true, destination: true, reservations: { quant: true } },
485
549
  lotLines: { lot: true, product: true },
486
550
  });
487
551
  const out = new Map();
@@ -513,7 +577,7 @@ async function applyMoves(ids, env) {
513
577
  if (p.destination.usage === 'internal')
514
578
  add({
515
579
  product: m.product.id,
516
- location: p.destination.id,
580
+ location: m.destination?.id ?? p.destination.id,
517
581
  company,
518
582
  lot,
519
583
  quantity: take,
@@ -531,7 +595,7 @@ async function applyMoves(ids, env) {
531
595
  if (done.gt(0))
532
596
  add({
533
597
  product: m.product.id,
534
- location: p.destination.id,
598
+ location: m.destination?.id ?? p.destination.id,
535
599
  company,
536
600
  lot: null,
537
601
  quantity: done,
@@ -578,7 +642,8 @@ async function applyMoves(ids, env) {
578
642
  }
579
643
  add({
580
644
  product: orm.asId(product, 'product.product'),
581
- location: p.destination.id,
645
+ location: [...p.moves].find((m) => m.product.id === product)?.destination?.id ??
646
+ p.destination.id,
582
647
  company,
583
648
  lot,
584
649
  quantity: l.quantity,
@@ -650,6 +715,413 @@ async function applyMoves(ids, env) {
650
715
  }
651
716
  });
652
717
  }
718
+ const STEP_NAMES = {
719
+ input: 'Input',
720
+ quality: 'Quality control',
721
+ packing: 'Packing',
722
+ output: 'Output',
723
+ };
724
+ /**
725
+ * The warehouse's transit location (RFC 0032 §3.3): where goods shipped to another warehouse wait until they are
726
+ * received, made beside its stock location the first time it is needed.
727
+ */
728
+ export async function transitLocation(env, warehouse) {
729
+ return env.asSuperuser({ reason: 'warehouse transit location' }, async (su) => {
730
+ const found = await su
731
+ .withFlags({ activeTest: false })
732
+ .model('stock.location')
733
+ .search({ where: { warehouse, transit: true }, limit: 1 });
734
+ if (found.ids[0] !== undefined)
735
+ return found.ids[0];
736
+ const [wh] = await su.model('stock.warehouse').browse([warehouse]).load({});
737
+ const made = await su.model('stock.location').create([
738
+ {
739
+ name: 'Transit',
740
+ usage: 'internal',
741
+ warehouse,
742
+ company: wh?.company.id ?? su.companyId,
743
+ transit: true,
744
+ },
745
+ ]);
746
+ await su.flush();
747
+ return made.ids[0];
748
+ });
749
+ }
750
+ /** The warehouse's location for a step of its routes, made beside its stock location the first time it is needed. */
751
+ export async function stepLocation(env, warehouse, step) {
752
+ return env.asSuperuser({ reason: 'warehouse step location' }, async (su) => {
753
+ const found = await su
754
+ .withFlags({ activeTest: false })
755
+ .model('stock.location')
756
+ .search({ where: { warehouse, step }, limit: 1 });
757
+ if (found.ids[0] !== undefined)
758
+ return found.ids[0];
759
+ const [wh] = await su.model('stock.warehouse').browse([warehouse]).load({});
760
+ const made = await su.model('stock.location').create([
761
+ {
762
+ name: STEP_NAMES[step],
763
+ usage: 'internal',
764
+ warehouse,
765
+ company: wh?.company.id ?? su.companyId,
766
+ step,
767
+ },
768
+ ]);
769
+ await su.flush();
770
+ return made.ids[0];
771
+ });
772
+ }
773
+ /** A warehouse's stock location: its first top-level internal location that is not a step. */
774
+ async function stockRoot(env, warehouse) {
775
+ return ((await env.model('stock.location').search({
776
+ where: {
777
+ warehouse,
778
+ usage: 'internal',
779
+ parent: { isNull: true },
780
+ step: { isNull: true },
781
+ transit: { ne: true },
782
+ },
783
+ order: ['id asc'],
784
+ limit: 1,
785
+ })).ids[0] ?? null);
786
+ }
787
+ /**
788
+ * Before transfers are confirmed: a receipt into a warehouse's stock location goes into its Input when the
789
+ * warehouse receives in two or three steps, a delivery out of it leaves from its Output when it delivers in two or
790
+ * three. A location chosen inside the stock location is kept.
791
+ */
792
+ async function routeFirstStep(ids, env) {
793
+ const pickings = await env
794
+ .model('stock.picking')
795
+ .browse(ids)
796
+ .load({ source: { warehouse: true }, destination: { warehouse: true } });
797
+ for (const p of pickings) {
798
+ if (p.kind === 'receipt' && p.destination.warehouse !== null) {
799
+ const wh = p.destination.warehouse;
800
+ if (wh.receptionSteps === 'one' || p.destination.id !== (await stockRoot(env, wh.id)))
801
+ continue;
802
+ await env
803
+ .model('stock.picking')
804
+ .browse([p.id])
805
+ .write({ destination: await stepLocation(env, wh.id, 'input') });
806
+ }
807
+ else if (p.kind === 'delivery' && p.source.warehouse !== null) {
808
+ const wh = p.source.warehouse;
809
+ if (wh.deliverySteps === 'one' || p.source.id !== (await stockRoot(env, wh.id)))
810
+ continue;
811
+ await env
812
+ .model('stock.picking')
813
+ .browse([p.id])
814
+ .write({ source: await stepLocation(env, wh.id, 'output') });
815
+ }
816
+ }
817
+ await env.flush();
818
+ }
819
+ /** A chained step: an internal transfer of `lines` from `source` to `destination`, confirmed (reserving). */
820
+ async function stepTransfer(env, from, source, destination, lines, next) {
821
+ const made = await env.model('stock.picking').create([
822
+ {
823
+ kind: 'internal',
824
+ company: from.company,
825
+ warehouse: from.warehouse,
826
+ partner: from.partner,
827
+ source,
828
+ destination,
829
+ origin: from.origin,
830
+ next,
831
+ moves: { create: lines.map((l) => ({ ...l })) },
832
+ },
833
+ ]);
834
+ await env
835
+ .model('stock.picking')
836
+ .browse(made.ids)
837
+ .confirm();
838
+ return made.ids[0];
839
+ }
840
+ /**
841
+ * After deliveries are confirmed: one leaving from its warehouse's Output gets the steps before it — a pick from
842
+ * stock into Output (two steps), or a pick into Packing and a pack into Output (three) — confirmed, the pick
843
+ * reserving; each step is validated on its own and brings the next one its stock.
844
+ */
845
+ async function chainDeliveries(ids, env) {
846
+ await env.asSuperuser({ reason: 'delivery steps' }, async (su) => {
847
+ const pickings = await su
848
+ .model('stock.picking')
849
+ .browse(ids)
850
+ .load({ source: { warehouse: true }, moves: { product: true }, previousSteps: true });
851
+ for (const p of pickings) {
852
+ const wh = p.source.warehouse;
853
+ if (p.kind !== 'delivery' || p.source.step !== 'output' || wh === null)
854
+ continue;
855
+ if (p.previousSteps.length > 0 || wh.deliverySteps === 'one')
856
+ continue;
857
+ const stock = await stockRoot(su, wh.id);
858
+ if (stock === null)
859
+ continue;
860
+ const lines = p.moves.map((m) => ({
861
+ product: m.product.id,
862
+ name: m.name,
863
+ quantity: m.productQty ?? m.quantity,
864
+ procurement: m.procurement,
865
+ }));
866
+ const from = {
867
+ company: p.company.id,
868
+ warehouse: wh.id,
869
+ origin: p.origin ?? p.name,
870
+ partner: p.partner?.id ?? null,
871
+ };
872
+ if (wh.deliverySteps === 'three') {
873
+ const packing = await stepLocation(su, wh.id, 'packing');
874
+ const pack = await stepTransfer(su, from, packing, p.source.id, lines, p.id);
875
+ await stepTransfer(su, from, stock, packing, lines, pack);
876
+ }
877
+ else
878
+ await stepTransfer(su, from, stock, p.source.id, lines, p.id);
879
+ }
880
+ });
881
+ }
882
+ /**
883
+ * After transfers are validated: what came into a warehouse's Input goes on to Quality control (three steps) or to
884
+ * stock, and what passed Quality control to stock — each a new transfer of what was done, confirmed; a step with a
885
+ * next one (a pick before its pack or delivery) reserves that one, now that its stock is there.
886
+ */
887
+ async function chainOnValidate(ids, env) {
888
+ await env.asSuperuser({ reason: 'transfer steps' }, async (su) => {
889
+ const pickings = await su
890
+ .model('stock.picking')
891
+ .browse(ids)
892
+ .load({ destination: { warehouse: true }, moves: { product: true }, next: true });
893
+ // What was ordered for a delivery has come: the transfers waiting for it reserve it.
894
+ const documents = [...new Set([...pickings].flatMap((p) => [p.name, p.origin ?? '']))].filter((d) => d !== '');
895
+ if (documents.length > 0) {
896
+ const waiting = await (await su.model('stock.move').search({
897
+ where: { procurement: { in: documents }, 'picking.state': 'confirmed' },
898
+ })).load({ picking: true });
899
+ const ids = [...new Set(waiting.map((m) => m.picking.id))];
900
+ if (ids.length > 0)
901
+ await reserve(ids, su);
902
+ }
903
+ for (const p of pickings) {
904
+ if (p.next !== null && p.next.state === 'confirmed')
905
+ await reserve([p.next.id], su);
906
+ const wh = p.destination.warehouse;
907
+ const step = p.destination.step;
908
+ if (wh === null || (step !== 'input' && step !== 'quality') || p.next !== null)
909
+ continue;
910
+ const stock = await stockRoot(su, wh.id);
911
+ if (stock === null)
912
+ continue;
913
+ const to = step === 'input' && wh.receptionSteps === 'three'
914
+ ? await stepLocation(su, wh.id, 'quality')
915
+ : stock;
916
+ const lines = p.moves
917
+ .filter((m) => (m.doneQty ?? zero).gt(0))
918
+ .map((m) => ({ product: m.product.id, name: m.name, quantity: m.doneQty ?? zero }));
919
+ if (lines.length === 0)
920
+ continue;
921
+ const next = await stepTransfer(su, {
922
+ company: p.company.id,
923
+ warehouse: wh.id,
924
+ origin: p.origin ?? p.name,
925
+ partner: p.partner?.id ?? null,
926
+ }, p.destination.id, to, lines, null);
927
+ await su
928
+ .model('stock.picking')
929
+ .browse([p.id])
930
+ .write({ next: next });
931
+ }
932
+ await su.flush();
933
+ });
934
+ }
935
+ /**
936
+ * After deliveries are confirmed: each line of a product with a make-to-order rule in the warehouse it leaves from
937
+ * (other than dropshipping) gets what it needs ordered by that rule — on a transfer, a request for quotation or a
938
+ * production order — once; the line says on which document.
939
+ */
940
+ async function orderOnDemand(ids, env) {
941
+ await env.asSuperuser({ reason: 'make to order' }, async (su) => {
942
+ const pickings = await su
943
+ .model('stock.picking')
944
+ .browse(ids)
945
+ .load({ source: { warehouse: true }, moves: { product: true } });
946
+ const wanted = new Map();
947
+ for (const p of pickings) {
948
+ const wh = p.source.warehouse;
949
+ if (p.kind !== 'delivery' || wh === null)
950
+ continue;
951
+ for (const m of p.moves) {
952
+ if (m.procurement !== null)
953
+ continue;
954
+ const [rule] = (await su.model('stock.reorder').search({
955
+ where: {
956
+ product: m.product.id,
957
+ warehouse: wh.id,
958
+ trigger: 'order',
959
+ method: { ne: 'dropship' },
960
+ },
961
+ limit: 1,
962
+ })).ids;
963
+ if (rule === undefined)
964
+ continue;
965
+ const w = wanted.get(rule) ?? { quantity: zero, moves: [] };
966
+ wanted.set(rule, {
967
+ quantity: w.quantity.plus(m.productQty ?? m.quantity),
968
+ moves: [...w.moves, m.id],
969
+ });
970
+ }
971
+ }
972
+ if (wanted.size === 0)
973
+ return;
974
+ const made = await su
975
+ .model('stock.reorder')
976
+ .browse([...wanted.keys()])
977
+ .procure(new Map([...wanted].map(([id, w]) => [id, w.quantity.toString()])));
978
+ for (const [rule, w] of wanted) {
979
+ const document = made.get(rule);
980
+ if (document === undefined)
981
+ continue;
982
+ await su
983
+ .model('stock.move')
984
+ .browse(w.moves)
985
+ .write({ procurement: document });
986
+ await su
987
+ .model('stock.reorder')
988
+ .browse([rule])
989
+ .write({ lastOrder: document });
990
+ }
991
+ await su.flush();
992
+ });
993
+ }
994
+ /** After transfers are cancelled: the steps before them that are not done are cancelled too. */
995
+ async function cancelPreviousSteps(ids, env) {
996
+ const before = await env.model('stock.picking').search({
997
+ where: { next: { in: [...ids] }, state: { in: ['draft', 'confirmed'] } },
998
+ });
999
+ if (before.length > 0)
1000
+ await before.cancel();
1001
+ }
1002
+ /**
1003
+ * Before transfers into stock are validated: each line without a place of its own is put away where the most
1004
+ * specific putaway rule of its destination says — the product's rule first, then its category's (or a parent
1005
+ * category's), the lowest sequence first.
1006
+ */
1007
+ async function putAway(ids, env) {
1008
+ await env.asSuperuser({ reason: 'putaway' }, async (su) => {
1009
+ const pickings = await su
1010
+ .model('stock.picking')
1011
+ .browse(ids)
1012
+ .load({ destination: true, moves: { product: { category: true } } });
1013
+ for (const p of pickings) {
1014
+ if (p.destination.usage !== 'internal')
1015
+ continue;
1016
+ const rules = [
1017
+ ...(await (await su.model('stock.putaway').search({
1018
+ where: { location: p.destination.id },
1019
+ order: ['sequence asc', 'id asc'],
1020
+ })).load({ category: true })),
1021
+ ];
1022
+ if (rules.length === 0)
1023
+ continue;
1024
+ for (const m of p.moves) {
1025
+ if (m.destination !== null)
1026
+ continue;
1027
+ const categories = [];
1028
+ let c = m.product.category;
1029
+ while (c !== null && c !== undefined && categories.length < 10) {
1030
+ categories.push(c.id);
1031
+ const [up] = await su.model('product.category').browse([c.id]).load({ parent: true });
1032
+ c = up?.parent ?? null;
1033
+ }
1034
+ const rule = rules.find((r) => r.product?.id === m.product.id) ??
1035
+ categories
1036
+ .map((id) => rules.find((r) => r.product === null && r.category?.id === id))
1037
+ .find((r) => r !== undefined);
1038
+ if (rule !== undefined)
1039
+ await m.write({ destination: rule.destination.id });
1040
+ }
1041
+ }
1042
+ await su.flush();
1043
+ });
1044
+ }
1045
+ /**
1046
+ * A putaway rule: what arrives in `location` — of `product`, or of `category` (and the categories inside it) — is
1047
+ * put away in `destination`, a location inside it.
1048
+ */
1049
+ /** An addition or a deduction on a transfer's transport (RFC 0032 §3.3): unloading, weighbridge, a short weight… */
1050
+ export const StockPickingCharge = defineModel('stock.picking.charge', {
1051
+ label: 'Transport addition or deduction',
1052
+ order: ['picking asc', 'id asc'],
1053
+ access: { 'stock.user': ALL, 'stock.manager': [...ALL, 'export'] },
1054
+ fields: {
1055
+ picking: f.many2one('stock.picking', {
1056
+ required: true,
1057
+ ondelete: 'cascade',
1058
+ label: 'Transfer',
1059
+ }),
1060
+ name: f.char({ required: true, label: 'Description' }),
1061
+ kind: f.selection({ addition: 'Addition', deduction: 'Deduction' }, {
1062
+ required: true,
1063
+ default: 'addition',
1064
+ help: 'Added to the freight bill, or deducted from it.',
1065
+ }),
1066
+ amount: f.decimal({ scale: 2, required: true, default: '0' }),
1067
+ },
1068
+ sqlConstraints: {
1069
+ positive: {
1070
+ check: orm.sql `amount >= 0`,
1071
+ message: 'Amounts are positive; choose deduction instead.',
1072
+ },
1073
+ },
1074
+ });
1075
+ /** Goods that come with a transfer without being its lines (empty bags, pallets), kept for the record. */
1076
+ export const StockPickingExtra = defineModel('stock.picking.extra', {
1077
+ label: 'Extra product',
1078
+ order: ['picking asc', 'id asc'],
1079
+ access: { 'stock.user': ALL, 'stock.manager': [...ALL, 'export'] },
1080
+ fields: {
1081
+ picking: f.many2one('stock.picking', {
1082
+ required: true,
1083
+ ondelete: 'cascade',
1084
+ label: 'Transfer',
1085
+ }),
1086
+ product: f.many2one('product.product', { ondelete: 'restrict' }),
1087
+ name: f.char({ required: true, label: 'Description' }),
1088
+ quantity: f.decimal({ scale: 3, required: true, default: '1' }),
1089
+ note: f.char(),
1090
+ },
1091
+ });
1092
+ export const StockPutaway = defineModel('stock.putaway', {
1093
+ label: 'Putaway rule',
1094
+ order: ['location asc', 'sequence asc', 'id asc'],
1095
+ archivable: true,
1096
+ companyScoped: { required: true },
1097
+ access: { 'stock.user': READ, 'stock.manager': [...ALL, 'export', 'import'] },
1098
+ fields: {
1099
+ location: f.many2one('stock.location', {
1100
+ required: true,
1101
+ ondelete: 'cascade',
1102
+ label: 'When it arrives in',
1103
+ }),
1104
+ product: f.many2one('product.product', { ondelete: 'cascade' }),
1105
+ category: f.many2one('product.category', { ondelete: 'cascade', label: 'Product category' }),
1106
+ destination: f.many2one('stock.location', {
1107
+ required: true,
1108
+ ondelete: 'cascade',
1109
+ label: 'Put it away in',
1110
+ }),
1111
+ sequence: f.integer({ required: true, default: 10 }),
1112
+ },
1113
+ constraints: {
1114
+ inside: {
1115
+ ...check('stock.putaway', ['location', 'destination', 'product', 'category'], async (rules) => (await rules.load({ location: true, destination: true, product: true, category: true }))
1116
+ .filter((r) => (r.product === null) === (r.category === null) ||
1117
+ r.destination.usage !== 'internal' ||
1118
+ r.destination.id === r.location.id ||
1119
+ !String(r.destination.parentPath ?? '').startsWith(String(r.location.parentPath ?? '\u0000')))
1120
+ .map((r) => r.id)),
1121
+ message: 'A putaway rule is for a product or a category (one of them), into a location inside the one it arrives in.',
1122
+ },
1123
+ },
1124
+ });
653
1125
  /**
654
1126
  * The lots and serial numbers of a transfer: listed by hand on what comes into stock (an existing lot, or the name of
655
1127
  * a new one), recorded by the validation on what leaves it. The lot's history.
@@ -714,7 +1186,13 @@ export const StockPicking = defineModel('stock.picking', {
714
1186
  internal: 'Internal move',
715
1187
  adjustment: 'Inventory adjustment',
716
1188
  production: 'Production',
717
- }, { required: true, default: 'receipt', label: 'Type' }),
1189
+ dropship: 'Dropship',
1190
+ }, {
1191
+ required: true,
1192
+ default: 'receipt',
1193
+ label: 'Type',
1194
+ help: 'What the transfer does: brings goods in, sends them out, moves them inside or adjusts stock.',
1195
+ }),
718
1196
  partner: f.many2one('res.partner', { ondelete: 'set null', label: 'Contact' }),
719
1197
  warehouse: f.many2one('stock.warehouse', { ondelete: 'restrict' }),
720
1198
  source: f.many2one('stock.location', { required: true, ondelete: 'restrict', label: 'From' }),
@@ -736,13 +1214,65 @@ export const StockPicking = defineModel('stock.picking', {
736
1214
  lotLines: f.one2many('stock.lot.line', 'picking', { label: 'Lots and serial numbers' }),
737
1215
  /** The count this adjustment applies. */
738
1216
  count: f.many2one('stock.count', { ondelete: 'set null', label: 'Count' }),
1217
+ // Additional information (RFC 0032 §3.3): who handles it and how it travels.
1218
+ responsible: f.many2one('res.users', { ondelete: 'set null' }),
1219
+ carrier: f.char({ label: 'Carrier' }),
1220
+ trackingRef: f.char({ label: 'Tracking reference' }),
1221
+ weight: f.decimal({
1222
+ scale: 3,
1223
+ label: 'Weight (kg)',
1224
+ help: 'The lines’ products’ weight times their quantities.',
1225
+ store: true,
1226
+ ...compute('stock.picking', 'weight', ['moves.productQty', 'moves.product.weight'], (pickings) => {
1227
+ for (const p of pickings)
1228
+ p.weight = [...p.moves].reduce((s, m) => s.plus((m.product.weight ?? zero).times(m.productQty ?? zero)), zero);
1229
+ }),
1230
+ }),
1231
+ // Transport details at the gate (RFC 0032 §3.3).
1232
+ vehicleNumber: f.char({ label: 'Vehicle number' }),
1233
+ driverName: f.char({ label: 'Driver' }),
1234
+ driverMobile: f.char({ label: 'Driver’s mobile' }),
1235
+ transporter: f.many2one('res.partner', {
1236
+ ondelete: 'restrict',
1237
+ label: 'Transport vendor',
1238
+ help: 'Who carried the goods: their freight bill is drafted when the transfer is validated (with Accounting).',
1239
+ }),
1240
+ transportDate: f.date({ label: 'Transport date' }),
1241
+ gateIn: f.datetime({ label: 'Gate in' }),
1242
+ gateOut: f.datetime({ label: 'Gate out' }),
1243
+ freightAmount: f.decimal({
1244
+ scale: 2,
1245
+ label: 'Freight bill',
1246
+ help: 'What the transport vendor bills for this transfer.',
1247
+ }),
1248
+ deductFromSupplier: f.boolean({
1249
+ default: false,
1250
+ label: 'Deduct from the supplier',
1251
+ help: 'A receipt whose supplier bears part of the cost (freight agreed delivered, shortage, poor quality): a vendor refund is drafted for the deduction.',
1252
+ }),
1253
+ supplierDeduction: f.decimal({ scale: 2, label: 'Supplier deduction' }),
1254
+ charges: f.one2many('stock.picking.charge', 'picking', { label: 'Additions and deductions' }),
1255
+ extras: f.one2many('stock.picking.extra', 'picking', { label: 'Extra products' }),
1256
+ gateNote: f.text({ label: 'Gate and QC details' }),
1257
+ remarks: f.text(),
739
1258
  /** The transfer this one takes the rest of. */
740
1259
  backorderOf: f.many2one('stock.picking', { ondelete: 'set null', label: 'Backorder of' }),
741
1260
  backorders: f.one2many('stock.picking', 'backorderOf'),
1261
+ /** The delivery or receipt this one returns (RFC 0030 §3.2), and why. */
1262
+ returnOf: f.many2one('stock.picking', { ondelete: 'restrict', label: 'Return of' }),
1263
+ returns: f.one2many('stock.picking', 'returnOf', { label: 'Returns' }),
1264
+ returnReason: f.many2one('stock.return.reason', {
1265
+ ondelete: 'restrict',
1266
+ label: 'Return reason',
1267
+ }),
1268
+ /** The step this one brings its stock to (a pick's pack or delivery). */
1269
+ next: f.many2one('stock.picking', { ondelete: 'set null', label: 'Next step' }),
1270
+ previousSteps: f.one2many('stock.picking', 'next', { label: 'Steps before' }),
742
1271
  /** How much of what leaves an internal location is reserved; receipts are always ready. */
743
1272
  availability: f.selection({ none: 'Nothing reserved', partial: 'Partly reserved', full: 'Everything reserved' }, {
744
1273
  store: true,
745
1274
  label: 'Availability',
1275
+ help: 'How much of what leaves stock is already reserved; receipts are always ready.',
746
1276
  ...compute('stock.picking', 'availability', ['source.usage', 'moves.productQty', 'moves.reserved'], (pickings) => {
747
1277
  for (const p of pickings) {
748
1278
  const moves = [...p.moves];
@@ -760,6 +1290,7 @@ export const StockPicking = defineModel('stock.picking', {
760
1290
  status: f.selection({ draft: 'Draft', waiting: 'Waiting', ready: 'Ready', done: 'Done', cancelled: 'Cancelled' }, {
761
1291
  store: true,
762
1292
  label: 'Status',
1293
+ help: 'A confirmed transfer is ready once everything is reserved, otherwise it is waiting.',
763
1294
  ...compute('stock.picking', 'status', ['state', 'availability'], (pickings) => {
764
1295
  for (const p of pickings)
765
1296
  p.status =
@@ -775,6 +1306,7 @@ export const StockPicking = defineModel('stock.picking', {
775
1306
  state: f.state({
776
1307
  states: { draft: 'Draft', confirmed: 'Confirmed', done: 'Done', cancel: 'Cancelled' },
777
1308
  initial: 'draft',
1309
+ help: 'A confirmed transfer reserves its stock; validated, the goods have moved.',
778
1310
  transitions: {
779
1311
  confirm: {
780
1312
  from: ['draft'],
@@ -787,10 +1319,17 @@ export const StockPicking = defineModel('stock.picking', {
787
1319
  // The lines' checks run while the transfer is still a draft (created and confirmed at once).
788
1320
  before: records('stock.picking', async (pickings) => {
789
1321
  await pickings.env.flush();
1322
+ await pickings.env
1323
+ .model('stock.picking')
1324
+ .browse(pickings.ids)
1325
+ .routing();
1326
+ await routeFirstStep(pickings.ids, pickings.env);
790
1327
  }),
791
1328
  after: records('stock.picking', async (pickings) => {
792
1329
  if (await reserveOnConfirm(pickings.env))
793
1330
  await reserve(pickings.ids, pickings.env);
1331
+ await orderOnDemand(pickings.ids, pickings.env);
1332
+ await chainDeliveries(pickings.ids, pickings.env);
794
1333
  }),
795
1334
  },
796
1335
  /** "Check availability": reserve what has come in since. */
@@ -808,7 +1347,7 @@ export const StockPicking = defineModel('stock.picking', {
808
1347
  await unreserve(pickings.ids, pickings.env);
809
1348
  }),
810
1349
  },
811
- validate: {
1350
+ validate: emitting('stock.picking.done', {
812
1351
  from: ['confirmed'],
813
1352
  to: 'done',
814
1353
  // What is done must be reserved (out of stock), and something must be done.
@@ -820,14 +1359,19 @@ export const StockPicking = defineModel('stock.picking', {
820
1359
  }),
821
1360
  message: 'Not everything done is reserved: check availability, wait for the stock, or lower the done quantities.',
822
1361
  before: records('stock.picking', async (pickings) => {
1362
+ await putAway(pickings.ids, pickings.env);
823
1363
  await applyMoves(pickings.ids, pickings.env);
824
1364
  }),
825
- },
1365
+ after: records('stock.picking', async (pickings) => {
1366
+ await chainOnValidate(pickings.ids, pickings.env);
1367
+ }),
1368
+ }),
826
1369
  cancel: {
827
1370
  from: ['draft', 'confirmed'],
828
1371
  to: 'cancel',
829
1372
  after: records('stock.picking', async (pickings) => {
830
1373
  await unreserve(pickings.ids, pickings.env);
1374
+ await cancelPreviousSteps(pickings.ids, pickings.env);
831
1375
  }),
832
1376
  },
833
1377
  redraft: { from: ['cancel'], to: 'draft' },
@@ -842,6 +1386,12 @@ export const StockPicking = defineModel('stock.picking', {
842
1386
  * (`stock_account`: the stock's value posted to Accounting).
843
1387
  */
844
1388
  validated: method('stock.picking', async () => undefined),
1389
+ /**
1390
+ * Runs before these draft transfers are confirmed, in the confirmation's scope: where their lines go. Nothing
1391
+ * here; a bridge overrides it (`purchase_stock`: lines of dropshipped products leave the delivery for a dropship
1392
+ * from the vendor, on a request for quotation).
1393
+ */
1394
+ routing: method('stock.picking', async () => undefined),
845
1395
  /**
846
1396
  * What a backorder copies from each of these transfers: the type, contact, places, company, source document,
847
1397
  * date and note. A bridge adds its link by overriding it (`sale_stock`: the sales order).
@@ -859,6 +1409,7 @@ export const StockPicking = defineModel('stock.picking', {
859
1409
  origin: p.origin,
860
1410
  scheduledDate: p.scheduledDate,
861
1411
  note: p.note,
1412
+ next: p.next?.id ?? null,
862
1413
  });
863
1414
  return out;
864
1415
  }),
@@ -885,8 +1436,12 @@ export const StockPicking = defineModel('stock.picking', {
885
1436
  .filter((p) => p.source.id === p.destination.id ||
886
1437
  (p.kind === 'receipt' && p.destination.usage !== 'internal') ||
887
1438
  (p.kind === 'delivery' && p.source.usage !== 'internal') ||
1439
+ (p.kind === 'dropship' &&
1440
+ (p.source.usage !== 'vendor' || p.destination.usage !== 'customer')) ||
1441
+ // Internal moves go between stock locations, or out to an internal-use location (RFC 0032).
888
1442
  (p.kind === 'internal' &&
889
- (p.source.usage !== 'internal' || p.destination.usage !== 'internal')) ||
1443
+ (p.source.usage !== 'internal' ||
1444
+ (p.destination.usage !== 'internal' && p.destination.usage !== 'consumption'))) ||
890
1445
  (p.kind === 'adjustment' &&
891
1446
  !((p.source.usage === 'adjustment' && p.destination.usage === 'internal') ||
892
1447
  (p.source.usage === 'internal' && p.destination.usage === 'adjustment'))) ||
@@ -894,7 +1449,7 @@ export const StockPicking = defineModel('stock.picking', {
894
1449
  !((p.source.usage === 'production' && p.destination.usage === 'internal') ||
895
1450
  (p.source.usage === 'internal' && p.destination.usage === 'production'))))
896
1451
  .map((p) => p.id)),
897
- message: 'A transfer goes between two places: a receipt into stock, a delivery out of stock, an internal move between stock locations, an adjustment between stock and the adjustment location.',
1452
+ message: 'A transfer goes between two places: a receipt into stock, a delivery out of stock, an internal move between stock locations or out to internal use, an adjustment between stock and the adjustment location.',
898
1453
  },
899
1454
  },
900
1455
  });
@@ -932,6 +1487,7 @@ export const StockCountLine = defineModel('stock.count.line', {
932
1487
  scale: 4,
933
1488
  store: true,
934
1489
  label: 'Difference',
1490
+ help: 'What was counted less what was expected; empty until the line is counted.',
935
1491
  ...compute('stock.count.line', 'difference', ['expected', 'counted'], (lines) => {
936
1492
  for (const l of lines)
937
1493
  l.difference = l.counted === null ? null : l.counted.minus(l.expected ?? zero);
@@ -1071,6 +1627,7 @@ export const StockCount = defineModel('stock.count', {
1071
1627
  state: f.state({
1072
1628
  states: { draft: 'Draft', counting: 'Counting', done: 'Applied', cancel: 'Cancelled' },
1073
1629
  initial: 'draft',
1630
+ help: 'Started, the count lists what is expected; applied, the differences are adjusted in stock.',
1074
1631
  transitions: {
1075
1632
  /** Lists what the location holds (and inside it), with what is expected, for counting. */
1076
1633
  start: {
@@ -1112,14 +1669,14 @@ export const StockCount = defineModel('stock.count', {
1112
1669
  });
1113
1670
  }),
1114
1671
  },
1115
- apply: {
1672
+ apply: emitting('stock.count.applied', {
1116
1673
  from: ['counting'],
1117
1674
  to: 'done',
1118
1675
  requires: 'stock.count_apply',
1119
1676
  before: records('stock.count', async (counts) => {
1120
1677
  await applyCounts(counts.ids, counts.env);
1121
1678
  }),
1122
- },
1679
+ }),
1123
1680
  cancel: { from: ['draft', 'counting'], to: 'cancel' },
1124
1681
  redraft: { from: ['cancel'], to: 'draft' },
1125
1682
  },
@@ -1168,21 +1725,26 @@ export const StockScrap = defineModel('stock.scrap', {
1168
1725
  /** Where it is thrown away from (empty: the main warehouse's stock). */
1169
1726
  location: f.many2one('stock.location', { ondelete: 'restrict', label: 'From' }),
1170
1727
  lot: f.many2one('stock.lot', { ondelete: 'restrict', label: 'Lot / serial number' }),
1171
- reason: f.selection(SCRAP_REASONS, { required: true, default: 'damaged' }),
1728
+ reason: f.selection(SCRAP_REASONS, {
1729
+ required: true,
1730
+ default: 'damaged',
1731
+ help: 'Why the goods are thrown away.',
1732
+ }),
1172
1733
  note: f.text(),
1173
1734
  date: f.date({ required: true, default: (env) => env.today() }),
1174
1735
  picking: f.many2one('stock.picking', { ondelete: 'set null', label: 'Transfer' }),
1175
1736
  state: f.state({
1176
1737
  states: { draft: 'Draft', done: 'Scrapped', cancel: 'Cancelled' },
1177
1738
  initial: 'draft',
1739
+ help: 'Validated, the goods leave their location as a loss.',
1178
1740
  transitions: {
1179
- validate: {
1741
+ validate: emitting('stock.scrap.done', {
1180
1742
  from: ['draft'],
1181
1743
  to: 'done',
1182
1744
  before: records('stock.scrap', async (scraps) => {
1183
1745
  await scrapStock(scraps.ids, scraps.env);
1184
1746
  }),
1185
- },
1747
+ }),
1186
1748
  cancel: { from: ['draft'], to: 'cancel' },
1187
1749
  },
1188
1750
  }),
@@ -1265,10 +1827,195 @@ export const ProductStock = extendModel('product.product', {
1265
1827
  }),
1266
1828
  },
1267
1829
  });
1830
+ /**
1831
+ * A warehouse's stock location, and every internal location of the warehouse — the stock location and those inside
1832
+ * it, and the steps of its routes (Input, Quality control, Packing, Output): what is anywhere in them is the
1833
+ * warehouse's.
1834
+ */
1835
+ export async function warehouseStock(env, warehouse, company) {
1836
+ const root = (await defaultLocations(env, 'internal', warehouse, company)).source;
1837
+ if (root === null)
1838
+ return { root, inside: new Set() };
1839
+ const inside = await env
1840
+ .model('stock.location')
1841
+ .search({ where: { warehouse, usage: 'internal', transit: { ne: true } } });
1842
+ return { root, inside: new Set(inside.ids) };
1843
+ }
1844
+ /**
1845
+ * A reorder rule (RFC 0024 §2.6): keep `product` in `warehouse` between a minimum and a maximum. Its forecast — on
1846
+ * hand, less what is going out, plus what is coming in and what is on order — is refreshed hourly and on demand;
1847
+ * below the minimum it proposes enough to reach the maximum, in steps of `multiple`, with the reckoning spelled out.
1848
+ * How it is ordered is its method: **transfer** from another warehouse (here), **buy** from its vendor
1849
+ * (`purchase_stock`), **make** with the product's bill of materials (`production`).
1850
+ */
1851
+ export const StockReorder = defineModel('stock.reorder', {
1852
+ label: 'Reorder rule',
1853
+ recName: 'name',
1854
+ order: ['warehouse asc', 'name asc'],
1855
+ archivable: true,
1856
+ companyScoped: { required: true },
1857
+ tracking: ['minimum', 'maximum', 'method', 'vendor'],
1858
+ access: { 'stock.user': READ, 'stock.manager': [...ALL, 'export', 'import'] },
1859
+ fields: {
1860
+ name: f.char({
1861
+ store: true,
1862
+ label: 'Rule',
1863
+ ...compute('stock.reorder', 'name', ['product.name', 'warehouse.code'], (rules) => {
1864
+ for (const r of rules)
1865
+ r.name = `${r.product.name} (${r.warehouse.code})`;
1866
+ }),
1867
+ }),
1868
+ product: f.many2one('product.product', { required: true, ondelete: 'cascade' }),
1869
+ warehouse: f.many2one('stock.warehouse', { required: true, ondelete: 'cascade' }),
1870
+ minimum: f.decimal({ scale: 4, required: true, default: '0', label: 'Minimum' }),
1871
+ maximum: f.decimal({ scale: 4, required: true, default: '0', label: 'Maximum' }),
1872
+ /** Ordered in steps of this (a box of 12): the proposal is rounded up to it. */
1873
+ multiple: f.decimal({ scale: 4, required: true, default: '1', label: 'Order in steps of' }),
1874
+ /** Days from ordering to having it: the expected date of what is ordered. */
1875
+ leadDays: f.integer({ required: true, default: 0, label: 'Lead time (days)' }),
1876
+ method: f.selection({
1877
+ buy: 'Buy',
1878
+ make: 'Make',
1879
+ transfer: 'Transfer',
1880
+ dropship: 'Dropship (the vendor delivers to the customer)',
1881
+ }, {
1882
+ required: true,
1883
+ default: 'buy',
1884
+ label: 'Replenish by',
1885
+ help: 'Whether more is bought, made, transferred from another warehouse or shipped by the vendor straight to the customer.',
1886
+ }),
1887
+ /**
1888
+ * When it orders: when the forecast falls below the minimum, or for each delivery, what it needs (make to
1889
+ * order; dropshipping always is).
1890
+ */
1891
+ trigger: f.selection({ minmax: 'Below the minimum', order: 'For each delivery (make to order)' }, {
1892
+ required: true,
1893
+ default: 'minmax',
1894
+ label: 'Orders',
1895
+ help: 'Order when the forecast falls below the minimum, or for each delivery what it needs.',
1896
+ }),
1897
+ vendor: f.many2one('res.partner', { ondelete: 'set null', label: 'Vendor' }),
1898
+ sourceWarehouse: f.many2one('stock.warehouse', {
1899
+ ondelete: 'set null',
1900
+ label: 'From warehouse',
1901
+ }),
1902
+ /** Ordered by the server, hourly, whenever the forecast falls below the minimum. */
1903
+ auto: f.boolean({ default: false, label: 'Order automatically' }),
1904
+ snoozedUntil: f.date({ label: 'Snoozed until' }),
1905
+ onHand: f.decimal({ scale: 4, label: 'On hand' }),
1906
+ forecast: f.decimal({ scale: 4, label: 'Forecast' }),
1907
+ proposed: f.decimal({ scale: 4, label: 'To order' }),
1908
+ /** How the proposal was reckoned, in words. */
1909
+ explanation: f.text({ label: 'Why' }),
1910
+ refreshedAt: f.datetime({ label: 'Refreshed' }),
1911
+ /** The document the last order made (`P00012`, `TR/2026/00031`, `MO/2026/00007`). */
1912
+ lastOrder: f.char({ label: 'Last ordered' }),
1913
+ },
1914
+ methods: {
1915
+ /**
1916
+ * What is on order for these rules beyond the transfers (which the forecast reads itself), in the product's
1917
+ * unit (decimal strings), with the documents. Nothing here; a bridge adds its documents (`purchase_stock`: requests for quotation,
1918
+ * `production`: production orders).
1919
+ */
1920
+ pending: method('stock.reorder', async function () {
1921
+ return new Map(this.ids.map((id) => [id, []]));
1922
+ }),
1923
+ /**
1924
+ * Where each rule of these would order from, in words (`purchase_stock`: the vendor chosen and why, RFC 0030
1925
+ * §3.1), for the explanation; `proposed` is what each would order. Empty here.
1926
+ */
1927
+ sourcing: method('stock.reorder', async (_proposed) => new Map()),
1928
+ /**
1929
+ * Orders `quantities` (decimal strings, in the product's unit) for these rules; returns the document each one made. Transfers
1930
+ * are made here, one per pair of warehouses, confirmed; a bridge orders its method (`purchase_stock`: buy,
1931
+ * `production`: make) after `next()`.
1932
+ */
1933
+ procure: method('stock.reorder', async function (quantities) {
1934
+ const out = new Map();
1935
+ const groups = new Map();
1936
+ for (const r of await this.load({})) {
1937
+ if (r.method !== 'transfer' || !orm.toDecimal(quantities.get(r.id) ?? '0').gt(0))
1938
+ continue;
1939
+ if (r.sourceWarehouse === null)
1940
+ continue;
1941
+ const key = `${r.company.id}:${r.sourceWarehouse.id}:${r.warehouse.id}`;
1942
+ const g = groups.get(key) ?? {
1943
+ rules: [],
1944
+ from: r.sourceWarehouse.id,
1945
+ to: r.warehouse.id,
1946
+ company: r.company.id,
1947
+ };
1948
+ g.rules.push(r.id);
1949
+ groups.set(key, g);
1950
+ }
1951
+ for (const g of groups.values()) {
1952
+ const company = g.company;
1953
+ const from = await defaultLocations(this.env, 'internal', g.from, company);
1954
+ const to = await defaultLocations(this.env, 'internal', g.to, company);
1955
+ if (from.source === null || to.source === null)
1956
+ continue;
1957
+ const rules = await this.env
1958
+ .model('stock.reorder')
1959
+ .browse(g.rules)
1960
+ .load({ product: true });
1961
+ const made = await this.env.model('stock.picking').create([
1962
+ {
1963
+ kind: 'internal',
1964
+ company,
1965
+ warehouse: g.to,
1966
+ source: from.source,
1967
+ destination: to.source,
1968
+ origin: 'Replenishment',
1969
+ scheduledDate: this.env.today(),
1970
+ moves: {
1971
+ create: rules.map((r) => ({
1972
+ product: r.product.id,
1973
+ quantity: quantities.get(r.id) ?? '0',
1974
+ uom: r.product.uom?.id ?? null,
1975
+ })),
1976
+ },
1977
+ },
1978
+ ]);
1979
+ await made.confirm();
1980
+ const [picking] = await made.load({});
1981
+ for (const r of rules)
1982
+ out.set(r.id, picking?.name ?? '');
1983
+ }
1984
+ return out;
1985
+ }),
1986
+ },
1987
+ sqlConstraints: {
1988
+ oneRule: {
1989
+ unique: ['product', 'warehouse'],
1990
+ message: 'This product already has a reorder rule in this warehouse.',
1991
+ },
1992
+ levels: {
1993
+ check: orm.sql `minimum >= 0 AND maximum >= minimum AND multiple > 0 AND lead_days >= 0`,
1994
+ message: 'The minimum is zero or more, the maximum at least the minimum, the step and the lead time positive.',
1995
+ },
1996
+ },
1997
+ constraints: {
1998
+ howToOrder: {
1999
+ ...check('stock.reorder', ['method', 'vendor', 'sourceWarehouse', 'warehouse', 'product'], async (rules) => (await rules.load({
2000
+ product: true,
2001
+ warehouse: true,
2002
+ vendor: true,
2003
+ sourceWarehouse: true,
2004
+ }))
2005
+ .filter((r) => r.product.kind !== 'goods' ||
2006
+ ((r.method === 'buy' || r.method === 'dropship') && r.vendor === null) ||
2007
+ (r.method === 'dropship' && r.trigger !== 'order') ||
2008
+ (r.method === 'transfer' &&
2009
+ (r.sourceWarehouse === null || r.sourceWarehouse.id === r.warehouse.id)))
2010
+ .map((r) => r.id)),
2011
+ message: 'A rule keeps goods in stock; buying and dropshipping need a vendor (dropshipping is for each delivery), a transfer another warehouse to take from.',
2012
+ },
2013
+ },
2014
+ });
1268
2015
  const shared = (id, name, usage) => record('stock.location', id, { name, usage, company: null }, { noupdate: true });
1269
2016
  export const stockShutro = defineModule({
1270
2017
  name: 'stock',
1271
- version: '0.1.0',
2018
+ version: '0.5.0',
1272
2019
  depends: [productShutro, contactsShutro, messagingShutro],
1273
2020
  groups: [
1274
2021
  orm.defineGroup({ code: 'stock.user', label: 'Stockroom user', implies: ['product.user'] }),
@@ -1302,6 +2049,9 @@ export const stockShutro = defineModule({
1302
2049
  }),
1303
2050
  ],
1304
2051
  models: [
2052
+ StockReturnReason,
2053
+ StockPickingCharge,
2054
+ StockPickingExtra,
1305
2055
  StockWarehouse,
1306
2056
  StockLocation,
1307
2057
  StockLot,
@@ -1313,6 +2063,8 @@ export const stockShutro = defineModule({
1313
2063
  StockCount,
1314
2064
  StockCountLine,
1315
2065
  StockScrap,
2066
+ StockReorder,
2067
+ StockPutaway,
1316
2068
  ],
1317
2069
  extensions: [ProductStock],
1318
2070
  data: [
@@ -1321,5 +2073,7 @@ export const stockShutro = defineModule({
1321
2073
  shared('location_adjustment', 'Inventory adjustment', 'adjustment'),
1322
2074
  shared('location_production', 'Production', 'production'),
1323
2075
  shared('location_scrap', 'Scrap', 'adjustment'),
2076
+ // Goods issued for a section's own use leave stock here (RFC 0032 §3.1).
2077
+ shared('location_internal_use', 'Internal use', 'consumption'),
1324
2078
  ],
1325
2079
  });