Commit graph

231 commits

Author SHA1 Message Date
Suraj Shetty
d2b7f47709
Merge pull request #19734 from barredterra/load-address-and-contact-display 2023-05-24 15:39:04 +05:30
Marica
3b5ff3dbb7
fix: get_default_address must accept 'Nonetype' name (#21022) 2023-05-17 11:11:57 +05:30
Raffael Meyer
440cde45f7
refactor: get_default_address (#20962) 2023-05-16 08:51:50 +05:30
Ritwik Puri
4b103888a7
chore: remove default None from address_dict param 2023-05-06 22:48:19 +05:30
Ritwik Puri
88bdefcc30
fix: type hints for get_address_display (#20923) 2023-05-06 21:36:07 +05:30
Raffael Meyer
0473f7b44f
feat: helper method for address display (#20900) 2023-05-04 23:36:58 +05:30
Raffael Meyer
fc10325074
fix: improve delete_contact_and_address (#20381) 2023-04-24 18:51:42 +05:30
Raffael Meyer
f5d79f0128
Merge branch 'develop' into load-address-and-contact-display 2023-04-21 13:17:46 +02:00
Ankush Menat
fa32b610d6
fix: rewrite query for postgres (#20557) 2023-04-03 14:47:45 +05:30
Ankush Menat
10dcbc5ecf fix: fix address query for postgres
refer https://github.com/frappe/frappe/pull/20537#ref-pullrequest-1645575433
2023-04-02 15:10:54 +05:30
Ankush Menat
fba3497ba0 test: address query 2023-03-31 19:04:11 +05:30
Ankush Menat
09e32c3085 perf: Faster address query with explicit joins
This querry is particularly problamatic when there are OR conditions due
to shared docs.

```sql
ANALYZE SELECT `tabAddress`.name,
       `tabAddress`.city,
       `tabAddress`.country
FROM `tabAddress`
join `tabDynamic Link` on (`tabDynamic Link`.parent = `tabAddress`.name AND `tabDynamic Link`.parenttype = 'Address')
WHERE
  `tabDynamic Link`.link_doctype = 'Customer'
  AND `tabDynamic Link`.link_name = 'CUSTOMER NAME'
  AND coalesce(`tabAddress`.disabled, 0) = 0
  AND (`tabAddress`.`country` like '%%'
       OR `tabAddress`.`state` like '%%'
       OR `tabAddress`.`name` like '%%'
       OR `tabAddress`.`name` like '%%')
  AND ((((coalesce(`tabAddress`.`branch`, '')=''
          OR `tabAddress`.`branch` in ('something')))))
  OR (`tabAddress`.name in ('SOME SHARED DOC'))
ORDER BY if(locate('', `tabAddress`.name), locate('', `tabAddress`.name), 99999),
         `tabAddress`.idx DESC,
         `tabAddress`.name
LIMIT 0, 20;
```

**Before:** Never terminates and reads entire table with millions of lines :LOL:

**After:** Reads ~100 rows max.

```
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: tabDynamic Link
         type: index_merge
possible_keys: parent,link_doctype_link_name_index,link_name
          key: link_name,link_doctype_link_name_index,parent
      key_len: 563,1126,563
          ref: NULL
         rows: 40
       r_rows: 79.00
     filtered: 100.00
   r_filtered: 100.00
        Extra: Using union(intersect(link_name,link_doctype_link_name_index),parent); Using where; Using temporary; Using filesort
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: tabAddress
         type: eq_ref
possible_keys: PRIMARY,selco_branch
          key: PRIMARY
      key_len: 562
          ref: _900a733bdc3bb9ed.tabDynamic Link.parent
         rows: 1
       r_rows: 1.00
     filtered: 100.00
   r_filtered: 100.00
        Extra: Using where
2 rows in set (0.001 sec)
```

<!--

Some key notes before you open a PR:

 1. Select which branch should this PR be merged in?
 2. PR name follows [convention](http://karma-runner.github.io/4.0/dev/git-commit-msg.html)
 3. All tests pass locally, UI and Unit tests
 4. All business logic and validations must be on the server-side
 5. Update necessary Documentation
 6. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes

Also, if you're new here

- Documentation Guidelines => https://github.com/frappe/erpnext/wiki/Updating-Documentation

- Contribution Guide => https://github.com/frappe/frappe/blob/develop/.github/CONTRIBUTING.md

- Pull Request Checklist => https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist

-->

> Please provide enough information so that others can review your pull request:

<!-- You can skip this if you're fixing a typo or updating existing documentation -->

> Explain the **details** for making this change. What existing problem does the pull request solve?

<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->

> Screenshots/GIFs

<!-- Add images/recordings to better visualize the change: expected/current behviour -->
2023-03-31 17:46:06 +05:30
Raffael Meyer
27a2b3204f
Merge branch 'develop' into load-address-and-contact-display 2023-02-22 18:54:18 +01:00
Ankush Menat
8446875257
refactor!: Remove "Set user permission" permtype (#20090)
This has never worked and setting user permission requires system
manager role always (because of permissions on list view)
2023-02-20 16:07:49 +05:30
Raffael Meyer
64c880aa70
Merge branch 'develop' into load-address-and-contact-display 2023-02-01 17:30:22 +01:00
Gavin D'souza
7ce0c4c8b3 Merge branch 'develop' into permlevel-apis 2023-01-31 17:47:59 +05:30
Gavin D'souza
31049b705e fix(db_query): With as_list, pass NULL to maintain order 2023-01-25 14:01:02 +05:30
barredterra
2a84b18d13 feat: load address and contact display
- Handle missing permissions
- Split into smaller functions
2023-01-23 18:59:16 +01:00
barredterra
076225720d refactor: address template 2023-01-18 12:53:32 +01:00
Ankush Menat
db35431b8c fix(postgres): psql with remote databases
If you dont use unix socket psql command doesn't work.
2022-12-20 15:14:38 +05:30
Ankush Menat
89a34159f9
fix: postgres query (#19357)
Double quotes are supposed to be used for table/columns only in
postgres. Mariadb is fine with either.


[skip ci]
2022-12-20 12:50:00 +05:30
Raffael Meyer
eae918d545
feat: contact full name (#18596)
* feat: contact full name

* patch: autocommit and don't update modified

* patch: print progress while updating contacts

* patch: don't overwrite existing full_name
2022-11-22 18:57:41 +05:30
Ankush Menat
8cca50bf26
refactor: remove naming case feature (#18672)
This has never worked since 2016... which can mean two things:
- No one really uses this.
- If I fix this now suddenly people will find different behaviour in
  naming because `name_case` is selected in some doctypes (but never
  tested)
2022-10-31 11:23:49 +05:30
Dany Robert
2f358dea03
fix: explicitly set doctype in queries (#18403) 2022-10-13 11:40:22 +05:30
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ankush Menat
40f27f908a style: format JS files with prettier 2022-08-04 14:51:01 +05:30
Gavin D'souza
85e3ee9403 chore: Minified DocType JSON notation from old verbose notation 2022-08-03 12:22:03 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Ankush Menat
28fd355f24 chore: translate before searching doctype 2022-06-20 11:16:24 +05:30
Ankush Menat
e0e452bdcc
fix: incorrect filtering on address doctype (#17241)
[skip ci]
2022-06-20 11:11:10 +05:30
Ankush Menat
8c6d266fad fix: can't select dynamic link on address doctype 2022-06-17 14:43:02 +05:30
Gavin D'souza
963648667d refactor: filter_dynamic_link_doctypes API
* Added typing, better variable naming
* Remove unnecessary re-iterations
* Optimize queries and membership processing
2022-06-13 18:39:56 +05:30
chillaranand
1d763a6659 refactor: Fix flake8 issues 2022-05-19 15:34:35 +05:30
Himanshu
5ac729252f
fix: change ordering to creation (#16863) 2022-05-10 19:41:11 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Suraj Shetty
57df0bad82 fix: Check permission for address and contact list 2021-10-28 15:14:53 +05:30
Suraj Shetty
3728e6dfdb fix: Use get_all instead of get_list for doc creation to avoid permission check 2021-10-26 12:40:37 +05:30
barredterra
37a1a15b87 fix: set correct title
(cherry picked from commit b35391d339b2e2be15f1615011e5ea609eba01f5)
2021-09-27 06:02:29 +00:00
Suraj Shetty
39dfb96ff8
Merge pull request #14152 from anupamvs/address-spacing 2021-09-09 12:30:53 +05:30
Anupam
35d563edb0 fix: contact.py spacing issue 2021-09-09 11:50:47 +05:30
Anupam
6ca2788cc5 fix: spacing issue 2021-09-09 11:48:20 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
65864c027f chore: Update module license header
These modules were imported from the ERPNext codebase into Frappe.
License header was overlooked at that point. These were contributed
initially by Frappe Technologies Pvt Ltd under GPLv3 (ERPNext's license) and now
we, as Frappe Technologies Pvt Ltd converting them to MIT to comply with
Frappe's license.
2021-09-03 11:51:01 +05:30
Gavin D'souza
c489846547 Merge branch 'develop' into unnecessary_comprehensions 2021-06-11 19:30:23 +05:30
Gavin D'souza
651a9ff42e fix: Return address 'name' instead of 'parent' field 2021-05-28 21:43:07 +05:30
Gavin D'souza
bd6fcddd04 chore: Drop unreachable code 2021-05-26 16:41:32 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Gavin D'souza
e8cf96d1d3 fix: Replace cmp with different logic
cmp was being used from past.builtins library since it was deprecated in
PY2. It's hard to understand behaviour of their usages, so this is an
attempt to replicate behaviour with simpler logic, making this more
readable.

Also, removed usages of iteritems and string_types, compatibility
imports
2021-05-26 13:25:01 +05:30
Ankush Menat
4754ab71d1
perf(minor): remove unnecessary comprehensions
- remove several unnecessary comprehensions from functions that accept a generator.
- Using `[x for x in iter]` causes a list to be built first then passed to the outer function.
- `any` and `all` can take generator instead. This makes memory usage O(1) and actually makes these functions short-circuiting. E.g. if the first condition fails then `all` will immediately return false instead of evaluating all the entries.
- `sum`, `min`, `max` => memory usage become O(1)
- `list`, `set`, `.join()` => roughly halves memory usage, as list is not required to be built.
- lastly, it's two fewer characters to read/think about.
2021-05-12 20:38:18 +05:30