shutro-erp 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account_asset/.kosh/bindings.d.ts +22 -0
- package/dist/account_asset/.kosh/bindings.js +15 -0
- package/dist/account_asset/.kosh/schema.d.ts +1755 -0
- package/dist/account_asset/board.d.ts +61 -0
- package/dist/account_asset/board.js +86 -0
- package/dist/account_asset/books.d.ts +42 -0
- package/dist/account_asset/books.js +398 -0
- package/dist/account_asset/demo.d.ts +7 -0
- package/dist/account_asset/demo.js +72 -0
- package/dist/account_asset/index.d.ts +9 -0
- package/dist/account_asset/index.js +335 -0
- package/dist/account_asset/module.d.ts +7622 -0
- package/dist/account_asset/module.js +230 -0
- package/dist/account_budget/.kosh/bindings.d.ts +22 -0
- package/dist/account_budget/.kosh/bindings.js +15 -0
- package/dist/account_budget/.kosh/schema.d.ts +1767 -0
- package/dist/account_budget/budget.d.ts +5 -0
- package/dist/account_budget/budget.js +142 -0
- package/dist/account_budget/demo.d.ts +6 -0
- package/dist/account_budget/demo.js +30 -0
- package/dist/account_budget/index.d.ts +4 -0
- package/dist/account_budget/index.js +223 -0
- package/dist/account_budget/module.d.ts +13863 -0
- package/dist/account_budget/module.js +167 -0
- package/dist/account_portal/.kosh/bindings.js +1 -1
- package/dist/account_portal/.kosh/schema.d.ts +123 -4
- package/dist/account_portal/module.d.ts +146 -0
- package/dist/accounting/.kosh/bindings.js +1 -1
- package/dist/accounting/.kosh/schema.d.ts +123 -4
- package/dist/accounting/index.d.ts +1 -1
- package/dist/accounting/index.js +131 -3
- package/dist/accounting/module.d.ts +296 -0
- package/dist/accounting/module.js +32 -1
- package/dist/approvals/.kosh/bindings.d.ts +22 -0
- package/dist/approvals/.kosh/bindings.js +15 -0
- package/dist/approvals/.kosh/schema.d.ts +611 -0
- package/dist/approvals/index.d.ts +18 -0
- package/dist/approvals/index.js +302 -0
- package/dist/approvals/mails.d.ts +25 -0
- package/dist/approvals/mails.js +82 -0
- package/dist/approvals/module.d.ts +1 -0
- package/dist/approvals/module.js +12 -0
- package/dist/approvals/web/History.d.ts +4 -0
- package/dist/approvals/web/History.js +13 -0
- package/dist/approvals/web/Inbox.d.ts +9 -0
- package/dist/approvals/web/Inbox.js +114 -0
- package/dist/approvals/web/Mine.d.ts +7 -0
- package/dist/approvals/web/Mine.js +27 -0
- package/dist/approvals/web/index.d.ts +13 -0
- package/dist/approvals/web/index.js +22 -0
- package/dist/approvals/web/messages.d.ts +2 -0
- package/dist/approvals/web/messages.js +119 -0
- package/dist/approvals/web/shared.d.ts +59 -0
- package/dist/approvals/web/shared.js +46 -0
- package/dist/attendance/.kosh/bindings.d.ts +22 -0
- package/dist/attendance/.kosh/bindings.js +15 -0
- package/dist/attendance/.kosh/schema.d.ts +1048 -0
- package/dist/attendance/days.d.ts +96 -0
- package/dist/attendance/days.js +430 -0
- package/dist/attendance/demo.d.ts +7 -0
- package/dist/attendance/demo.js +58 -0
- package/dist/attendance/index.d.ts +4 -0
- package/dist/attendance/index.js +513 -0
- package/dist/attendance/module.d.ts +3969 -0
- package/dist/attendance/module.js +412 -0
- package/dist/attendance/routes.d.ts +16 -0
- package/dist/attendance/routes.js +266 -0
- package/dist/attendance/web/Check.d.ts +8 -0
- package/dist/attendance/web/Check.js +40 -0
- package/dist/attendance/web/Kiosk.d.ts +8 -0
- package/dist/attendance/web/Kiosk.js +62 -0
- package/dist/attendance/web/PinButton.d.ts +7 -0
- package/dist/attendance/web/PinButton.js +29 -0
- package/dist/attendance/web/index.d.ts +13 -0
- package/dist/attendance/web/index.js +22 -0
- package/dist/attendance/web/messages.d.ts +2 -0
- package/dist/attendance/web/messages.js +61 -0
- package/dist/cli/init.js +32 -0
- package/dist/cli/templates.d.ts +1 -1
- package/dist/cli/templates.js +89 -0
- package/dist/contacts/module.js +13 -2
- package/dist/crm/.kosh/bindings.js +1 -1
- package/dist/crm/.kosh/schema.d.ts +2 -1
- package/dist/crm/module.d.ts +2 -0
- package/dist/crm/module.js +2 -1
- package/dist/documents/.kosh/bindings.d.ts +22 -0
- package/dist/documents/.kosh/bindings.js +15 -0
- package/dist/documents/.kosh/schema.d.ts +862 -0
- package/dist/documents/demo.d.ts +6 -0
- package/dist/documents/demo.js +22 -0
- package/dist/documents/documents.d.ts +98 -0
- package/dist/documents/documents.js +318 -0
- package/dist/documents/index.d.ts +30 -0
- package/dist/documents/index.js +442 -0
- package/dist/documents/module.d.ts +2781 -0
- package/dist/documents/module.js +214 -0
- package/dist/documents/web/Versions.d.ts +7 -0
- package/dist/documents/web/Versions.js +45 -0
- package/dist/documents/web/index.d.ts +11 -0
- package/dist/documents/web/index.js +16 -0
- package/dist/documents/web/messages.d.ts +2 -0
- package/dist/documents/web/messages.js +21 -0
- package/dist/event_account/.kosh/bindings.js +1 -1
- package/dist/event_account/.kosh/schema.d.ts +123 -4
- package/dist/event_account/module.d.ts +146 -0
- package/dist/expense/.kosh/bindings.d.ts +22 -0
- package/dist/expense/.kosh/bindings.js +15 -0
- package/dist/expense/.kosh/schema.d.ts +1299 -0
- package/dist/expense/demo.d.ts +7 -0
- package/dist/expense/demo.js +69 -0
- package/dist/expense/index.d.ts +3 -0
- package/dist/expense/index.js +495 -0
- package/dist/expense/module.d.ts +4747 -0
- package/dist/expense/module.js +647 -0
- package/dist/expense_account/.kosh/bindings.d.ts +22 -0
- package/dist/expense_account/.kosh/bindings.js +15 -0
- package/dist/expense_account/.kosh/schema.d.ts +1936 -0
- package/dist/expense_account/index.d.ts +3 -0
- package/dist/expense_account/index.js +74 -0
- package/dist/expense_account/module.d.ts +9153 -0
- package/dist/expense_account/module.js +318 -0
- package/dist/helpdesk/.kosh/bindings.d.ts +22 -0
- package/dist/helpdesk/.kosh/bindings.js +15 -0
- package/dist/helpdesk/.kosh/schema.d.ts +885 -0
- package/dist/helpdesk/demo.d.ts +7 -0
- package/dist/helpdesk/demo.js +65 -0
- package/dist/helpdesk/hours.d.ts +17 -0
- package/dist/helpdesk/hours.js +94 -0
- package/dist/helpdesk/index.d.ts +10 -0
- package/dist/helpdesk/index.js +461 -0
- package/dist/helpdesk/module.d.ts +2940 -0
- package/dist/helpdesk/module.js +326 -0
- package/dist/helpdesk/routes.d.ts +12 -0
- package/dist/helpdesk/routes.js +132 -0
- package/dist/helpdesk/sla.d.ts +37 -0
- package/dist/helpdesk/sla.js +226 -0
- package/dist/hr/index.d.ts +1 -1
- package/dist/hr/index.js +1 -1
- package/dist/l10n_bd/.kosh/bindings.js +1 -1
- package/dist/l10n_bd/.kosh/schema.d.ts +123 -4
- package/dist/l10n_bd/module.d.ts +146 -0
- package/dist/l10n_bd_payroll/.kosh/bindings.d.ts +22 -0
- package/dist/l10n_bd_payroll/.kosh/bindings.js +15 -0
- package/dist/l10n_bd_payroll/.kosh/schema.d.ts +2312 -0
- package/dist/l10n_bd_payroll/data.d.ts +47 -0
- package/dist/l10n_bd_payroll/data.js +347 -0
- package/dist/l10n_bd_payroll/index.d.ts +4 -0
- package/dist/l10n_bd_payroll/index.js +24 -0
- package/dist/l10n_bd_payroll/module.d.ts +12932 -0
- package/dist/l10n_bd_payroll/module.js +86 -0
- package/dist/l10n_in/.kosh/bindings.js +1 -1
- package/dist/l10n_in/.kosh/schema.d.ts +123 -4
- package/dist/l10n_in/module.d.ts +147 -0
- package/dist/mail/inbound/handle.js +6 -1
- package/dist/maintenance_stock/.kosh/bindings.js +1 -1
- package/dist/maintenance_stock/.kosh/schema.d.ts +77 -2
- package/dist/maintenance_stock/module.d.ts +788 -66
- package/dist/modules-sdk/index.d.ts +1 -1
- package/dist/modules-sdk/manifest.d.ts +39 -2
- package/dist/mrp/.kosh/bindings.js +1 -1
- package/dist/mrp/.kosh/schema.d.ts +77 -2
- package/dist/mrp/index.d.ts +1 -1
- package/dist/mrp/index.js +2 -1
- package/dist/mrp/module.d.ts +781 -54
- package/dist/mrp/module.js +64 -2
- package/dist/mrp_account/.kosh/bindings.js +1 -1
- package/dist/mrp_account/.kosh/schema.d.ts +198 -5
- package/dist/mrp_account/module.d.ts +4852 -2541
- package/dist/payment/.kosh/bindings.js +1 -1
- package/dist/payment/.kosh/schema.d.ts +125 -5
- package/dist/payment/index.d.ts +41 -0
- package/dist/payment/index.js +131 -74
- package/dist/payment/module.d.ts +210 -6
- package/dist/payment/module.js +19 -3
- package/dist/payment/settle.js +10 -1
- package/dist/payroll/.kosh/bindings.d.ts +22 -0
- package/dist/payroll/.kosh/bindings.js +15 -0
- package/dist/payroll/.kosh/schema.d.ts +1390 -0
- package/dist/payroll/compute.d.ts +35 -0
- package/dist/payroll/compute.js +398 -0
- package/dist/payroll/demo.d.ts +55 -0
- package/dist/payroll/demo.js +121 -0
- package/dist/payroll/formula.d.ts +62 -0
- package/dist/payroll/formula.js +320 -0
- package/dist/payroll/index.d.ts +230 -0
- package/dist/payroll/index.js +713 -0
- package/dist/payroll/module.d.ts +9390 -0
- package/dist/payroll/module.js +606 -0
- package/dist/payroll/routes.d.ts +10 -0
- package/dist/payroll/routes.js +112 -0
- package/dist/payroll_account/.kosh/bindings.d.ts +22 -0
- package/dist/payroll_account/.kosh/bindings.js +15 -0
- package/dist/payroll_account/.kosh/schema.d.ts +2308 -0
- package/dist/payroll_account/index.d.ts +3 -0
- package/dist/payroll_account/index.js +40 -0
- package/dist/payroll_account/module.d.ts +12396 -0
- package/dist/payroll_account/module.js +256 -0
- package/dist/permissions/approvals.d.ts +131 -9
- package/dist/permissions/approvals.js +662 -57
- package/dist/permissions/index.d.ts +1 -1
- package/dist/permissions/index.js +2 -2
- package/dist/permissions/models.js +191 -12
- package/dist/permissions/routes.d.ts +6 -1
- package/dist/permissions/routes.js +37 -4
- package/dist/permissions/web/ApprovalPanel.d.ts +5 -4
- package/dist/permissions/web/ApprovalPanel.js +39 -13
- package/dist/permissions/web/index.d.ts +6 -4
- package/dist/permissions/web/index.js +13 -4
- package/dist/permissions/web/messages.d.ts +2 -0
- package/dist/permissions/web/messages.js +43 -0
- package/dist/portal/index.js +1 -1
- package/dist/pos/.kosh/bindings.js +1 -1
- package/dist/pos/.kosh/schema.d.ts +123 -4
- package/dist/pos/index.js +4 -0
- package/dist/pos/module.d.ts +147 -0
- package/dist/pos_stock/.kosh/bindings.js +1 -1
- package/dist/pos_stock/.kosh/schema.d.ts +198 -5
- package/dist/pos_stock/module.d.ts +914 -46
- package/dist/product/.kosh/bindings.js +1 -1
- package/dist/product/.kosh/schema.d.ts +2 -1
- package/dist/product/index.js +13 -0
- package/dist/product/module.d.ts +2 -0
- package/dist/product/module.js +2 -1
- package/dist/project/.kosh/bindings.js +1 -1
- package/dist/project/.kosh/schema.d.ts +672 -1
- package/dist/project/index.d.ts +3 -1
- package/dist/project/index.js +901 -14
- package/dist/project/module.d.ts +9892 -390
- package/dist/project/module.js +1530 -13
- package/dist/project/routes.d.ts +44 -0
- package/dist/project/routes.js +314 -0
- package/dist/project/schedule.d.ts +72 -0
- package/dist/project/schedule.js +192 -0
- package/dist/project/web/Refresh.d.ts +8 -0
- package/dist/project/web/Refresh.js +29 -0
- package/dist/project/web/Schedule.d.ts +9 -0
- package/dist/project/web/Schedule.js +93 -0
- package/dist/project/web/Structure.d.ts +8 -0
- package/dist/project/web/Structure.js +86 -0
- package/dist/project/web/Workload.d.ts +8 -0
- package/dist/project/web/Workload.js +43 -0
- package/dist/project/web/index.d.ts +14 -0
- package/dist/project/web/index.js +25 -0
- package/dist/project/web/messages.d.ts +2 -0
- package/dist/project/web/messages.js +85 -0
- package/dist/project_account/.kosh/bindings.d.ts +22 -0
- package/dist/project_account/.kosh/bindings.js +15 -0
- package/dist/project_account/.kosh/schema.d.ts +2241 -0
- package/dist/project_account/index.d.ts +3 -0
- package/dist/project_account/index.js +27 -0
- package/dist/project_account/module.d.ts +11539 -0
- package/dist/project_account/module.js +76 -0
- package/dist/project_portal/.kosh/bindings.js +1 -1
- package/dist/project_portal/.kosh/schema.d.ts +672 -1
- package/dist/project_portal/module.d.ts +4798 -129
- package/dist/project_purchase/.kosh/bindings.d.ts +22 -0
- package/dist/project_purchase/.kosh/bindings.js +15 -0
- package/dist/project_purchase/.kosh/schema.d.ts +2320 -0
- package/dist/project_purchase/index.d.ts +9 -0
- package/dist/project_purchase/index.js +22 -0
- package/dist/project_purchase/module.d.ts +25147 -0
- package/dist/project_purchase/module.js +56 -0
- package/dist/purchase/.kosh/bindings.js +1 -1
- package/dist/purchase/.kosh/schema.d.ts +97 -4
- package/dist/purchase/module.d.ts +13 -2
- package/dist/purchase/module.js +10 -1
- package/dist/purchase_account/.kosh/bindings.js +1 -1
- package/dist/purchase_account/.kosh/schema.d.ts +126 -6
- package/dist/purchase_account/index.js +1 -0
- package/dist/purchase_account/module.d.ts +176 -1
- package/dist/purchase_account/module.js +13 -2
- package/dist/purchase_portal/.kosh/bindings.js +1 -1
- package/dist/purchase_portal/.kosh/schema.d.ts +97 -4
- package/dist/purchase_portal/module.d.ts +6 -1
- package/dist/purchase_stock/.kosh/bindings.js +1 -1
- package/dist/purchase_stock/.kosh/schema.d.ts +174 -5
- package/dist/purchase_stock/index.d.ts +1 -1
- package/dist/purchase_stock/index.js +9 -2
- package/dist/purchase_stock/module.d.ts +840 -68
- package/dist/purchase_stock/module.js +242 -6
- package/dist/purchase_stock_account/.kosh/bindings.js +1 -1
- package/dist/purchase_stock_account/.kosh/schema.d.ts +203 -7
- package/dist/purchase_stock_account/module.d.ts +8163 -5514
- package/dist/purchase_stock_account/module.js +11 -5
- package/dist/recruitment/.kosh/bindings.js +1 -1
- package/dist/recruitment/.kosh/schema.d.ts +2 -1
- package/dist/recruitment/module.d.ts +2 -0
- package/dist/recruitment/module.js +2 -1
- package/dist/sale_account/.kosh/bindings.js +1 -1
- package/dist/sale_account/.kosh/schema.d.ts +123 -4
- package/dist/sale_account/module.d.ts +147 -0
- package/dist/sale_portal/.kosh/bindings.js +1 -1
- package/dist/sale_portal/.kosh/schema.d.ts +2 -1
- package/dist/sale_portal/module.d.ts +1 -0
- package/dist/sale_project/.kosh/bindings.js +1 -1
- package/dist/sale_project/.kosh/schema.d.ts +673 -1
- package/dist/sale_project/module.d.ts +4800 -129
- package/dist/sale_project/module.js +17 -1
- package/dist/sale_stock/.kosh/bindings.js +1 -1
- package/dist/sale_stock/.kosh/schema.d.ts +77 -2
- package/dist/sale_stock/module.d.ts +789 -66
- package/dist/sales/.kosh/bindings.js +1 -1
- package/dist/sales/.kosh/schema.d.ts +2 -1
- package/dist/sales/index.js +4 -0
- package/dist/sales/module.d.ts +1 -0
- package/dist/sign/.kosh/bindings.d.ts +22 -0
- package/dist/sign/.kosh/bindings.js +15 -0
- package/dist/sign/.kosh/schema.d.ts +990 -0
- package/dist/sign/index.d.ts +14 -0
- package/dist/sign/index.js +350 -0
- package/dist/sign/module.d.ts +4478 -0
- package/dist/sign/module.js +158 -0
- package/dist/sign/sign.d.ts +82 -0
- package/dist/sign/sign.js +474 -0
- package/dist/stock/.kosh/bindings.js +1 -1
- package/dist/stock/.kosh/schema.d.ts +77 -2
- package/dist/stock/demo.d.ts +2 -1
- package/dist/stock/demo.js +28 -1
- package/dist/stock/index.d.ts +2 -1
- package/dist/stock/index.js +233 -4
- package/dist/stock/module.d.ts +2363 -837
- package/dist/stock/module.js +569 -14
- package/dist/stock/replenish.d.ts +38 -0
- package/dist/stock/replenish.js +176 -0
- package/dist/stock/web/Replenishment.d.ts +8 -0
- package/dist/stock/web/Replenishment.js +84 -0
- package/dist/stock/web/index.d.ts +4 -2
- package/dist/stock/web/index.js +6 -2
- package/dist/stock/web/messages.js +52 -0
- package/dist/stock_account/.kosh/bindings.js +1 -1
- package/dist/stock_account/.kosh/schema.d.ts +198 -5
- package/dist/stock_account/index.js +10 -0
- package/dist/stock_account/module.d.ts +969 -101
- package/dist/trade_finance/index.js +2 -0
- package/dist/trade_finance/module.js +2 -0
- package/dist/trade_finance_account/.kosh/bindings.js +1 -1
- package/dist/trade_finance_account/.kosh/schema.d.ts +123 -4
- package/dist/trade_finance_account/index.js +1 -0
- package/dist/trade_finance_account/module.d.ts +146 -0
- package/dist/trade_finance_account/module.js +1 -0
- package/dist/trade_finance_purchase/.kosh/bindings.js +1 -1
- package/dist/trade_finance_purchase/.kosh/schema.d.ts +97 -4
- package/dist/trade_finance_purchase/module.d.ts +6 -1
- package/dist/trade_finance_sale/.kosh/bindings.js +1 -1
- package/dist/trade_finance_sale/.kosh/schema.d.ts +2 -1
- package/dist/trade_finance_sale/module.d.ts +1 -0
- package/dist/ui/app.js +24 -12
- package/dist/ui/components/AppIcon.js +8 -1
- package/dist/ui/i18n/messages.d.ts +4 -0
- package/dist/ui/i18n/messages.js +8 -0
- package/dist/ui/views/FormView.js +4 -2
- package/dist/ui/views/KanbanView.js +9 -1
- package/dist/ui/views/ListView.js +4 -2
- package/dist/ui/views/widgets.js +7 -1
- package/dist/website/index.js +1 -0
- package/dist/website/module.js +1 -0
- package/dist/website_crm/.kosh/bindings.js +1 -1
- package/dist/website_crm/.kosh/schema.d.ts +2 -1
- package/dist/website_crm/module.d.ts +1 -0
- package/dist/website_sale/.kosh/bindings.d.ts +22 -0
- package/dist/website_sale/.kosh/bindings.js +15 -0
- package/dist/website_sale/.kosh/schema.d.ts +2284 -0
- package/dist/website_sale/couriers.d.ts +50 -0
- package/dist/website_sale/couriers.js +59 -0
- package/dist/website_sale/demo.d.ts +7 -0
- package/dist/website_sale/demo.js +90 -0
- package/dist/website_sale/growth.d.ts +31 -0
- package/dist/website_sale/growth.js +163 -0
- package/dist/website_sale/index.d.ts +49 -0
- package/dist/website_sale/index.js +538 -0
- package/dist/website_sale/module.d.ts +22027 -0
- package/dist/website_sale/module.js +397 -0
- package/dist/website_sale/shipments.d.ts +16 -0
- package/dist/website_sale/shipments.js +113 -0
- package/dist/website_sale/shop.d.ts +81 -0
- package/dist/website_sale/shop.js +649 -0
- package/dist/website_sale_stock/.kosh/bindings.d.ts +22 -0
- package/dist/website_sale_stock/.kosh/bindings.js +15 -0
- package/dist/website_sale_stock/.kosh/schema.d.ts +2681 -0
- package/dist/website_sale_stock/index.d.ts +9 -0
- package/dist/website_sale_stock/index.js +20 -0
- package/dist/website_sale_stock/module.d.ts +24998 -0
- package/dist/website_sale_stock/module.js +28 -0
- package/package.json +83 -2
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
* The data layer of the Purchase ↔ Stockroom bridge (RFC 0021): a confirmed purchase order gets its receipt — one
|
|
3
3
|
* Stockroom transfer with a line per goods line, in the line's unit, from the vendors into the company's main
|
|
4
4
|
* warehouse, expected on the order's arrival date — made once through the outbox (`purchase.order.confirmed`) and
|
|
5
|
-
* confirmed. The order shows its receipts and what is received; each line, its received quantity.
|
|
5
|
+
* confirmed. The order shows its receipts and what is received; each line, its received quantity. An order may name
|
|
6
|
+
* the warehouse it is delivered to (the main one otherwise). Reorder rules that buy (RFC 0024 §2.6) order on
|
|
7
|
+
* requests for quotation to their vendor — a draft one from replenishment gets the new lines — and count what is
|
|
8
|
+
* on requests and orders not received yet as on order. Dropshipped products leave a delivery as it is confirmed:
|
|
9
|
+
* a dropship transfer from the vendor to the customer, with its request for quotation (no receipt: the vendor
|
|
10
|
+
* delivers).
|
|
6
11
|
*/
|
|
7
12
|
import { productShutro } from '../product/index.js';
|
|
8
13
|
import { purchaseShutro } from '../purchase/index.js';
|
|
9
14
|
import { orm } from '../server/orm.js';
|
|
10
|
-
import { defaultLocations, stockShutro } from '../stock/index.js';
|
|
15
|
+
import { defaultLocations, inProductUnit, stockShutro } from '../stock/index.js';
|
|
11
16
|
import { compute, defineModule, extendModel, f } from './.kosh/bindings.js';
|
|
12
17
|
const zero = orm.toDecimal(0);
|
|
13
18
|
export const PickingPurchase = extendModel('stock.picking', {
|
|
@@ -15,6 +20,12 @@ export const PickingPurchase = extendModel('stock.picking', {
|
|
|
15
20
|
purchaseOrder: f.many2one('purchase.order', { ondelete: 'set null', label: 'Purchase order' }),
|
|
16
21
|
},
|
|
17
22
|
overrides: {
|
|
23
|
+
// Lines of products dropshipped from the warehouse leave the delivery for a dropship and its request.
|
|
24
|
+
routing: async function (next) {
|
|
25
|
+
await next();
|
|
26
|
+
const pickings = this;
|
|
27
|
+
await dropship(pickings.env, pickings.ids);
|
|
28
|
+
},
|
|
18
29
|
// A backorder stays with its order.
|
|
19
30
|
backorderValues: async function (next) {
|
|
20
31
|
const out = await next();
|
|
@@ -58,6 +69,14 @@ export const LineReceived = extendModel('purchase.order.line', {
|
|
|
58
69
|
export const OrderReceipts = extendModel('purchase.order', {
|
|
59
70
|
fields: {
|
|
60
71
|
receipts: f.one2many('stock.picking', 'purchaseOrder'),
|
|
72
|
+
/** The vendor delivers to the customer: the order's transfer is a dropship, never received in stock. */
|
|
73
|
+
dropship: f.boolean({ default: false, label: 'Dropship' }),
|
|
74
|
+
/** Where the goods are received (the company's main warehouse when empty). */
|
|
75
|
+
warehouse: f.many2one('stock.warehouse', {
|
|
76
|
+
ondelete: 'set null',
|
|
77
|
+
checkCompany: true,
|
|
78
|
+
label: 'Deliver to',
|
|
79
|
+
}),
|
|
61
80
|
receiptState: f.selection({
|
|
62
81
|
nothing: 'Nothing to receive',
|
|
63
82
|
to_receive: 'To receive',
|
|
@@ -91,7 +110,13 @@ export async function createReceiptFor(env, orderId) {
|
|
|
91
110
|
const [order] = await su
|
|
92
111
|
.model('purchase.order')
|
|
93
112
|
.browse([orm.asId(orderId, 'purchase.order')])
|
|
94
|
-
.load({
|
|
113
|
+
.load({
|
|
114
|
+
lines: { product: true, uom: true },
|
|
115
|
+
partner: true,
|
|
116
|
+
company: true,
|
|
117
|
+
receipts: true,
|
|
118
|
+
warehouse: true,
|
|
119
|
+
});
|
|
95
120
|
if (order === undefined || (order.state !== 'purchase' && order.state !== 'done'))
|
|
96
121
|
return null;
|
|
97
122
|
if ([...order.receipts].some((r) => r.state !== 'cancel'))
|
|
@@ -99,7 +124,7 @@ export async function createReceiptFor(env, orderId) {
|
|
|
99
124
|
const goods = order.lines.filter((l) => l.product.kind === 'goods');
|
|
100
125
|
if (goods.length === 0)
|
|
101
126
|
return null;
|
|
102
|
-
const places = await defaultLocations(su, 'receipt', null, order.company.id);
|
|
127
|
+
const places = await defaultLocations(su, 'receipt', order.warehouse?.id ?? null, order.company.id);
|
|
103
128
|
if (places.source === null || places.destination === null)
|
|
104
129
|
throw new orm.ValidationError('purchase.order', ['state'], `The company of ${order.name} has no warehouse to receive into.`, 'Add a warehouse in Stockroom › Configuration › Warehouses.');
|
|
105
130
|
const made = await su.model('stock.picking').create([
|
|
@@ -128,9 +153,220 @@ export async function createReceiptFor(env, orderId) {
|
|
|
128
153
|
return made.ids[0] ?? null;
|
|
129
154
|
});
|
|
130
155
|
}
|
|
156
|
+
const OPEN_RFQ = ['draft', 'sent', 'to_approve'];
|
|
157
|
+
const isoPlus = (today, days) => {
|
|
158
|
+
const d = new Date(`${today}T00:00:00Z`);
|
|
159
|
+
d.setUTCDate(d.getUTCDate() + days);
|
|
160
|
+
return d.toISOString().slice(0, 10);
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Draft deliveries' lines of products with a dropship rule in the warehouse they leave from go to a dropship
|
|
164
|
+
* transfer per vendor — vendors to the delivery's customer, with every link of the delivery and its lines (a sales
|
|
165
|
+
* order's) — and a request for quotation to that vendor, marked as a dropship, linked line by line. A delivery left
|
|
166
|
+
* with no lines becomes the dropship itself.
|
|
167
|
+
*/
|
|
168
|
+
async function dropship(env, ids) {
|
|
169
|
+
await env.asSuperuser({ reason: 'dropship' }, async (su) => {
|
|
170
|
+
const [vendors] = (await su.model('stock.location').search({ where: { usage: 'vendor' }, limit: 1 })).ids;
|
|
171
|
+
if (vendors === undefined)
|
|
172
|
+
return;
|
|
173
|
+
const pickings = await su
|
|
174
|
+
.model('stock.picking')
|
|
175
|
+
.browse(ids)
|
|
176
|
+
.load({
|
|
177
|
+
source: { warehouse: true },
|
|
178
|
+
company: true,
|
|
179
|
+
moves: { product: { purchaseTaxes: true }, uom: true },
|
|
180
|
+
});
|
|
181
|
+
for (const p of pickings) {
|
|
182
|
+
const wh = p.source.warehouse;
|
|
183
|
+
if (p.kind !== 'delivery' || p.state !== 'draft' || wh === null)
|
|
184
|
+
continue;
|
|
185
|
+
const moves = [...p.moves];
|
|
186
|
+
const byVendor = new Map();
|
|
187
|
+
for (const m of moves) {
|
|
188
|
+
const [rule] = await (await su.model('stock.reorder').search({
|
|
189
|
+
where: { product: m.product.id, warehouse: wh.id, method: 'dropship' },
|
|
190
|
+
limit: 1,
|
|
191
|
+
})).load({ vendor: true });
|
|
192
|
+
if (rule?.vendor === null || rule?.vendor === undefined)
|
|
193
|
+
continue;
|
|
194
|
+
const v = byVendor.get(rule.vendor.id) ?? { leadDays: rule.leadDays, moves: [] };
|
|
195
|
+
v.moves.push(m);
|
|
196
|
+
byVendor.set(rule.vendor.id, v);
|
|
197
|
+
}
|
|
198
|
+
if (byVendor.size === 0)
|
|
199
|
+
continue;
|
|
200
|
+
const total = byVendor.size === 1 && [...byVendor.values()][0]?.moves.length === moves.length;
|
|
201
|
+
const pickingValues = (await su.model('stock.picking').browse([p.id]).backorderValues()).get(p.id);
|
|
202
|
+
const today = su.today();
|
|
203
|
+
for (const [vendor, v] of byVendor) {
|
|
204
|
+
const made = await su.model('purchase.order').create([
|
|
205
|
+
{
|
|
206
|
+
partner: vendor,
|
|
207
|
+
company: p.company.id,
|
|
208
|
+
currency: p.company.currency.id,
|
|
209
|
+
warehouse: wh.id,
|
|
210
|
+
dropship: true,
|
|
211
|
+
dateOrder: today,
|
|
212
|
+
datePlanned: isoPlus(today, v.leadDays),
|
|
213
|
+
origin: p.origin ?? p.name,
|
|
214
|
+
lines: {
|
|
215
|
+
create: v.moves.map((m) => ({
|
|
216
|
+
product: m.product.id,
|
|
217
|
+
name: m.name ?? m.product.name,
|
|
218
|
+
quantity: m.quantity,
|
|
219
|
+
uom: m.uom?.id ?? m.product.uom?.id ?? null,
|
|
220
|
+
priceUnit: m.product.standardPrice,
|
|
221
|
+
taxes: { set: [...m.product.purchaseTaxes.ids] },
|
|
222
|
+
})),
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
]);
|
|
226
|
+
const order = made.ids[0];
|
|
227
|
+
const orderLines = (await su.model('purchase.order.line').search({
|
|
228
|
+
where: { order: order },
|
|
229
|
+
order: ['id asc'],
|
|
230
|
+
})).ids;
|
|
231
|
+
if (total) {
|
|
232
|
+
await su
|
|
233
|
+
.model('stock.picking')
|
|
234
|
+
.browse([p.id])
|
|
235
|
+
.write({ kind: 'dropship', source: vendors, purchaseOrder: order });
|
|
236
|
+
for (const [i, m] of v.moves.entries())
|
|
237
|
+
await su
|
|
238
|
+
.model('stock.move')
|
|
239
|
+
.browse([m.id])
|
|
240
|
+
.write({ purchaseLine: orderLines[i] ?? null });
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const lineValues = await su
|
|
244
|
+
.model('stock.move')
|
|
245
|
+
.browse(v.moves.map((m) => m.id))
|
|
246
|
+
.backorderValues();
|
|
247
|
+
const split = await su.model('stock.picking').create([
|
|
248
|
+
{
|
|
249
|
+
...pickingValues,
|
|
250
|
+
kind: 'dropship',
|
|
251
|
+
source: vendors,
|
|
252
|
+
next: null,
|
|
253
|
+
purchaseOrder: order,
|
|
254
|
+
moves: {
|
|
255
|
+
create: v.moves.map((m, i) => ({
|
|
256
|
+
...lineValues.get(m.id),
|
|
257
|
+
quantity: m.quantity,
|
|
258
|
+
purchaseLine: orderLines[i] ?? null,
|
|
259
|
+
})),
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
]);
|
|
263
|
+
await su
|
|
264
|
+
.model('stock.move')
|
|
265
|
+
.browse(v.moves.map((m) => m.id))
|
|
266
|
+
.unlink();
|
|
267
|
+
await su
|
|
268
|
+
.model('stock.picking')
|
|
269
|
+
.browse(split.ids)
|
|
270
|
+
.confirm();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
await su.flush();
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/** The warehouse an order is received into: its own, else the company's main one. */
|
|
277
|
+
async function receivedInto(env, warehouse, company) {
|
|
278
|
+
return warehouse ?? (await defaultLocations(env, 'receipt', null, company)).warehouse;
|
|
279
|
+
}
|
|
280
|
+
export const ReorderBuy = extendModel('stock.reorder', {
|
|
281
|
+
overrides: {
|
|
282
|
+
// Requests for quotation and orders not received yet (their receipt is still to be made) are on order.
|
|
283
|
+
pending: async function (next) {
|
|
284
|
+
const out = await next();
|
|
285
|
+
const rules = this;
|
|
286
|
+
const env = rules.env;
|
|
287
|
+
for (const r of await rules.load({ product: true })) {
|
|
288
|
+
const lines = await (await env.model('purchase.order.line').search({
|
|
289
|
+
where: {
|
|
290
|
+
product: r.product.id,
|
|
291
|
+
'order.company': r.company.id,
|
|
292
|
+
'order.state': { in: [...OPEN_RFQ, 'purchase', 'done'] },
|
|
293
|
+
},
|
|
294
|
+
})).load({ order: { receipts: true }, uom: true, product: { uom: true } });
|
|
295
|
+
const found = out.get(r.id) ?? [];
|
|
296
|
+
for (const l of lines) {
|
|
297
|
+
if (l.order.dropship)
|
|
298
|
+
continue;
|
|
299
|
+
if (!OPEN_RFQ.includes(l.order.state) && l.order.receipts.length > 0)
|
|
300
|
+
continue;
|
|
301
|
+
if ((await receivedInto(env, l.order.warehouse?.id ?? null, r.company.id)) !==
|
|
302
|
+
r.warehouse.id)
|
|
303
|
+
continue;
|
|
304
|
+
const qty = inProductUnit(l.quantity, l.uom, l.product.uom);
|
|
305
|
+
found.push({ quantity: qty.toString(), document: l.order.name });
|
|
306
|
+
}
|
|
307
|
+
out.set(r.id, found);
|
|
308
|
+
}
|
|
309
|
+
return out;
|
|
310
|
+
},
|
|
311
|
+
// Buying: one request for quotation per vendor and warehouse — a draft one from replenishment gets the lines.
|
|
312
|
+
procure: async function (next, quantities) {
|
|
313
|
+
const out = await next(quantities);
|
|
314
|
+
const rules = this;
|
|
315
|
+
const env = rules.env;
|
|
316
|
+
const today = env.today();
|
|
317
|
+
for (const r of await rules.load({ product: { purchaseTaxes: true }, company: true })) {
|
|
318
|
+
const qty = quantities.get(r.id);
|
|
319
|
+
if (r.method !== 'buy' || r.vendor === null || qty === undefined)
|
|
320
|
+
continue;
|
|
321
|
+
const arrival = new Date(`${today}T00:00:00Z`);
|
|
322
|
+
arrival.setUTCDate(arrival.getUTCDate() + r.leadDays);
|
|
323
|
+
const line = {
|
|
324
|
+
product: r.product.id,
|
|
325
|
+
name: r.product.name,
|
|
326
|
+
quantity: qty,
|
|
327
|
+
uom: r.product.uom?.id ?? null,
|
|
328
|
+
priceUnit: r.product.standardPrice,
|
|
329
|
+
taxes: { set: [...r.product.purchaseTaxes.ids] },
|
|
330
|
+
};
|
|
331
|
+
const [open] = await (await env.model('purchase.order').search({
|
|
332
|
+
where: {
|
|
333
|
+
partner: r.vendor.id,
|
|
334
|
+
company: r.company.id,
|
|
335
|
+
warehouse: r.warehouse.id,
|
|
336
|
+
state: 'draft',
|
|
337
|
+
origin: 'Replenishment',
|
|
338
|
+
},
|
|
339
|
+
order: ['id desc'],
|
|
340
|
+
limit: 1,
|
|
341
|
+
})).load({});
|
|
342
|
+
if (open !== undefined) {
|
|
343
|
+
await env.model('purchase.order.line').create([{ ...line, order: open.id }]);
|
|
344
|
+
out.set(r.id, open.name);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const made = await env.model('purchase.order').create([
|
|
348
|
+
{
|
|
349
|
+
partner: r.vendor.id,
|
|
350
|
+
company: r.company.id,
|
|
351
|
+
currency: r.company.currency.id,
|
|
352
|
+
warehouse: r.warehouse.id,
|
|
353
|
+
dateOrder: today,
|
|
354
|
+
datePlanned: arrival.toISOString().slice(0, 10),
|
|
355
|
+
origin: 'Replenishment',
|
|
356
|
+
lines: { create: [line] },
|
|
357
|
+
},
|
|
358
|
+
]);
|
|
359
|
+
const [order] = await made.load({});
|
|
360
|
+
out.set(r.id, order?.name ?? '');
|
|
361
|
+
}
|
|
362
|
+
await env.flush();
|
|
363
|
+
return out;
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
});
|
|
131
367
|
export const purchaseStockShutro = defineModule({
|
|
132
368
|
name: 'purchase_stock',
|
|
133
|
-
version: '0.
|
|
369
|
+
version: '0.2.0',
|
|
134
370
|
depends: [purchaseShutro, stockShutro, productShutro],
|
|
135
371
|
groups: [
|
|
136
372
|
orm.defineGroup({
|
|
@@ -140,5 +376,5 @@ export const purchaseStockShutro = defineModule({
|
|
|
140
376
|
}),
|
|
141
377
|
],
|
|
142
378
|
models: [],
|
|
143
|
-
extensions: [PickingPurchase, MovePurchase, LineReceived, OrderReceipts],
|
|
379
|
+
extensions: [PickingPurchase, MovePurchase, LineReceived, OrderReceipts, ReorderBuy],
|
|
144
380
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash:
|
|
1
|
+
// GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: 12ed1cd9243b4281
|
|
2
2
|
// Bindings of module `purchase_stock_account`: import the definition API from here to get types scoped to what it can see.
|
|
3
3
|
export { defineModel, defineModule, extendModel, f, replace } from '../../server/orm.js';
|
|
4
4
|
import { definitions } from '../../server/orm.js';
|