Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reload communication before re-save #20914

Merged
merged 2 commits into from
May 6, 2023
Merged

Conversation

ankush
Copy link
Member

@ankush ankush commented May 5, 2023

Solves:

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 453, in receive
    communication = mail.process()
      self = <EmailAccount: Sales>
      exceptions = []
      inbound_mails = [<frappe.email.receive.InboundMail object at 0x7ff8b2fe56c0>, <frappe.email.receive.InboundMail object at 0x7ff8b2fe4af0>, <frappe.email.receive.InboundMail object at 0x7ff8b2fe58a0>]
      mail = <frappe.email.receive.InboundMail object at 0x7ff8b2fe4af0>
      communication = <Communication: 84e7fa273c>
  File "apps/frappe/frappe/email/receive.py", line 619, in process
    return self._build_communication_doc()
      self = <frappe.email.receive.InboundMail object at 0x7ff8b2fe4af0>
      communication = None
  File "apps/frappe/frappe/email/receive.py", line 655, in _build_communication_doc
    communication.save()
      self = <frappe.email.receive.InboundMail object at 0x7ff8b2fe4af0>
      reference_doc = <Lead: Lead-23-24-02732>
      communication = <Communication: 5639d5b8a5>
  File "apps/frappe/frappe/model/document.py", line 316, in save
    return self._save(*args, **kwargs)
      self = <Communication: 5639d5b8a5>
      args = ()
      kwargs = {}
  File "apps/frappe/frappe/model/document.py", line 345, in _save
    self.check_if_latest()
      self = <Communication: 5639d5b8a5>
      ignore_permissions = None
      ignore_version = None
  File "apps/frappe/frappe/model/document.py", line 779, in check_if_latest
    frappe.msgprint(
      self = <Communication: 5639d5b8a5>
      previous = <Communication: 5639d5b8a5>
  File "apps/frappe/frappe/__init__.py", line 491, in msgprint
    _raise_exception()
      title = None
      as_table = False
      as_list = False
      indicator = 'red'
      alert = False
      primary_action = None
      is_minimizable = False
      wide = False
      sys = <module 'sys' (built-in)>
      out = {'message': 'Error: Document has been modified after you have opened it (2023-05-04 18:30:40.492993, 2023-05-04 18:30:41.221896). Please refresh to get the latest document.', 'title': 'Message', 'indicator': 'red', 'raise_exception': 1}
      _raise_exception = <function msgprint.<locals>._raise_exception at 0x7ff8b0b87d90>
      _strip_html_tags = <functools._lru_cache_wrapper object at 0x7ff8b093d9b0>
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'Error: Document has been modified after you have opened it (2023-05-04 18:30:40.492993, 2023-05-04 18:30:41.221896). Please refresh to get the latest document.'
      raise_exception = <class 'frappe.exceptions.TimestampMismatchError'>
      strip_html_tags = <function strip_html_tags at 0x7ff8ba8bc310>
  File "apps/frappe/frappe/__init__.py", line 440, in _raise_exception
    raise raise_exception(msg)
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'Error: Document has been modified after you have opened it (2023-05-04 18:30:40.492993, 2023-05-04 18:30:41.221896). Please refresh to get the latest document.'
      raise_exception = <class 'frappe.exceptions.TimestampMismatchError'>
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2023-05-04 18:30:40.492993, 2023-05-04 18:30:41.221896). Please refresh to get the latest document.

since db_set and db.set_value are present in post save/insert hooks for communication doctype, it causes this error very frequently

@github-actions github-actions bot added the add-test-cases Add test case to validate fix or enhancement label May 5, 2023
@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Merging #20914 (cd516ff) into develop (bb14fe6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #20914   +/-   ##
========================================
  Coverage    63.95%   63.96%           
========================================
  Files          761      761           
  Lines        68860    68861    +1     
  Branches      6227     6227           
========================================
+ Hits         44042    44047    +5     
+ Misses       21262    21258    -4     
  Partials      3556     3556           
Flag Coverage Δ
server 68.93% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@phot0n phot0n marked this pull request as ready for review May 6, 2023 10:19
@phot0n phot0n requested review from a team and phot0n and removed request for a team May 6, 2023 10:19
@phot0n phot0n added backport version-14-hotfix backport to version 14 and removed add-test-cases Add test case to validate fix or enhancement labels May 6, 2023
@phot0n phot0n merged commit 715dc56 into frappe:develop May 6, 2023
mergify bot pushed a commit that referenced this pull request May 6, 2023
phot0n pushed a commit that referenced this pull request May 6, 2023
(cherry picked from commit 715dc56)

Co-authored-by: Ankush Menat <ankush@frappe.io>
@ankush ankush deleted the reload_comm branch May 6, 2023 12:53
frappe-pr-bot pushed a commit that referenced this pull request May 9, 2023
# [14.36.0](v14.35.0...v14.36.0) (2023-05-09)

### Bug Fixes

* ensure that `get_last_email` returns the most recent email (backport [#20711](#20711)) ([624f96b](624f96b))
* escape html from listview row title ([56bec1d](56bec1d))
* escape html from workspace title ([e68fc43](e68fc43))
* ignore virtual doctypes during data export ([#20891](#20891)) ([#20899](#20899)) ([d6bfaae](d6bfaae))
* make operator in link filters translatable (backport [#20884](#20884)) ([#20911](#20911)) ([1ec3bad](1ec3bad))
* message.py executing script ([#20887](#20887)) ([#20897](#20897)) ([1bcf5d4](1bcf5d4))
* **multi-pdf:** change response type to pdf ([997559c](997559c))
* **oauth:** add exp to idToken ([#20694](#20694)) ([#20903](#20903)) ([1a8e671](1a8e671))
* reload communication before re-save ([#20914](#20914)) ([#20921](#20921)) ([37a8ec0](37a8ec0))
* set default letterhead and print format ([a5a6965](a5a6965))
* strip comma, space from recipients before sending email for auto repeat ([#20940](#20940)) ([#20945](#20945)) ([042a1d2](042a1d2))
* translate lowercase operators to german ([#20912](#20912)) ([#20916](#20916)) ([c47b146](c47b146))
* type hints for get_address_display ([#20923](#20923)) ([#20924](#20924)) ([15df963](15df963))
* use smaller font only if the report doesnt have a standard print format ([#20878](#20878)) ([#20947](#20947)) ([35165d0](35165d0))

### Features

* helper method for address display ([#20900](#20900)) ([#20901](#20901)) ([f914770](f914770))
* telemetry using posthog (backport [#20825](#20825)) ([#20934](#20934)) ([bbe29ee](bbe29ee))

### Performance Improvements

* get all file data at once when downloading private file ([#20902](#20902)) ([e106594](e106594))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants