Commit graph

537 commits

Author SHA1 Message Date
Akhil Narang
18867b273f
chore: make return type annotation make more sense
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
gavin
8e7cd47d3d
feat: Document.remove_tag (#22970)
Added remove_tag API for consistency
2023-10-30 16:10:20 +05:30
Maharshi Patel
409a3a8105 Merge branch 'develop' into fix-attach-before-doc-save 2023-10-19 11:40:20 +05:30
Ankush Menat
018ed845bd refactor: defer unnecessary json-dumping of messages
Also avoid accessing locals where interface is present like for popping last message.
2023-10-16 18:13:50 +05:30
Ankush Menat
d5a21a2676 fix: rename type validation
`None` can be passed which is acceptable here.

TODO: Make slackdict accept none as bool and convert to False
2023-10-16 18:12:53 +05:30
Ankush Menat
11dd961d81 refactor!: Method whitelisting
Document.whitelist doesn't work, no idea why it's doing all weird
`__func__` business.

`@frappe.whitelist()` works just fine.
2023-10-16 18:12:53 +05:30
Ankush Menat
52d6bd67e4 fix: Always return document from doc.insert 2023-10-13 15:34:03 +05:30
Akhil Narang
1482ad68c9 fix(model/document): add missing parameters to docstring
[skip ci]

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-10-13 14:51:39 +05:30
Maharshi Patel
53cdd6d1bf fix: relink attachments before saving doc
Certain people add attachment, before filling mandatory fields
which will raise Missing Fields error.

Or any other kind of errors raised by different validators due to which
file is uploaded but doc is not saved.

This will lead to orphaned/mislinked files. ex. new-purchase-receipt-1

This fix changes name of new docs to new-<doctype>-<no>-<10digithash>
after saving the document we can use this new name to find any mislinked
files created in past hour and relink them to the new doc on save.
2023-10-10 23:49:16 +05:30
Akhil Narang
b601131d8f
fix: don't allow setting an invalid rating (#22633)
* feat: don't allow setting an invalid rating

Convert anything <0 to 0, and anything >1 to 1

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* chore: add in tests for rating

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-10-10 15:38:58 +05:30
Ankush Menat
6a2bfbf61d
fix: Ignore perm while updating module onboarding (#22448)
* fix: Ignore perm while updating module onboarding

* fix: incorrect error message
2023-09-18 09:00:53 +00:00
Ankush Menat
edfeb0d932 fix(UX): Highlight which permission is missing 2023-08-29 19:11:58 +05:30
Gavin D'souza
6b1609d277
fix: Cast documents iterable to list in db_insert 2023-08-25 16:12:48 +05:30
Gavin D'souza
a996ff7f5b fix: Handle child record insertions via bulk_insert 2023-08-18 14:17:19 +00:00
mergify[bot]
fd10ab25cc
Merge pull request #22003 from gavindsouza/refactor-doc-bits
refactor: Use single query to delete child rows on doc.save
2023-08-11 06:45:07 +00:00
Gavin D'souza
84f134a683
fix: Add "better" typing hints 2023-08-11 11:45:47 +05:30
Gavin D'souza
5554707148 refactor: Use single query to delete child rows 2023-08-10 06:29:18 +00:00
barredterra
b553ed98d8 refactor: inline immediately returned variable
Inline a variable to a return in the case when the
variable being declared is immediately returned
2023-08-08 18:09:49 +02:00
Ankush Menat
f6326b6145
fix: check before deleting prepared report (#21950) 2023-08-07 14:00:34 +05:30
Raffael Meyer
dc0a8c5ccb
fix: keep privacy setting of attachments on amend (#21911) 2023-08-03 15:33:39 +05:30
Ankush Menat
c40faddac7
perf: skip reset_seen for new doc (#21832)
The query is fired but document doesn't exist yet, so it does nothing really.

[skip ci]
2023-07-27 16:07:22 +05:30
Ankush Menat
0bc5d1dc3b feat(DX): type annotated python controllers 2023-07-24 15:32:46 +05:30
Ankush Menat
1bfe585b71
fix!: Drop unused link_doctype, link_name (#21788) 2023-07-24 14:22:07 +05:30
Sagar Vora
7d7c440a1b fix: compare with doc.amended_from while saving version for newly amended doc 2023-07-17 16:04:28 +05:30
Ankush Menat
adf30693a9 ci: update pyupgrade 2023-07-14 14:24:08 +05:30
Ankush Menat
039be73af4
refactor: Consider singles for dynamic set_value usage (#21367)
Found all usage using this semgrep rule:

```yaml
    - pattern: frappe.db.set_value($DOCTYPE, ...)
    - pattern-not: frappe.db.set_value("$STR", ...)
```
2023-06-14 10:46:25 +05:30
Ankush Menat
3005e66e45 refactor!: Drop previously deprecated code 2023-06-13 16:00:43 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
106ff1f1ee fix: move cache clearing away from document
Passing lambda function from inside document object would keep reference
to document alive. This means increasing memeory usage in bulk
processing.

Refer https://github.com/frappe/frappe/pull/17061 for example

This also extends it to db.set_value
2023-06-03 22:53:10 +05:30
Ankush Menat
be1da0dd00 chore: remove duplicate cache clearing 2023-06-03 22:53:10 +05:30
Ankush Menat
339cbf208c fix: Cache clearing implementation 2023-06-03 22:53:10 +05:30
Sagar Vora
2eca7b4837 chore: more pythonic code
[skip ci]
2023-05-25 18:47:39 +05:30
Suraj Shetty
7abdad3282 Merge branch 'develop' of https://github.com/frappe/frappe into newsletter-analytics 2023-02-28 14:31:03 +05:30
Suraj Shetty
b397ec3858 feat: Track count of views on newsletter emails 2023-02-23 13:45:53 +05:30
Rucha Mahabal
89d63ea82b
fix: false positive attr check while applying permlevel (#20069)
* fix: false positive attr check while applying permlevel

* Revert "fix: false positive attr check while applying permlevel"

This reverts commit 9114788590ce12be977df847c13b00e3bf72ac2a.

* fix: ignore AttributeError while trying to pop low permlevel fields

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-02-20 12:18:37 +05:30
Gavin D'souza
acb0dc38ae fix: Check if attr exists before checking permlevel 2023-01-24 12:17:57 +05:30
Gavin D'souza
c28e4590e8 fix(rest): Delete doc attr if insufficient field permissions 2023-01-09 15:47:21 +05:30
rohitwaghchaure
0e9d16820b
fix: For Update for child table (#19436) 2023-01-02 11:35:21 +05:30
rohitwaghchaure
a72fdcbd89
fix: not able to make delivery note from pick list (#19418) 2022-12-27 17:58:04 +05:30
Sagar Vora
1458429d98
chore(Document): remove code that resets self.latest (#19399) 2022-12-24 00:13:28 +05:30
Sagar Vora
c453ad2d97 perf: reuse _doc_before_save in doc.get_latest 2022-12-17 07:56:54 +00:00
Raffael Meyer
bb5b0e5e64
refactor!: remove compare util from frappe package (#19234)
Use `from frappe.utils import compare` instead of `frappe.compare`.
2022-12-11 23:20:21 +05:30
Sagar Vora
4acddacf2d chore(Document): simplify get_permlevel_access 2022-12-04 02:44:18 +05:30
Raffael Meyer
c7ef28fa0c
fix: don't validate to & from dates if any one is missing in validate_from_to_dates (#19079) 2022-12-03 18:32:59 +05:30
Ankush Menat
a6af1ed542 feat: bulk insert simple Document objects 2022-11-28 15:32:20 +05:30
Aradhya Tripathi
07bd958dfd
Merge branch 'develop' into bg-submissions 2022-11-12 08:37:55 +05:30
gavin
9ad0538521
perf(doc): skip order_by when name is set in load_from_db (#18837)
Setting ORDER BY clause in the SQL nudges MariaDB to not use index
(even) for primary keys.
2022-11-10 16:53:28 +05:30
Sagar Vora
a42ca7d8c1
fix: raise exception if doc before save is not found (#18796)
* fix: raise exception if doc before save is not found

* test: ensure error is raised when trying to save new doc using `doc.save()`

* chore: add comment explaining condition

* test: clearer name and docstring
2022-11-09 19:45:41 +05:30
Aradhya
f587140f6f Merge branch 'develop' of https://github.com/Aradhya-Tripathi/frappe into bg-submissions 2022-11-04 18:34:41 +05:30
Sagar Vora
8b84042037
fix: load doc_before_save in check_if_latest (#18752) 2022-11-04 10:44:17 +05:30