Commit Graph

1672 Commits

Author SHA1 Message Date
s-aga-r
f6ef3068d7 Merge branch 'develop' into subcontracting 2022-06-20 23:10:31 +05:30
marination
0320b59ea6 chore: Clear Progress section for completed logs & on_submit UX
- Delete `BOM Update Batch` table on 'Completed' log, to save space
- Hide Progress section on 'Completed' log
- Enqueue `on_submit` for 'Update Cost' job, getting leaf boms could take time for huge DBs. Users have to wait for screen to unfreeze.
- Add error handling to `process_boms_cost_level_wise` (Called via cron job and on submit, both in background)
2022-06-20 16:25:34 +05:30
Conor
74a782d81d
refactor: DB independent quoting and truthy/falsy values (#31358)
* refactor: DB independent quoting and truthy/falsy values

* style: reformat to black spec

* fix: ifnull -> coalesce

* fix: coalesce -> Coalesce

* fix: revert pypika comparison

* refactor: convert queries to QB

* fix: incorrect value types for query

`=` query makes no sense with list of values

* fix: remove warehouse docstatus condition

* fix: keep using base rate as rate

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-06-17 17:01:27 +05:30
rohitwaghchaure
2ec133df6d
Merge branch 'develop' into fixed-transferred-materials-are-not-consumed 2022-06-17 15:02:07 +05:30
Rushabh Mehta
c0f9b34ede
fix(minor): move variants to separate tab (#31354)
* fix(minor): move variants to separate tab

* fix(minor): variants tab

* fix(minor): add counts

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-06-15 16:08:05 +05:30
Ankush Menat
94ad66e55b
chore: revert naming to default (#31364) 2022-06-15 13:35:42 +05:30
rohitwaghchaure
a4c2c3e02f
Merge branch 'develop' into fixed-transferred-materials-are-not-consumed 2022-06-15 09:41:01 +05:30
s-aga-r
9a68af36ec Merge branch 'develop' into subcontracting 2022-06-14 19:13:10 +05:30
Conor
00ef499739
refactor: use db independent offset syntax (#31345)
* chore: use db independent offset syntax

* fix: typo

* style: reformat code to black spec

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-06-14 10:49:07 +05:30
Sagar Sharma
f755430098
Merge branch 'develop' into subcontracting 2022-06-13 03:00:53 -07:00
Ankush Menat
39ec0aca95
fix(UX): use doc.status for Job Card status (#31320)
fix(UX): use doc.status for JC status

- Use doc.status directly for indicator - single source of truth
- Update status to cancelled when doc is cancelled
2022-06-10 18:43:46 +05:30
Ankush Menat
16c8b7404d
Merge pull request #31072 from marination/perf-bom-update-tool
perf: BOM Update Tool
2022-06-09 17:04:00 +05:30
marination
3fa0a46f39 chore: Less hacky tests, versioning (replace bom) and clearing log data (update cost)
- Remove `auto_commit_on_many_writes` in `update_cost_in_level()` as commits happen every N BOMs
- Auto commit every 50 BOMs
- test: Remove hacky `frappe.flags.in_test` returns
- test: Enqueue `now` if in tests (for update cost and replace bom)
- Replace BOM: Copy bom object to `_doc_before_save` so that version.py finds a difference between the two
- Replace BOM: Add reference to version
- Update Cost: Unset `processed_boms` if Log is completed (useless after completion)
- test: `update_cost_in_all_boms_in_test` works close to actual prod implementation (only call Cron job manually)
- Test: use `enqueue_replace_bom`  so that test works closest to production behaviour

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-06-09 16:27:51 +05:30
Ankush Menat
d9a5213952
fix(ux): hide new version btn on unsaved BOM (#31297) 2022-06-09 15:33:18 +05:30
Sagar Sharma
f7a52f76d4
Merge branch 'develop' into subcontracting 2022-06-08 04:27:24 -07:00
marination
7e41d84a11 chore: get_valuation_rate sider fixes
- Use qb instead of db.sql
- Don't use `args` as argument for function
- Cleaner variable names
2022-06-08 14:01:04 +05:30
marination
9f2793ccf1 test: Fix test_update_bom_cost_in_all_boms
- Use base_rate for assertions as rate is subject to change due to conversion factor (USD)
2022-06-08 11:18:53 +05:30
Marica
ff0a6b7cbd
Merge branch 'develop' into perf-bom-update-tool 2022-06-07 14:49:59 +05:30
marination
6bde1bb5d2 test: Util to update cost in all BOMs
- Utility to update cost in all BOMs without cron jobs or background jobs (run immediately)
- Re-use util wherever all bom costs are to be updated
- Skip explicit commits if in test
- Specify company in test records (dirty data sometimes, company wh mismatch)
- Skip background jobs queueing if in test
2022-06-07 14:44:00 +05:30
Rohit Waghchaure
d94ff3ede8 test: test cases to cover batch, serialized raw materials 2022-06-06 17:57:52 +05:30
marination
15101190a6 chore: get_valuation_rate in bom.py must always return float & goto Item master if no bins 2022-06-06 17:54:13 +05:30
marination
934db57fdd chore: Miscellanous fixes/enhancements
- `get_valuation_rate`: if no bins are found return 0, SLEs do not exist either
- `get_valuation_rate`: Compute average valuation rate via query
- `get_rm_rate_map`: set order_by as None to avoid creating sort index (modified) each time query runs (seen in process list)
- BOM Update Batch: add status field and hide `boms_updated` so that  users can see progress without loading all updated boms (too much data)
- BOM Update Batch: set batch row status to completed after job runs
- BOM Update Log: remove `parent_boms` field (just pass parent boms to processing function) & remove Paused state (not used)
- Move job to long queue to avoid choking default queue
- `update_cost_in_boms`: use `get_doc` as each BOM is accessed only once. Use `for_update` to lock BOM row
- Commit after every 100 BOMs
2022-06-06 17:01:51 +05:30
Ankush Menat
ee5bc58e9b
fix(job card): only hold during draft state (#31243) 2022-06-06 16:27:25 +05:30
s-aga-r
992ba974e2 Merge branch 'develop' into subcontracting 2022-06-03 13:25:49 +05:30
marination
62857e3e08 feat: Track progress in Log Batch/Job wise
- This was done due to stale reads while the background jobs tried updating status of the log
- Added a table where all bom jobs within log will be tracked with what level they are processing
- Cron job will check if table jobs are all processed every 5 mins
- If yes, it will prepare parents and call `process_boms_cost_level_wise` to start next level
- If pending jobs, do nothing
- Current BOM Level is being tracked that helps adding rows to the table
- Individual bom cost jobs (that are queued) will process and update boms > will update BOM Update Batch table row with list of updated BOMs
2022-06-02 13:35:30 +05:30
Deepesh Garg
167cf7b49d fix: Remove domain restrcition from Manufacturing Workspace 2022-06-01 09:04:53 +05:30
marination
a62bc9b6c9 chore: Limit Update Cost jobs & db_update only if changed values
- If `Update Cost` job is ongoing, then block creation of new ones since all BOMs are updated
- `db_update` in `calculate_rm_cost` only if changed values to reduce redundant row updates
- Misc: Use variable for batch size
2022-05-31 16:00:29 +05:30
Ankush Menat
954dac88a8 fix: allow non-explosive recrusive BOMs
Recursion should be allowed as long as child item is not "exploded"
further by a BOM.
2022-05-30 10:40:13 +05:30
Ankush Menat
d224bf1d34 fix: only erase BOM when do_not_explode is set 2022-05-30 10:40:13 +05:30
Ankush Menat
b170cec2fe fix(ux): "New Version" button BOM
"duplicate" technically creates a new version but that's not intuitive
at all.
2022-05-30 10:40:12 +05:30
Ankush Menat
933434c3ea chore: format 2022-05-29 22:09:32 +05:30
marination
978ba5238f fix: Safe cast row.rate (in case of faulty exploded items, edge case but oh well) 2022-05-27 21:59:59 +05:30
marination
2de2491e17 perf: get_next_higher_level_boms
- Separate getting dependants and checking if they are valid (loop within loop led to redundant processing that slowed down function)
- Adding to above, the same dependant(parent) was repeatedly processed as many children shared it. Expensive.
- Use a parent-child map similar to child-parent map to check if all children are resolved
- `map.get()` reduced time: 10 mins -> 0.9s~1 second (as compared to `get_cached_doc` or query)
- Total time: 17 seconds to process 6599 leaf boms and 4.2L parent boms
- Previous Total time: >10 mins (I terminated it due to not wanting to waste time XD)
2022-05-27 20:33:14 +05:30
MOHAMMED NIYAS
7ff8acac51
fix: date filter on quality inspection report (#31148)
* fix: date filter

fix from date to to date filter btw those days

* fix: remove unnecessary conditions

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-05-27 17:13:14 +05:30
marination
5949946265 chore: Change BOM Progress field types to Long Text 2022-05-27 17:04:21 +05:30
marination
eabd8290d4 feat: Only update exploded items rate and amount
- Generate RM-Rate map from Items table (will include subassembly items with rate)
- Function to reset exploded item rate from above map
- `db_update` exploded item rate only if rate is changed
- Via Update Cost, only update exploded items rate, do not regenerate table again
- Exploded Items are regenerated on Save and Replace BOM job
- `calculate_exploded_cost` is run only via non doc events (Update Cost button, Update BOMs Cost Job)
2022-05-27 14:32:58 +05:30
Sagar Sharma
61296a0658 fix: Subcontracting through Production Plan 2022-05-26 15:08:16 +05:30
Sagar Sharma
4ff734c25a
Merge branch 'develop' into subcontracting 2022-05-25 12:32:33 +05:30
marination
9f5f18e94d style: Update docstrings and fix/add type hints + Collapsible progress section in Log 2022-05-25 11:22:13 +05:30
marination
ab2d95a74d feat: Level-wise BOM cost updation
- Process BOMs level wise and Pause after level is complete
- Cron job will resume Paused jobs, which will again process the new level and pause at the end
- This will go on until all BOMs are updated
- Added Progress section with fields to track updated BOMs in Log
- Cleanup: Add BOM Updation utils file to contain helper functions/sub-functions
- Cleanup: BOM Update Log file will only contain functions that are in direct context of the Log

Co-authored-by: Gavin D'souza <gavin18d@gmail.com>
2022-05-25 11:21:01 +05:30
Sagar Sharma
6e5effc1b0
Merge branch 'develop' into subcontracting 2022-05-23 11:35:50 +05:30
marination
9f6e10663b chore: Run _validate_over_transfer only if excess transfer is blocked in settings 2022-05-23 11:05:55 +05:30
Ankush Menat
1a58b788e5 Merge branch 'develop' into jc-excess-transfer-config 2022-05-21 14:32:44 +05:30
Ankush Menat
66cf9aa344 fix: creation of corrective job card fails
This used to fail because sub_operations is a child table that's not
initalized by default till v13, in develop branch we init tables with
empty list.
2022-05-21 14:01:30 +05:30
Ankush Menat
e625394488 test: simplify job card tests 2022-05-21 14:01:28 +05:30
Sagar Sharma
213113bc00 Merge branch 'develop' into subcontracting 2022-05-20 12:13:13 +05:30
Sagar Sharma
92625902ad refactor!: BOM 2022-05-20 10:45:34 +05:30
Sagar Sharma
409df263e8 refactor!: change "is_subcontracted" field type from "Select" to "Check" 2022-05-20 10:45:33 +05:30
marination
90d4dc0cd6 fix: test_work_order_with_non_stock_item
- Use the right price list and currency to avoid rate conversion (1000/62.9), since rates are reset correctly now
- Use RM rate based on Price List in BOM. Non stock item has no valuation
2022-05-20 03:12:42 +05:30
marination
dd99c00eb6 fix: Get fresh RM rate in calculate_rm_cost 2022-05-19 21:48:24 +05:30
marination
9a7e9d902d perf: Use cached doc instead of get_doc
- Doc is only used to iterate over items(which wont change) and change rate/amount of rows
- These changes are inserted in db via `db_update`, so no harm
- Tested locally: refetching cached doc after db update, reflects fresh data.
2022-05-19 21:24:31 +05:30
marination
9dc3083088 fix: Call calculate_cost for Draft BOM and typo in argument 2022-05-19 20:33:48 +05:30
marination
5932e9d78a fix: DB update child items, remove redundancy, fix perf
- Move `get_boms_in_bottom_up_order` in bom update tool’s file
- Remove repeated rm cost update from `update_cost`. `calculate_cost` handles RM cost update
- db_update children in `calculate_cost` optionally
- Don’t call `update_exploded_items` and regenerate exploded items in `update_cost`. They will stay the same (except cost)
2022-05-19 20:22:13 +05:30
Ankush Menat
1de6b14d15
fix: remove "scrap %" field (#31069)
This does nothing, there's scrap items table below that's actually used
for specifying scrap.
2022-05-19 14:25:16 +05:30
marination
b6e46eea80 perf: get_boms_in_bottom_up_order
- Create child-parent map once and fetch value from child key to get parents
- Get parents recursively for a leaf node (get all ancestors)
- Approx. 44 secs for 4lakh 70k boms
2022-05-18 13:00:00 +05:30
marination
e07ce6efe0 fix: Job Card excess transfer behaviour
- Block excess transfer of items if not allowed in settings
- Behaviour made consistent with js behaviour (button disappears if not pending and not allowed in settings)
- Test for same case
2022-05-17 17:39:45 +05:30
marination
90a8e924f5 fix: set_missing_values in SE and re-use the same on all SE mappings
- `set_missing_values` in SE will set actual qty, transfer qty and calculate rate/amount
- Re-use `set_missing_values` wherever SE is doc is being mapped
2022-05-11 14:54:22 +05:30
Rushabh Mehta
548afba8bb
fix(minor): update frappe.error_log to new API (#30864)
* fix(minor): update frappe.error_log to new API

* refactor: changes for updated log_error api

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-05-02 15:04:26 +05:30
Ankush Menat
7d2587c0a9 fix: nullish check and table name 2022-04-26 11:03:32 +05:30
HENRY Florian
143786aaa0
fix: Must not be able to start Job Card if it is related to Work Order that is not started yet (#29072)
* fix: Cannot start Job strat if related to Work Order not started yet

* fix: Cannot start Job strat if related to Work Order not started yet

* test

* test

* fix siders

* PR review

* chore: Code cleanup

- Better short circuit for if condition (make it such that both conditions dont always have to be computed)
- Remove `r.message` extraction by avoiding `then()`

* chore: Remove unnecessary json change

Co-authored-by: marination <maricadsouza221197@gmail.com>
2022-04-20 12:29:52 +05:30
marination
6315acc450 fix: Map correct company to PO made via Prod Plan (subcontract) 2022-04-13 11:47:58 +05:30
marination
2777c5c67c fix: Map Production Plan company in subassembly WO created from it 2022-04-12 14:30:01 +05:30
marination
5aa60bb651 test: Multiple RM transfer in separate Stock Entries
- Added test and acceptance of 0 as For Quantity in test helper
2022-04-11 16:44:55 +05:30
marination
be2e5ce966 style: Missing Semicolon 2022-04-11 15:32:57 +05:30
marination
dfff4beaf4 fix: Handle multiple item transfer in separate SEs against WO
- Check for pending qty in child items to show/hide "Start" button
- If no qty needed to transfer (FG qty is fulfilled), but RM qty pending: map pending in SE with For Quantity = 0
2022-04-11 14:10:57 +05:30
Ankush Menat
49560d20bc
fix: remove bad defaults from BOM operation (#30644)
[skip ci]
2022-04-08 11:23:02 +05:30
Ankush Menat
8e425252c4 chore: typo 2022-04-06 18:27:41 +05:30
Ankush Menat
eebcf2a9f1
fix: only trigger onload checks on saved docs (#30603) 2022-04-06 18:13:55 +05:30
Ankush Menat
52eb0a93bb
Merge pull request #30528 from s-aga-r/is-subcontracted-fieldtype
refactor!: change "is_subcontracted" field type from "Select" to "Check"
2022-04-04 14:01:20 +05:30
Ankush Menat
a896895a9e fix: bulk fix (~330) missing translations 2022-04-04 13:59:51 +05:30
Sagar Sharma
d074c93ac7 refactor!: change "is_subcontracted" field type from "Select" to "Check" 2022-04-01 13:22:44 +05:30
marination
2fece523f6 chore: Added BOM std filters and update type in List View 2022-03-31 12:55:48 +05:30
Marica
f482b184a0
Merge branch 'develop' into bom-update-tool 2022-03-31 12:42:56 +05:30
marination
a945484af4 test: Added test for 2 more validations
- Covers full validate function
2022-03-30 18:20:54 +05:30
marination
620575a901 fix: Type Annotations, Redundancy, etc.
- Renamed public function`update_new_bom` to `update_new_bom_in_bom_items`
- Replaced `get_cached_doc` with `get_doc`
- Removed click progress bar (drive through update log)
- Removed `bom_obj.update_new_bom()`, was redundant. Did same job as `update_new_bom_in_bom_items`
- Removed `update_new_bom()` in `bom.py`, unused.
- Prettier query formatting
- `update_type` annotated as non optional Literal
- Removed redundant use of JobTimeoutException
- Corrected type annotations in `create_bom_update_log()`
2022-03-30 18:03:52 +05:30
mergify[bot]
89a9afab94
fix: cast array slice index integer while splitting serial_nos array (#30468) (#30496)
(cherry picked from commit 3f3717952c94af428c3d4c919aceb6b8cbae7679)

Co-authored-by: Anoop <anoop@earthianslive.com>
2022-03-30 17:00:28 +05:30
marination
ebf00946c9 fix: Semgrep
- Explain explicit commits and skip semgrep
- Format client side translated string correctly
2022-03-30 13:22:29 +05:30
marination
79495679e2 fix: Auto format bom_update_log.py 2022-03-30 13:08:58 +05:30
marination
1d1e925bcf test: API hit via BOM Update Tool
- test creation of log and it's impact
2022-03-30 13:01:01 +05:30
marination
b5ad626d23 fix: Linter 2022-03-30 10:22:05 +05:30
marination
fa3b953cf7 test: idx mapping correctness 2022-03-29 13:54:14 +05:30
marination
639d380c1f chore: Remove redundant idx query and value setting
- idx can be removed from `select_columns` as it is already in the main query
- setting idx to '' is not required as it is not used further
2022-03-28 21:00:00 +05:30
Ankush Menat
63d892454b Merge branch 'develop' into bom-update-tool 2022-03-28 20:28:21 +05:30
Ankush Menat
494bd9ef78 style: format code with black 2022-03-28 18:52:46 +05:30
Ankush Menat
8dff4d66a4
fix: bom valuation - handle lack of LPP (#30454) 2022-03-28 18:18:23 +05:30
Ankush Menat
0534cf6c9c
fix: show subassembly table always (#30422)
[skip ci]
2022-03-25 19:03:33 +05:30
Ankush Menat
d4ee31dc8f fix: consider all existing PO items
When this is sent from API/client side doesn't send temporary_name it
can be flaky. Hence, use all available names for validation.
2022-03-24 17:58:22 +05:30
Ankush Menat
5b1d6055e6 fix: subassembly items linked to temporary name
Production Plan tables for po_items and sub_assembly_items are prepared
client side so both dont exist at time of first save or modifying and
hence any "links" created are invalid. This change retains temporary
name so it can be relinked server side after naming is performed.

Co-Authored-By: Marica <maricadsouza221197@gmail.com>
2022-03-24 15:00:05 +05:30
Ankush Menat
3d43c437ad fix: only validate qty for main non-subassy items 2022-03-24 15:00:05 +05:30
Ankush Menat
6418dc1606 fix: make auto created job cards "Open" 2022-03-23 15:50:46 +05:30
Ankush Menat
e1f5620654 fix: material transfer status should be before WIP 2022-03-23 15:50:46 +05:30
Raffael Meyer
0a015b7f70
refactor: remove redundant if-statement (#30311) 2022-03-20 19:29:41 +05:30
marination
f3715ab382 fix: Test, Sider and Added button to access log from Tool 2022-03-17 17:43:12 +05:30
marination
3e3af95712 fix: Sider and Linter 2022-03-17 15:03:20 +05:30
marination
8aff75f8e8 feat: List View indicators for Log and Error Log link in log 2022-03-17 12:58:09 +05:30
marination
cff91558d4 chore: Polish error handling and code sepration
- Added Typing
- Moved all job business logic to bom update log
- Added `run_bom_job` that handles errors and runs either of two methods
- UX: Replace button disabled until both inputs are filled
- Show log creation message on UI for correctness
- APIs return log document as result
- Converted raw sql to QB
2022-03-17 12:32:37 +05:30
marination
4283a13e5a feat: BOM Update Log
- Created BOM Update Log that will handle queued job status and failures
- Moved validation and BG job to thus new doctype
- BOM Update Tool only works as an endpoint
2022-03-16 19:47:25 +05:30
mergify[bot]
e8310c6dec
fix: Job Card sub operations status and list view (backport #30243) (#30256)
* fix: show status in job card list view in Draft mode

(cherry picked from commit fa32fc3c832196004154055ac1b2334d6202c261)

* fix: job card - sub operations table status misbehaviour on pause / resume Job Card

(cherry picked from commit 7b8723445ee695e88590bb833f60a0c4731106fa)

Co-authored-by: Anoop Kurungadam <anoop@earthianslive.com>
2022-03-15 15:48:15 +05:30
Ankush Menat
8e559f01c8 test: refactor BOM quality template test 2022-03-14 18:28:08 +05:30
Florian HENRY
9415229e8d fix: BOM - clear Quality Inspection Template according to Inspection Quality Required
Squashed commit of the following:

commit b73fa210b234d2c8067db2c32f94f362b89afe5a
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Mon Mar 14 08:30:24 2022 +0100

    add json tes

commit 984d015a7d9aceb6ea64be7ed9f1cc0caa356714
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Mon Mar 14 08:30:06 2022 +0100

    better test

commit 42061146658598da02eda7cb781bd2cf44c8ca34
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Fri Mar 11 16:12:57 2022 +0100

    update test

commit 6259c0957566600b044fcd4a5e14e69cdff71020
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Fri Mar 11 13:59:13 2022 +0100

    update test

commit cbc4ad9566f6f7f01dd622651458fea309d80954
Merge: faa44b3fdd 94d0f8d4e7
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Fri Mar 11 12:46:48 2022 +0100

    Merge branch 'develop' of https://github.com/frappe/erpnext into dev_fix_30190

commit faa44b3fdd983adfc04bbf04a7ebfef114501bb3
Author: Florian HENRY <florian.henry@open-concept.pro>
Date:   Fri Mar 11 12:03:35 2022 +0100

    fix: clear Quality Inspection Template according to Inspection Quality Required
2022-03-14 18:25:00 +05:30