Merge pull request #25374 from ankush/shipment_status_update

fix: commit  changes to shipment status in database
This commit is contained in:
rohitwaghchaure 2021-04-18 17:56:22 +05:30 committed by GitHub
commit 4ed5d994a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 2 deletions

View File

@ -7,11 +7,29 @@ rules:
- pattern-inside: |
def on_submit(self, ...):
...
- metavariable-regex:
metavariable: '$ATTR'
# this is negative look-ahead, add more attrs to ignore like (ignore|ignore_this_too|ignore_me)
regex: '^(?!status_updater)(.*)$'
message: |
Doctype modified after submission. Please check if modification of self.$ATTR is commited to database.
languages: [python]
severity: ERROR
- id: frappe-modifying-after-cancel
patterns:
- pattern: self.$ATTR = ...
- pattern-inside: |
def on_cancel(self, ...):
...
- metavariable-regex:
metavariable: '$ATTR'
regex: '^(?!ignore_linked_doctypes|status_updater)(.*)$'
message: |
Doctype modified after cancellation. Please check if modification of self.$ATTR is commited to database.
languages: [python]
severity: ERROR
- id: frappe-print-function-in-doctypes
pattern: print(...)
message: |

View File

@ -772,3 +772,4 @@ erpnext.patches.v12_0.purchase_receipt_status
erpnext.patches.v13_0.fix_non_unique_represents_company
erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021
erpnext.patches.v13_0.update_shipment_status

View File

@ -0,0 +1,14 @@
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "shipment")
# update submitted status
frappe.db.sql("""UPDATE `tabShipment`
SET status = "Submitted"
WHERE status = "Draft" AND docstatus = 1""")
# update cancelled status
frappe.db.sql("""UPDATE `tabShipment`
SET status = "Cancelled"
WHERE status = "Draft" AND docstatus = 2""")

View File

@ -23,10 +23,10 @@ class Shipment(Document):
frappe.throw(_('Please enter Shipment Parcel information'))
if self.value_of_goods == 0:
frappe.throw(_('Value of goods cannot be 0'))
self.status = 'Submitted'
self.db_set('status', 'Submitted')
def on_cancel(self):
self.status = 'Cancelled'
self.db_set('status', 'Cancelled')
def validate_weight(self):
for parcel in self.shipment_parcel: