Commit graph

87 commits

Author SHA1 Message Date
Chinmay D. Pai
9d36b05804
fix: correctly pickle email_args for workflow emails
currently, since we return possible actions as dict_values, pickle fails
to work with it with the following error:

```python-traceback
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 99, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py", line 210, in send_workflow_action_email
    enqueue(method=frappe.sendmail, queue='short', **email_args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 69, in enqueue
    kwargs=queue_args)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/queue.py", line 258, in enqueue_call
    job = self.enqueue_job(job, at_front=at_front)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/queue.py", line 324, in enqueue_job
    job.save(pipeline=pipe)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/job.py", line 516, in save
    connection.hmset(key, self.to_dict(include_meta=include_meta))
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/job.py", line 469, in to_dict
    obj['data'] = zlib.compress(self.data)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/job.py", line 234, in data
    self._data = dumps(job_tuple)
TypeError: can't pickle dict_values objects
```

passing the values as a list instead works fine.

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-03-07 18:06:02 +05:30
Suraj Shetty
ddd091d9f7 fix: Wrap condition field with bactick since it is a reserved keyword 2020-02-07 17:54:18 +05:30
Suraj Shetty
0461696fd8 fix: De-duplicate actions sent in mail 2020-02-07 11:19:01 +05:30
mergify[bot]
62ea837d07
Merge pull request #9363 from prssanna/workflow-fix
fix(Workflow): Set workflow state when some action is performed on a …
2020-02-05 10:04:49 +00:00
prssanna
70316e8670 fix(test): set workflow state Approved docstatus to 1 in test 2020-02-05 11:47:03 +05:30
prssanna
2edfca9fb5 test: add test case to check if workflow state is set 2020-02-04 12:09:18 +05:30
Suraj Shetty
51bae0df50 fix(translations): Incorrect syntax 2020-01-29 15:35:28 +05:30
Suraj Shetty
dee4a7336c fix(translations): Incorrect syntax 2020-01-29 15:22:35 +05:30
Suraj Shetty
160d495743
style: Update docstring and fix formatting 2020-01-08 09:37:06 +05:30
prssanna
3cce101c2d test: add test to check if document status is updated 2020-01-07 00:58:43 +05:30
prssanna
04e7b7a96b fix: compare docs by state as key 2020-01-05 15:59:38 +05:30
prssanna
764f18e2e9 fix: check if doc_before_save exists 2019-12-31 12:24:30 +05:30
prssanna
173960e50b fix: update docstatus of documents if docstatus value is changed in workflow 2019-12-30 16:56:07 +05:30
Suraj Shetty
2242146c82 fix: Rename Reference DocType -> Reference Document Type 2019-09-05 15:47:40 +05:30
Suraj Shetty
84c3eb3d62 fix: Disable caching for respond_as_web_page response (#8276)
* fix: Do not cache workflow approval confirmation page

* fix: Make it readable

* fix: Disable caching for respond_as_web_page

* fix: Remove info about no_cache from docstring
2019-08-27 19:36:44 +05:30
Govind S Menokee
206f8fca03
fix: workflow action creation is not skipped
Workflow action creation check is not properly executed due to incorrect field name used in validation.
2019-07-16 16:34:59 +05:30
Suraj Shetty
bea7c72ae9 fix: Update checkbox description 2019-06-14 16:40:33 +05:30
Suraj Shetty
59ac009d5a fix: Codacy 2019-06-14 13:03:48 +05:30
Suraj Shetty
1833c01029 fix: Skip transition if next state of the transition is optional 2019-06-14 11:44:53 +05:30
Suraj Shetty
6d910fc9cd fix: Skip workflow action for transition which cancels the doc 2019-06-13 14:41:41 +05:30
Suraj Shetty
d327dc518e refactor: Make function to create new todo 2019-06-03 12:18:30 +05:30
Suraj Shetty
67b41deb44 test: Add test case to check get_common_transition_actions 2019-06-02 10:56:20 +05:30
Suraj Shetty
8528298b55 test: Init bulk approval test 2019-05-31 13:44:15 +05:30
Nabin Hait
8c91e46563 Fixed merge conflict 2019-04-11 11:56:37 +05:30
Suraj Shetty
0c9e5e2540
style: Add space between key and value 2019-04-09 22:54:52 +05:30
Ahmed Madi
035a8457f6
Update workflow_action.py
Add reference_doctype and reference_name to the send_workflow_action_email function
2019-03-31 11:56:00 +03:00
Suraj Shetty
aee7c67f8b refactor: Move get_users_with_role to utils.user 2019-03-21 21:06:54 +05:30
Frappe Bot
497a14046e Merge branch 'master' into develop 2019-03-01 09:10:17 +00:00
Rushabh Mehta
b288522f3f
Merge pull request #7006 from rohitwaghchaure/indexing_for_workflow_action
(fix, workflow action): added indexing for user and status columns
2019-03-01 09:08:53 +05:30
Rohit Waghchaure
7aad78be75 (fix, workflow action): added indexing for user and status columns 2019-02-28 18:55:57 +05:30
Frappe Bot
54e97b9ebc Merge branch 'master' into develop 2019-02-28 10:05:32 +00:00
Rohit Waghchaure
0ede34aeb3 fix: explicit commit submitting the document even if exception is raised 2019-02-27 17:10:41 +05:30
Saurabh
b727233948 Merge branch 'staging' into develop 2018-12-13 10:37:25 +05:30
Prateeksha Singh
c964d1420c [custom-field] Admin-owned programmed fields 2018-12-11 16:10:02 +05:30
Nabin Hait
d37d111f61 Fixed merge conflict 2018-10-15 15:53:26 +05:30
Nabin Hait
b218a16dc3 fix(name): naming of workflow action based on hash 2018-10-15 14:21:40 +05:30
Ameya Shenoy
63c5613f92
Merge branch 'staging' into develop 2018-10-11 10:11:26 +00:00
Nabin Hait
56be85c934 User permissions patch fixes for skip-for-doctypes (#6229)
* fix(patch): Fixed skip_for_doctypes in User Permissions

* fix(address): Made address_title non-mandatory, because it is set based on links
2018-10-11 15:29:03 +05:30
Ameya Shenoy
e551153ea0
Merge branch 'staging' into develop 2018-09-26 07:21:28 +00:00
rohitwaghchaure
de9778047d [Fix] Not able to delete the document which has workflow (#6119) 2018-09-24 12:34:21 +05:30
Rushabh Mehta
2e6a202652 Postgres support for Frappe (#5919)
* [start] postgres

* [wip] started refactoring db_schema

* Add psycopg2 to requirements.txt

* Add support for Postgres SQL

- Separate frameworkSQL, database, schema, setup_db file for
mariaDB and postgres
- WIP

* Remove quotes from sql to make it compatible with postgres as well

* Moved some code from db_schema to database.py

* Move code from db_schema to schema.py

Add other required refactoring

* Add schema chages

* Remove redundant code in file

* Add invalid column name exception class to exceptions.py

* Add back tick in query wherever needed and replace ifnull with coalesce

* Update get_column_description code in database.py file

* Remove a print statement

* Add keys to get on_duplicate query

* Add bactick wherever necessary

- Remove db_schema.py file

* Remove DATE_SUB as it is incompatible with postgres

- Fix prepare_filter_condition

* Add backtick and quotes wherever necessary
- Move get_database_size to frappe.db namespace
- fix some left out bugs and errors

* Add code to create key and unique index
- added mysql and posgres in their respective database.py

* Add more bacticks in queries and fix some errors
- Pass keys to on_duplicate_update method
- Replace MONTH with EXTRACT function
- Remove DATEDIFF and CURDATE usage

* Cast state value to int in toggle_two_factor_auth
- since two_factor_auth has the datatype of Int

* Refactor
- Replace Timediff with normal arithmetic operator
- Add MAX_COLUMN_LENGTH
- Remove Redundant code
- Add regexp character constant
- Move create_help_table to database.py
- Add get_full_text_search_condition method
- Inherit MariaDBTable from DBTable

* Replace Database instance with get_db method

* Move db_manager to separate file

* Refactor
- Remove some unwanted code
- Separate alter table code for postgres and mysql
- Replace data_type with column_type in database.py

* Make fulltext search changes in global_search.py

* Add empty string check

* Add root_password to site config

* Create cli command for postgres console

* Move setup of help database to setup_db.py

* Add get_database_list method

* Fix exception handling
- Replace bad_field handler with missing_column handler

* Fix tests and sql queries

* Fix import error

* Fix typo db -> database

* Fix error with make_table in help.py

* Try test for postgres

* Remove pyhton 2.7 version to try postgres travis test

* Add test fixes

* Add db_type to the config of test_site_postgres

* Enable query debug to check the reason for travis fail

* Add backticks to check if the test passes

* Update travis.yml
- Add postgres addon

* Try appending 'd_' to hash for db_name
- since postgres does not support dbname starting with a number

* Try adding db_type for global help to make travis work

* Add print statements to debug travis failure

* Enable transaction and remove debug flag

* Fix help table creation query (postgres)

* Fix import issue

* Add some checks to prevent errors
- Some doctypes used to get called even before they are created

* Try fixes

* Update travis config

* Fix create index for help table

* Remove unused code

* Fix queries and update travis config

* Fix ifnull replace logic (regex)

* Add query fixes and code cleanup

* Fix typo
- get_column_description -> get_table_columns_description

* Fix tests
- Replace double quotes in query with single quote

* Replace psycopg2 with psycopg2-binary to avoid warnings
- http://initd.org/psycopg/docs/install.html#binary-install-from-pypi

* Add multisql api

* Add few multisql queries

* Remove print statements

* Remove get_fulltext_search_condition method and replace with multi query

* Remove text slicing in create user

* Set default for 'values' argument in multisql

* Fix incorrect queries and remove few debug flags
- Fix multisql bug

* Force delete user to fix test
- Fix Import error
- Fix incorrect query

* Fix query builder bug

* Fix bad query

* Fix query (minor)

* Convert boolean text to int since is_private has datatype of int
- Some query changes like removed double quotes
and replace with interpolated string to pass multiple
value pass in one of the query

* Extend database class from an object to support python 2

* Fix query
- Add quotes around value passed to the query for variable comparision

* Try setting host_name for each test site
- To avoid "RemoteDisconnected" error while testing data migration test
- Update travis.yml to add hosts
- Remove unwanted commit in setup_help_database

* Set site hostname to data migration connector (in test file)
- To connect the same site host

* Fix duplicate entry issue
- the problem is in naming series file.
In previous commits I unknowingly changed a part of a series query
due to which series were not getting reset

* Replace few sql queries with orm methods

* Fix codacy

* Fix 'Doctype Sessions not found' issue

* Fix bugs induced during codacy fixes

* Fix Notification Test

- Use ORM instead of raw sql

* Set Date fallback value to 0001-01-01

- 0000-00-00 is invalid date in Postgres
- 0001-01-01 works in both

* Fix date filter method

* Replace double quotes with single quote for literal value

* Remove print statement

* Replace double quotes with single

* Fix tests

- Replace few raw sql with ORM

* Separate query for postgres

- update_fields_to_fetch_query

* Fix tests

- replace locate with strpos for postgres

* Fix tests

- Skip test for datediff
- convert bytes to str in escape method

* Remove TestBot

* Skip fieldname extraction

* Replace docshare raw sql with ORM

* Fix typo

* Fix ancestor query test

* Fix test data migration

* Remove hardcoded hostname

* Add default option and option list for db_type

* Remove frappe.async module

* Remove a debug flag from test

* Fix codacy

* fix import issue

* Convert classmethod to static method

* Convert few instance methods to static methods

* Remove some unused imports

* Fix codacy

- Add exception type
- Replace few instance methods with static methods
- Remove unsued import

* Fix codacy

* Remove unused code

* Remove some unused codes

- Convert some instance methods to static function

* Fix a issue with query modification

* Fix add_index query

* Fix query

* Fix update_auth patch

* Fix a issue with exception handling

* Add try catch to a reload_doc

* Add try-catch to file_manager_hook patch

* import update_gravatar to set_user_gravatar patch

* Undo all the wrong patch fixes

* Fix db_setup code 😪
- previously it was not restoring db from source SQL
which is why few old patched were breaking
(because they were getting different schema structure)

* Fix typo !

* Fix exception(is_missing_column) handling

* Add deleted code
- This code is only used in a erpnext patch.
Can be moved to that patch file

* Fix codacy

* Replace a mariadb specific function in a query used in validate_series

* Remove a debug flag

* Revert changes (rename_parent_and_child)

* Fix validate_one_root method

* Fix date format issue

* Fix codacy
- Disable a pylint for variable argument warning
- Convert an instance method to static method

* Add bandit.yml

The Codacy seems to use Bandit which generates
warning for every subprocess import and its usage during pytest
Since we have carefully used subprocess (avoided user input),
warnings needs to be avoided.
This can be removed if we have any alternative for subprocess usage.

* Skip start_process_with_partial_path check

* Fix typo

* Add python 2.7 test

* Move python versions in travis.yml

* Add python versions to jobs

* Overwrite python version inheritance for postgres in travis.yml

* Add quotes around python version in .travis.yml

* Add quotes around the name of the job

* Try a travis fix

* Try .travis.yml fix

* Import missing subprocess

* Refactor travis.yml

* Refactor travis.yml
- move install and tests commands to separate files
- Use matrix to build combination of python version and db type

* Make install.sh and run-tests.sh executable

* Add sudo required to travis.yml to allow sudo cmmands in shell files

* Load nvm

* Remove verbose flag from scripts

* Remove command-trace-print flag

* Change to build dir in before script

* Add absolute path for scripts

* Fix tests

* Fix typo

* Fix codacy
- fixes - "echo won't expand escape sequences." warning

* Append (_) underscore instead of 'd' for db_name

* Remove printf and use mysql execute flag
2018-09-21 10:20:48 +05:30
Suraj Shetty
9a7dc7b4e5 Workflow action ui ux fixes (#5926)
* Allow cancel for doctype with workflow

* Fix child row deletion in workflows

-https://github.com/frappe/erpnext/issues/14731

* Add get_pdf_link method

* Refactor workflow action response

- Confirm before applying action

* Fix bug with confirmation page for workflow action

* Fix codacy

* Add cancel button and pdf link

* Fix Codacy

Remove trailing whitespace
2018-08-07 14:43:20 +05:30
Suraj Shetty
ecde50a699 Add logic to check if the document was modified (#5746)
- Check if the document was modified after the workflow
action mail was sent.
If yes, then show an alert with the latest document preview.
2018-07-02 19:10:48 +05:30
Suraj Shetty
26c6e2928c Move allow self approval check to transisition for more control (#5691)
* Move allow self approval check to transisition for more control

* Disable email alert from workflow test

* Add allow_self_approval to each transition of test workflow

* Remove print statement

* Remove extra blank lines
2018-06-21 09:08:27 +05:30
Suraj Shetty
9e402ec3b5 Clear cache on workflow update (#5677) 2018-06-12 21:50:36 +05:30
Suraj Shetty
6b77c10cc9 [Workflow] Added a check to enable/disable workflow action emails and test fix (#5668)
* Fix build and make py3 compatible

* Remove unused test since state edit check was removed

* Add toggle to enable or disable workflow action emails
2018-06-11 15:09:42 +05:30
Suraj Shetty
90325ceccf [Improvement] Allow user to apply Workflow Action without login (#5637)
* Enqueue send email job

* Allow user to apply action without login

* Reorganize method

* Show username instead of email

* Refactor send email job

* Fix python 3 test

* Fix python 3 tests

- send user data list instead of dict-view
https://stackoverflow.com/a/16228268
2018-06-04 11:43:24 +05:30
Suraj Shetty
c71c132ba2 Workflow actions (#5598)
* Init workflow actions

- WIP code
- Add hooks to create and update
workflow action on document status changes.
- Tweak listview to show host document on list view item click
- Add new doctype "Pending Workflow Action"
- Add allow_self_approval check in Workflow master

* Rename doctypes

- Rename "Workflow Action" to "Workflow Action Master"
- Rename "Pending Workflow Action" to "Workflow Action"
- Remove irrelevant files

* Clear old workflow action on docstatus change

- Add check for user permission before creating a workflow action record
- Make doctype changes to support the Workflow Action  System

* Show host document only if workflow action status is open

* Send workflow action mail notifications

* Add patch to rename `tabWorkflow Action` to `tab Workflow Master`

- Rename table to retain data in `tabWorkflow Action` as it
will be overwritten with new structure on migration

* Enqueue email

* Remove unused files

* Add hook for custom has_permission

* Optimize send_workflow_action_email method

* Add permission_query_condition hook

* Show notification based on status

* Override get_form_link in list view

* Refactor workflow action

- Add action link
- update workflow action hooks

* Avoid repeated creation of Worklow Actions

- Update hooks entry to avoid unwanted method call

* Fix error with frappe.db.count usage

* Fix ui/ux for Workflow Action

- Fix action url and improve response on action button click
- Fix workflow action template style

* Fix Codacy

* Add self approval check

* Fix codacy

* Fix test

* Fix python version confilct and a permission error

* Fix incorrect 'this' reference

* Update with requested changes

* Add next action email template option

* Fix string formatting

* Refactor workflow Action

- Make process_workflow_action smaller

* Fix bugs and errors due to refactor

* Fix workflow field caching

* Add a workflow action test

* Fix bugs with email template
2018-05-30 11:24:49 +05:30
Rushabh Mehta
b4650f42a1 [minor] remove in_dialog old property 2018-05-16 12:51:01 +05:30
Nabin Hait
6737f1912c Fixed merge conflict 2018-05-08 15:27:37 +05:30