Compare commits

...

167 Commits

Author SHA1 Message Date
Nabin Hait
6a6958db5c Merge branch 'develop' 2015-07-08 16:53:55 +05:30
Nabin Hait
ab1acb460b bumped to version 5.1.4 2015-07-08 17:23:55 +06:00
Nabin Hait
48d71fa7f7 Merge pull request #3602 from nabinhait/develop
Change log
2015-07-08 16:47:14 +05:30
Nabin Hait
30960e6a06 Change log added 2015-07-08 16:46:28 +05:30
Nabin Hait
736000c223 Merge pull request #3600 from neilLasrado/batch
Fixed issues in Expired Batches while making Stock Entry
2015-07-08 16:10:21 +05:30
Nabin Hait
4017bfcd2e Merge pull request #3591 from rmehta/salary-manager-fix
[fixes] salary manager #3554
2015-07-08 15:39:33 +05:30
Nabin Hait
e594e5de49 Merge pull request #3596 from neilLasrado/pos
Mode of Payment added to POS Profile
2015-07-08 15:36:30 +05:30
Nabin Hait
1f1f14be39 Merge pull request #3599 from nabinhait/develop
Multiple fixes
2015-07-08 15:33:57 +05:30
Neil Trini Lasrado
ebb60f5dbc Fixed issues in Expired Batches while making Stock Entry 2015-07-08 15:24:02 +05:30
Neil Trini Lasrado
75b00e3958 Mode of Payment added to POS Profile 2015-07-08 14:43:47 +05:30
Nabin Hait
5e3646ad6e validation message fix 2015-07-08 14:39:03 +05:30
Nabin Hait
4439d8264f minor fix 2015-07-08 14:32:56 +05:30
Nabin Hait
00d79eb68d minor fix 2015-07-08 14:32:27 +05:30
Nabin Hait
28a9e35de9 Validate item rate with reference document with tolerance 0.009 2015-07-08 13:10:59 +05:30
Nabin Hait
c450536a2c [fix] Map values in Debit / Credit Note from Stock Entry 2015-07-08 13:10:59 +05:30
Nabin Hait
3b3c48c877 [fix] Set Customer name in opportunity as per company name in lead 2015-07-08 13:10:59 +05:30
Rushabh Mehta
621d6eac3c [minor] added calendar hooks 2015-07-08 12:39:27 +05:30
Rushabh Mehta
f9b356992a [fixes] salary manager #3554 2015-07-07 16:30:29 +05:30
Nabin Hait
c516e1871d Merge branch 'develop' 2015-07-06 15:32:32 +05:30
Nabin Hait
9a38e669ef bumped to version 5.1.3 2015-07-06 16:02:32 +06:00
Nabin Hait
143f2c6faf Merge pull request #3585 from nabinhait/change_log
Added change log
2015-07-06 15:15:29 +05:30
Nabin Hait
9269813207 Added change log 2015-07-06 15:13:35 +05:30
Nabin Hait
0e6f92efa8 Merge pull request #3571 from neilLasrado/item-varients
Fixes for Item Attributes
2015-07-06 14:56:33 +05:30
Neil Trini Lasrado
1a0e86f11d Update item_attribute.py
Error Description Changed
2015-07-06 14:46:06 +05:30
Nabin Hait
73b7efd61d Merge pull request #3583 from rmehta/quotation-list-fix
[fix] quotation list #3492
2015-07-06 14:31:23 +05:30
Nabin Hait
4c4a5b968c Merge pull request #3576 from nabinhait/variant
[fix][patch] delete item variant attributes if no variants exists against that item
2015-07-06 14:30:48 +05:30
Nabin Hait
7b5ac6396a Merge pull request #3575 from nabinhait/batch_report
[fix] Hide zero balance rows in batch-wise balance history report
2015-07-06 14:30:23 +05:30
Nabin Hait
01771e8afc Merge pull request #3573 from rmehta/fix-labels
[fix] [minor] fix customer_name, supplier_name labels
2015-07-06 14:30:13 +05:30
Nabin Hait
347c4affe9 Merge pull request #3567 from rmehta/item-description-mozilla-fix
[fix] item image in mozilla #3412 #3413
2015-07-06 14:27:34 +05:30
Nabin Hait
526957505f Merge pull request #3569 from rmehta/employee-unset-user-id
[fix] remove user permission if user id is unset #3447
2015-07-06 14:27:22 +05:30
Nabin Hait
faa3416852 Merge pull request #3570 from rmehta/remove-masters-from-setup
[minor] remove the term 'Masters' from setup, it is confusing and not used anywhere, add Company to Accounts tab
2015-07-06 14:26:51 +05:30
Rushabh Mehta
56912791e2 [fix] quotation list #3492 2015-07-06 11:14:31 +05:30
Rushabh Mehta
38647c68b9 Merge pull request #3579 from neilLasrado/autocomplete
Autocomplete issues fixed in Manage Variants
2015-07-05 13:52:56 +05:30
Neil Trini Lasrado
4d64acfafc Autocomplete issues fixed in Manage Variants 2015-07-04 14:50:00 +05:30
Nabin Hait
d7441ec051 [fix][patch] delete item variant attributes if no variants exists against that item 2015-07-03 19:20:27 +05:30
Rushabh Mehta
0f15273bd7 Merge pull request #3572 from tmimori/develop
Fix for Monthly Attendance Report #3402
2015-07-03 15:49:26 +05:30
Nabin Hait
24efb3122a [fix] Hide zero balance rows in batch-wise balance history report 2015-07-03 15:20:14 +05:30
Rushabh Mehta
85e6f5d04e [fix] [minor] fix customer_name, supplier_name labels 2015-07-03 12:59:08 +05:30
Neil Trini Lasrado
1faaf71dfc Auto-Capitalize Item Attribute Abbreation, Prevent attribute to be deleated if Variant exists 2015-07-03 12:44:01 +05:30
Tsutomu Mimori
5a0fbff1a3 #3402 2015-07-03 16:08:02 +09:00
Rushabh Mehta
7278c0ae85 [minor] remove the term 'Masters' from setup, it is confusing and not used anywhere, add Company to Accounts tab 2015-07-03 12:21:50 +05:30
Rushabh Mehta
5688a6c31a [fix] remove user permission if user id is unset #3447 2015-07-03 11:34:53 +05:30
Rushabh Mehta
71349d221b [fix] item image in mozilla #3412 #3413 2015-07-03 10:43:35 +05:30
Nabin Hait
b7219dc698 Merge branch 'develop' 2015-07-02 17:58:40 +05:30
Nabin Hait
37c6ce7b1e bumped to version 5.1.2 2015-07-02 18:28:40 +06:00
Nabin Hait
7028ba507e Merge pull request #3561 from nabinhait/develop
Fixes
2015-07-02 17:55:18 +05:30
Nabin Hait
fcee17fd16 Removed purchase item validation 2015-07-02 17:51:35 +05:30
Nabin Hait
5906f02e3a update item image in invoice if item exists 2015-07-02 17:51:35 +05:30
Nabin Hait
721dcb1870 Merge branch 'develop' 2015-07-02 16:33:52 +05:30
Nabin Hait
6385967ccd bumped to version 5.1.1 2015-07-02 17:03:52 +06:00
Nabin Hait
81a977cacf Merge pull request #3559 from nabinhait/develop
Fixes
2015-07-02 16:32:34 +05:30
Nabin Hait
34058ded0e [fix] Update item image in sales invoice 2015-07-02 16:31:55 +05:30
Nabin Hait
e98120b716 [fix] Change log path 2015-07-02 16:29:28 +05:30
Nabin Hait
50e363b24e Merge branch 'develop' 2015-07-02 15:28:49 +05:30
Nabin Hait
bc176b6bf8 bumped to version 5.1.0 2015-07-02 15:58:49 +06:00
Nabin Hait
784b49e54e change log 2015-07-02 15:28:15 +05:30
Nabin Hait
04fb6e1a45 Merge pull request #3558 from nabinhait/develop
Change log
2015-07-02 15:22:20 +05:30
Nabin Hait
dffd7c3889 Change log 2015-07-02 15:21:25 +05:30
Nabin Hait
0c7594e5ed Merge pull request #3557 from rmehta/item-description-in-form
[fix] show item description in form grid based on in_list_view
2015-07-02 15:19:24 +05:30
Rushabh Mehta
5105f909d6 [fix] show item description in form grid based on in_list_view 2015-07-02 15:09:18 +05:30
Nabin Hait
2ab9d6e92c Merge pull request #3552 from nabinhait/develop
Recurring docs should not consider Stopped documents and should be scheduled for hourly
2015-07-02 14:42:57 +05:30
Nabin Hait
7580723ab3 Recurring docs should not consider Stopped documents and should be scheduled for hourly 2015-07-02 14:41:27 +05:30
Nabin Hait
52fef71c14 Merge pull request #3543 from rmehta/against-account-fix
Fix against account to show party instead of account
2015-07-02 14:28:11 +05:30
Rushabh Mehta
2cd02af80a [fix] patch date 2015-07-02 14:25:51 +05:30
Rushabh Mehta
0b0ec3536c [change-log] added 2015-07-02 14:25:51 +05:30
Rushabh Mehta
6b35ea873b [fix] against account in general ledger will show party 2015-07-02 14:25:51 +05:30
Nabin Hait
ecf220a721 Merge pull request #3549 from neilLasrado/item-varients
Validation changed for Item Template cannot have Stock
2015-07-02 14:18:31 +05:30
Nabin Hait
04fb1c7fe4 Merge pull request #3550 from neilLasrado/item-desc
Image feild added to Sales Invoice & Purchase Invoice
2015-07-02 14:17:52 +05:30
Neil Trini Lasrado
53bd62eafc Validation changed for Item Template cannot have Stock 2015-07-02 14:15:23 +05:30
Nabin Hait
ff68bf2609 Merge pull request #3551 from nabinhait/develop
Fixes
2015-07-02 14:10:58 +05:30
Nabin Hait
fdd0db3459 Update project completion percentage and costing after syncing task 2015-07-02 14:09:49 +05:30
Nabin Hait
f92465981c datetime issue fixed in maintenance schedule 2015-07-02 14:09:49 +05:30
Nabin Hait
885c70984d [fix] Always show Sales invoice in Gross profit report 2015-07-02 14:09:49 +05:30
Neil Trini Lasrado
9c15ef903d Image feild added to Sales Invoice & Purchase Invoice 2015-07-02 13:09:57 +05:30
Rushabh Mehta
bc799885d0 [fix] bom client script 2015-07-02 12:44:16 +05:30
Nabin Hait
cb129264cb Merge pull request #3386 from neilLasrado/item-varients
[redesign] Manage Item varients
2015-07-01 18:29:04 +05:30
Neil Trini Lasrado
fe9cd1d875 More Fixes in Manage Varients 2015-07-01 14:41:30 +05:30
Neil Trini Lasrado
64fbe955c7 Modified Date changed for Item Doctype 2015-07-01 14:04:00 +05:30
Neil Trini Lasrado
0988440fd9 Fixes for Manage Variants 2015-07-01 13:17:15 +05:30
Neil Trini Lasrado
274dd4ada0 Fixed Manage Variants Attribute autocomplete appearance. 2015-07-01 12:51:40 +05:30
Neil Trini Lasrado
724fd82419 Fixes in Manage Variants 2015-07-01 12:51:40 +05:30
Neil Trini Lasrado
3f2604eff6 Patch for Item Variants 2015-07-01 12:51:40 +05:30
Neil Trini Lasrado
c761fefb78 more fixes in test records 2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
203cb10ef7 fixes in test cases 2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
90c66b1998 test cases added 2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
fed431f908 Code Fixes in Manage Variants 2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
bd9745ba72 Rename Item Variant from Manage Variants feature Added. 2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
8fb123b20e item variants, creation, deleation and update logic added.
logic added to copy changes in template to variants
2015-07-01 12:51:11 +05:30
Neil Trini Lasrado
333ccd212b variants combination generation logic added 2015-07-01 12:51:10 +05:30
Neil Trini Lasrado
c8cc8b7115 manage variants new doctype created 2015-07-01 12:51:10 +05:30
Nabin Hait
ec44fa95ce Merge pull request #3537 from neilLasrado/project
Fixed Issues in Project Task
2015-06-30 17:29:19 +05:30
Neil Trini Lasrado
a25e8ea0bc Fixed Issues in Project Task 2015-06-30 17:15:13 +05:30
Rushabh Mehta
ea02b9a5c3 Merge pull request #3530 from anandpdoshi/anand-june-29
[fix] Item Variant Attribute autocomplete appearance. Fixes #3488, #3515, #3525
2015-06-30 13:05:19 +05:30
Rushabh Mehta
74a63bf003 Merge pull request #3531 from pdvyas/exchange-rate-api
Change currency exchange rate api to fixer.io
2015-06-30 12:46:52 +05:30
Pratik Vyas
a0f2510b01 Change currency exchange rate api to fixer.io 2015-06-30 12:36:17 +05:30
Anand Doshi
0820161157 [fix] Item Variant Attribute autocomplete appearance. Fixes #3488, #3515, #3525 2015-06-29 20:57:06 -07:00
Nabin Hait
56bc215855 Merge pull request #3505 from neilLasrado/print-format
Recurring Invoice Print Format
2015-06-29 18:54:24 +05:30
Nabin Hait
8687d25f7e Merge pull request #3526 from neilLasrado/minor-fixes
Minor fixes
2015-06-29 18:53:10 +05:30
Nabin Hait
9cea01fa8b Merge pull request #3527 from nabinhait/develop
Journal Entry list view and delete events via query
2015-06-29 18:39:43 +05:30
Nabin Hait
e06d01e3ed Delete events via query instead of delete_doc function, to save time 2015-06-29 18:38:38 +05:30
Nabin Hait
11243a4fb4 Show amount in Journal Entry list view 2015-06-29 18:38:38 +05:30
Neil Trini Lasrado
b9e5cd0df4 Fixed lead status not updating on Creation of oppurtunity issue 2015-06-29 17:01:32 +05:30
Neil Trini Lasrado
a1f1edc786 Typo fixes in Sales Person 2015-06-29 16:04:12 +05:30
Neil Trini Lasrado
e2d8dd0663 added recurring print format to sales/purchase invoice and order 2015-06-29 12:50:41 +05:30
Nabin Hait
d1605c5cb2 Merge branch 'develop' 2015-06-27 13:09:05 +05:30
Nabin Hait
64ca52fb77 bumped to version 5.0.29 2015-06-27 13:39:05 +06:00
Nabin Hait
2f11a3bdaf Merge pull request #3523 from nabinhait/develop
Multiple fixes
2015-06-27 13:07:44 +05:30
Nabin Hait
943dc1f59c Merge branch 'develop' 2015-06-27 13:07:01 +05:30
Nabin Hait
6d1c994bc9 bumped to version 5.0.28 2015-06-27 13:37:01 +06:00
Nabin Hait
93cdee4503 [fix] Escape values in queries 2015-06-27 12:51:00 +05:30
Nabin Hait
dfac6848cc In list view property added in BOM 2015-06-26 14:42:51 +05:30
Nabin Hait
8ad0b4e0b9 Show Issue id in list view from customer login 2015-06-26 14:42:51 +05:30
Nabin Hait
b8cd92f1aa Merge pull request #3517 from neilLasrado/batch
Added validation to prevent transfer of raw material from an expired …
2015-06-25 18:20:46 +05:30
Nabin Hait
1fe48cb820 Merge pull request #3514 from anandpdoshi/anand-june-24
[fix] Use per_billed instead of per_delivered and per_received for open notification
2015-06-25 18:04:26 +05:30
Anand Doshi
723b046c5b [fix] Use per_billed instead of per_delivered and per_received for open notification 2015-06-24 19:21:52 -04:00
Neil Trini Lasrado
035160c9a6 Added validation to prevent transfer of raw material from an expired batch for manufacturing 2015-06-24 15:25:57 +05:30
Nabin Hait
01c7ce1da3 Merge pull request #3508 from nabinhait/develop
[fix] validate items in stock entry for subcontracting against PO
2015-06-23 11:12:23 +05:30
Nabin Hait
9cf2910ba1 [fix] validate items in stock entry for subcontracting against purchase order 2015-06-23 11:07:34 +05:30
Nabin Hait
c8da7b7d32 Merge branch 'develop' 2015-06-23 10:27:59 +05:30
Nabin Hait
9679d31397 bumped to version 5.0.27 2015-06-23 10:57:59 +06:00
Nabin Hait
38bebe1b83 Merge pull request #3503 from neilLasrado/leave-application
Fixed bugs in Calender View for Leave Application
2015-06-22 19:32:16 +05:30
Nabin Hait
ffbc11e8de Merge pull request #3504 from nabinhait/develop
Multiple fixes
2015-06-22 19:29:32 +05:30
Nabin Hait
818d9674d9 [fix] Update outstanding amount function fixed if party not mentioned 2015-06-22 18:21:38 +05:30
Neil Trini Lasrado
086f8942eb Fixed bugs in Calender View for Leave Application 2015-06-22 13:51:56 +05:30
Nabin Hait
c3b492b237 [fix] Auto remarks in Journal Entry based on company currency 2015-06-22 07:52:38 +05:30
Nabin Hait
9d0dd5066a Removed 'Root Type' validation for receivable/payable account in sales/purchase invoice 2015-06-22 07:32:46 +05:30
Nabin Hait
e7f479b26a Validate accounting entry agaist Stock account if perpetual inventory enabled 2015-06-22 07:31:49 +05:30
Nabin Hait
7ee45b4af2 [fix] Batch-wise balance history: show records only with batch-id 2015-06-18 15:29:14 +05:30
Nabin Hait
5cce1e0929 Merge pull request #3489 from nabinhait/develop
Opening balance
2015-06-18 10:34:31 +05:30
Nabin Hait
be496bc91c [fix] Trial Balance opening 2015-06-18 10:33:20 +05:30
Nabin Hait
59f063e5c3 [fix] opening balance in general ledger report 2015-06-18 10:33:20 +05:30
Nabin Hait
af5820874c Merge branch 'develop' 2015-06-17 15:51:00 +05:30
Nabin Hait
495db99719 bumped to version 5.0.26 2015-06-17 16:21:00 +06:00
Nabin Hait
123beb5a07 Merge pull request #3484 from rmehta/bom-search-report
[report] BOM Search
2015-06-17 15:38:39 +05:30
Nabin Hait
7ed4e080a2 Merge pull request #3486 from nabinhait/develop
Opening balance
2015-06-17 15:36:06 +05:30
Nabin Hait
e91025c0aa [fix] Opening balance in trial balance and general ledger based on is_opening 2015-06-17 15:35:06 +05:30
Nabin Hait
1ac9f2f50d [fix] Opening balance in trial balance and general ledger based on is_opening 2015-06-17 15:09:40 +05:30
Nabin Hait
bd9aa13db3 Minor issue in naming series 2015-06-17 15:09:40 +05:30
Rushabh Mehta
ed9d5cfdaf [minor] cleanup 2015-06-17 02:13:03 +05:30
Rushabh Mehta
bf4547ca5f [fix] dynamic link in BOM Search report 2015-06-17 02:12:06 +05:30
Rushabh Mehta
b45a6bcb88 [report] BOM Search 2015-06-17 01:54:56 +05:30
Anand Doshi
ac59c2b300 [minor] clear Item's introduction section on refresh 2015-06-16 13:06:48 -04:00
Nabin Hait
6a8d7a1b91 Merge branch 'develop' 2015-06-16 16:50:49 +05:30
Nabin Hait
5d71a28e97 bumped to version 5.0.25 2015-06-16 17:20:49 +06:00
Nabin Hait
7d100a1ee7 Merge pull request #3480 from nabinhait/develop
Indexes
2015-06-16 16:49:26 +05:30
Nabin Hait
81dca110eb Change log added 2015-06-16 16:48:47 +05:30
Nabin Hait
9c852108d0 Added index in sales/purchase invoice and fix in index patch 2015-06-16 16:48:47 +05:30
Nabin Hait
e3ac032696 Merge pull request #3472 from neilLasrado/po
Multiple Fixes
2015-06-16 15:52:48 +05:30
Neil Trini Lasrado
64cacfb077 Fixes in Activity Cost 2015-06-16 15:42:40 +05:30
Neil Trini Lasrado
ae4cc078ea Activity Cost - Mandatory removed for Employee. 2015-06-16 15:30:08 +05:30
Nabin Hait
0ee543e932 Merge pull request #3479 from nabinhait/develop
[fix][report] Payment period based on invoice date
2015-06-16 15:29:14 +05:30
Nabin Hait
a123638d37 [fix][report] Payment period based on invoice date 2015-06-16 15:21:00 +05:30
Nabin Hait
58996985ed Merge pull request #3476 from nabinhait/develop
Expense Approver Query and discount label
2015-06-16 15:01:08 +05:30
Nabin Hait
5d0ce7939f Show only users with Expense Approver role in Expense Claim Approver field 2015-06-15 17:59:37 +05:30
Neil Trini Lasrado
4abf552d7b Over Production Allowance Percentage Setting added to Manufacturing Settings 2015-06-15 15:58:45 +05:30
Nabin Hait
7c5ba957ac Label changed for discount amount in base currency 2015-06-15 15:47:07 +05:30
Nabin Hait
77f04e293a Merge branch 'develop' 2015-06-15 10:35:39 +05:30
Nabin Hait
d1d3237784 bumped to version 5.0.24 2015-06-15 11:05:39 +06:00
Nabin Hait
76f0d26f1e Merge pull request #3471 from nabinhait/develop
Hotfix
2015-06-15 10:32:23 +05:30
Nabin Hait
65922d3079 [fix] supplier invoice date can not be after posting date 2015-06-15 10:23:53 +05:30
Nabin Hait
810041cbe3 [fix] Fixed error due to performance upgrade cleanup 2015-06-15 10:20:11 +05:30
Nabin Hait
b9626659ea Merge pull request #3465 from neilLasrado/po
Po
2015-06-15 10:04:36 +05:30
Nabin Hait
e3d13bee36 Merge pull request #3467 from anandpdoshi/anand-june-12
Fixes
2015-06-15 10:03:20 +05:30
Anand Doshi
63e4d31aa6 [fix] Task should be mandatory in Time Log only when Project is mentioned but Production Order is not 2015-06-12 18:59:18 -04:00
Anand Doshi
f2a0161709 [fix] Don't create Time Logs against Production Order if Workstation is not specified in Operations 2015-06-12 18:58:36 -04:00
Neil Trini Lasrado
3c1a4a0b9b percent_complete made no-copy in Project 2015-06-12 18:34:08 +05:30
Neil Trini Lasrado
82cc2921d1 Validation added to prevent user from creating salary structure with 'From Date' before employee 'Date of joining' 2015-06-12 18:34:08 +05:30
117 changed files with 2408 additions and 1549 deletions

View File

@@ -1,2 +1,2 @@
from __future__ import unicode_literals
__version__ = '5.0.23'
__version__ = '5.1.4'

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, fmt_money, getdate, formatdate
from frappe.utils import flt, fmt_money, getdate, formatdate, cstr
from frappe import _
from frappe.model.document import Document
@@ -118,7 +118,7 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
bal = flt(frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry`
where against_voucher_type=%s and against_voucher=%s
and account = %s and party_type=%s and party=%s""",
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s""",
(against_voucher_type, against_voucher, account, party_type, party))[0][0] or 0.0)
if against_voucher_type == 'Purchase Invoice':
@@ -127,8 +127,9 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
against_voucher_amount = flt(frappe.db.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
and account = %s and party_type=%s and party=%s and ifnull(against_voucher, '') = ''""",
(against_voucher, account, party_type, party))[0][0])
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s
and ifnull(against_voucher, '') = ''""",
(against_voucher, account, cstr(party_type), cstr(party)))[0][0])
if not against_voucher_amount:
frappe.throw(_("Against Journal Entry {0} is already adjusted against some other voucher")
@@ -157,3 +158,22 @@ def validate_frozen_account(account, adv_adj=None):
frappe.throw(_("Account {0} is frozen").format(account))
elif frozen_accounts_modifier not in frappe.get_roles():
frappe.throw(_("Not authorized to edit frozen Account {0}").format(account))
def update_against_account(voucher_type, voucher_no):
entries = frappe.db.get_all("GL Entry",
filters={"voucher_type": voucher_type, "voucher_no": voucher_no},
fields=["name", "party", "against", "debit", "credit", "account"])
accounts_debited, accounts_credited = [], []
for d in entries:
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
for d in entries:
if flt(d.debit > 0):
new_against = ", ".join(list(set(accounts_credited)))
if flt(d.credit > 0):
new_against = ", ".join(list(set(accounts_debited)))
if d.against != new_against:
frappe.db.set_value("GL Entry", d.name, "against", new_against)

View File

@@ -53,7 +53,7 @@
"fieldname": "posting_date",
"fieldtype": "Date",
"in_filter": 1,
"in_list_view": 1,
"in_list_view": 0,
"label": "Posting Date",
"no_copy": 1,
"oldfieldname": "posting_date",
@@ -445,7 +445,7 @@
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
"modified": "2015-04-27 20:32:31.655580",
"modified": "2015-06-29 15:28:12.529019",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Journal Entry",

View File

@@ -81,7 +81,7 @@ class JournalEntry(AccountsController):
frappe.throw(_("Row {0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx))
def check_credit_limit(self):
customers = list(set([d.party for d in self.get("accounts")
customers = list(set([d.party for d in self.get("accounts")
if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
if customers:
from erpnext.selling.doctype.customer.customer import check_credit_limit
@@ -243,8 +243,8 @@ class JournalEntry(AccountsController):
def set_against_account(self):
accounts_debited, accounts_credited = [], []
for d in self.get("accounts"):
if flt(d.debit > 0): accounts_debited.append(d.account)
if flt(d.credit) > 0: accounts_credited.append(d.account)
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
for d in self.get("accounts"):
if flt(d.debit > 0): d.against_account = ", ".join(list(set(accounts_credited)))
@@ -275,29 +275,27 @@ class JournalEntry(AccountsController):
else:
msgprint(_("Please enter Reference date"), raise_exception=frappe.MandatoryError)
company_currency = get_company_currency(self.company)
for d in self.get('accounts'):
if d.against_invoice and d.credit:
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = currency), \
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
d.against_invoice))
if d.against_sales_order and d.credit:
currency = frappe.db.get_value("Sales Order", d.against_sales_order, "currency")
r.append(_("{0} against Sales Order {1}").format(fmt_money(flt(d.credit), currency = currency), \
r.append(_("{0} against Sales Order {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
d.against_sales_order))
if d.against_voucher and d.debit:
bill_no = frappe.db.sql("""select bill_no, bill_date, currency
bill_no = frappe.db.sql("""select bill_no, bill_date
from `tabPurchase Invoice` where name=%s""", d.against_voucher)
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
not in ['na', 'not applicable', 'none']:
r.append(_('{0} against Bill {1} dated {2}').format(fmt_money(flt(d.debit), currency=bill_no[0][2]), bill_no[0][0],
r.append(_('{0} against Bill {1} dated {2}').format(fmt_money(flt(d.debit), currency=company_currency), bill_no[0][0],
bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d'))))
if d.against_purchase_order and d.debit:
currency = frappe.db.get_value("Purchase Order", d.against_purchase_order, "currency")
r.append(_("{0} against Purchase Order {1}").format(fmt_money(flt(d.credit), currency = currency), \
r.append(_("{0} against Purchase Order {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
d.against_purchase_order))
if self.user_remark:
@@ -428,7 +426,7 @@ class JournalEntry(AccountsController):
def validate_expense_claim(self):
for d in self.accounts:
if d.against_expense_claim:
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim",
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim",
d.against_expense_claim, ("total_sanctioned_amount", "total_amount_reimbursed"))
pending_amount = flt(sanctioned_amount) - flt(reimbursed_amount)
if d.debit > pending_amount:

View File

@@ -77,6 +77,51 @@
"read_only": 0,
"reqd": 1
},
{
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"allow_on_submit": 1,
"fieldname": "letter_head",
"fieldtype": "Link",
"label": "Letter Head",
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms and Conditions",
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"permlevel": 0,
"read_only": 0
},
{
"allow_on_submit": 1,
"fieldname": "select_print_heading",
"fieldtype": "Link",
"in_filter": 0,
"label": "Print Heading",
"oldfieldname": "select_print_heading",
"oldfieldtype": "Select",
"options": "Print Heading",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
@@ -105,6 +150,14 @@
"read_only": 0,
"reqd": 0
},
{
"fieldname": "mode_of_payment",
"fieldtype": "Link",
"label": "Mode of Payment",
"options": "Mode of Payment",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "cash_bank_account",
"fieldtype": "Link",
@@ -139,17 +192,6 @@
"read_only": 0,
"reqd": 0
},
{
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
@@ -161,16 +203,6 @@
"read_only": 0,
"reqd": 1
},
{
"fieldname": "taxes_and_charges",
"fieldtype": "Link",
"label": "Taxes and Charges",
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Template",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "write_off_account",
"fieldtype": "Link",
@@ -190,43 +222,19 @@
"reqd": 1
},
{
"allow_on_submit": 1,
"fieldname": "letter_head",
"fieldname": "taxes_and_charges",
"fieldtype": "Link",
"label": "Letter Head",
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms and Conditions",
"oldfieldname": "tc_name",
"label": "Taxes and Charges",
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"permlevel": 0,
"read_only": 0
},
{
"allow_on_submit": 1,
"fieldname": "select_print_heading",
"fieldtype": "Link",
"in_filter": 0,
"label": "Print Heading",
"oldfieldname": "select_print_heading",
"oldfieldtype": "Select",
"options": "Print Heading",
"options": "Sales Taxes and Charges Template",
"permlevel": 0,
"read_only": 0
}
],
"icon": "icon-cog",
"idx": 1,
"modified": "2015-05-20 05:38:44.482696",
"modified": "2015-07-07 08:56:04.381471",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Profile",

View File

@@ -224,3 +224,4 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
else
cur_frm.pformat.print_heading = __("Purchase Invoice");
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cint, formatdate, flt
from frappe.utils import cint, formatdate, flt, getdate
from frappe import msgprint, _, throw
from erpnext.setup.utils import get_company_currency
import frappe.defaults
@@ -88,9 +88,7 @@ class PurchaseInvoice(BuyingController):
throw(_("Conversion rate cannot be 0 or 1"))
def validate_credit_to_acc(self):
root_type, account_type = frappe.db.get_value("Account", self.credit_to, ["root_type", "account_type"])
if root_type != "Liability":
frappe.throw(_("Credit To account must be a liability account"))
account_type = frappe.db.get_value("Account", self.credit_to, "account_type")
if account_type != "Payable":
frappe.throw(_("Credit To account must be a Payable account"))
@@ -126,20 +124,11 @@ class PurchaseInvoice(BuyingController):
}
})
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
super(PurchaseInvoice, self).validate_with_previous_doc({
"Purchase Order Item": {
"ref_dn_field": "po_detail",
"compare_fields": [["rate", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
},
"Purchase Receipt Item": {
"ref_dn_field": "pr_detail",
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
self.validate_rate_with_reference_doc([
["Purchase Order", "purchase_order", "po_detail"],
["Purchase Receipt", "purchase_receipt", "pr_detail"]
])
def set_against_expense_account(self):
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
@@ -166,7 +155,7 @@ class PurchaseInvoice(BuyingController):
elif item.expense_account not in against_accounts:
# if no auto_accounting_for_stock or not a stock item
against_accounts.append(item.expense_account)
self.against_expense_account = ",".join(against_accounts)
def po_required(self):
@@ -273,7 +262,7 @@ class PurchaseInvoice(BuyingController):
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": self.credit_to,
"against": self.supplier,
"debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0,
"credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0,
"remarks": self.remarks,
@@ -297,7 +286,7 @@ class PurchaseInvoice(BuyingController):
gl_entries.append(
self.get_gl_dict({
"account": item.expense_account,
"against": self.credit_to,
"against": self.supplier,
"debit": item.base_net_amount,
"remarks": self.remarks,
"cost_center": item.cost_center
@@ -317,7 +306,7 @@ class PurchaseInvoice(BuyingController):
gl_entries.append(
self.get_gl_dict({
"account": stock_received_but_not_billed,
"against": self.credit_to,
"against": self.supplier,
"debit": flt(item.item_tax_amount, self.precision("item_tax_amount", item)),
"remarks": self.remarks or "Accounting Entry for Stock"
})
@@ -343,7 +332,7 @@ class PurchaseInvoice(BuyingController):
self.get_gl_dict({
"account": expenses_included_in_valuation,
"cost_center": cost_center,
"against": self.credit_to,
"against": self.supplier,
"credit": applicable_amount,
"remarks": self.remarks or "Accounting Entry for Stock"
})
@@ -357,7 +346,7 @@ class PurchaseInvoice(BuyingController):
gl_entries.append(
self.get_gl_dict({
"account": self.write_off_account,
"against": self.credit_to,
"against": self.supplier,
"credit": flt(self.write_off_amount),
"remarks": self.remarks,
"cost_center": self.write_off_cost_center
@@ -376,7 +365,7 @@ class PurchaseInvoice(BuyingController):
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
self.make_gl_entries_on_cancel()
self.update_project()
def update_project(self):
project_list = []
for d in self.items:
@@ -386,10 +375,10 @@ class PurchaseInvoice(BuyingController):
project.update_purchase_costing()
project.save()
project_list.append(d.project_name)
def validate_supplier_invoice(self):
if self.bill_date:
if self.bill_date > self.posting_date:
if getdate(self.bill_date) > getdate(self.posting_date):
frappe.throw("Supplier Invoice Date cannot be greater than Posting Date")
if self.bill_no:
if cint(frappe.db.get_single_value("Accounts Settings", "check_supplier_invoice_uniqueness")):
@@ -412,4 +401,4 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s'
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype)})

View File

@@ -49,6 +49,23 @@
"read_only": 0,
"width": "300px"
},
{
"fieldname": "image",
"fieldtype": "Attach",
"hidden": 1,
"label": "Image",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "image_view",
"fieldtype": "Image",
"label": "Image View",
"options": "image",
"permlevel": 0,
"precision": "",
"print_hide": 1
},
{
"fieldname": "quantity_and_rate",
"fieldtype": "Section Break",
@@ -452,7 +469,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2015-06-02 14:18:56.294949",
"modified": "2015-07-02 03:00:44.496683",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",

View File

@@ -36,7 +36,7 @@ def get_items(price_list, sales_or_purchase, item=None):
if(locate(%(_name)s, i.item_name), locate(%(_name)s, i.item_name), 99999),
if(locate(%(_name)s, i.variant_of), locate(%(_name)s, i.variant_of), 99999),
if(locate(%(_name)s, i.item_group), locate(%(_name)s, i.item_group), 99999),"""
args["name"] = "%%%s%%" % item
args["name"] = "%%%s%%" % frappe.db.escape(item)
args["_name"] = item.replace("%", "")
# locate function is used to sort by closest match from the beginning of the value

View File

@@ -392,8 +392,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
}
}
cur_frm.set_query("debit_to", function(doc) {
return{
filters: [

View File

@@ -38,7 +38,8 @@
"options": "Customer",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
"read_only": 0,
"search_index": 1
},
{
"depends_on": "customer",
@@ -46,7 +47,7 @@
"fieldtype": "Data",
"hidden": 0,
"in_list_view": 0,
"label": "Name",
"label": "Customer Name",
"oldfieldname": "customer_name",
"oldfieldtype": "Data",
"permlevel": 0,
@@ -502,7 +503,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -880,7 +881,7 @@
"options": "Project",
"permlevel": 0,
"read_only": 0,
"search_index": 1
"search_index": 0
},
{
"depends_on": "eval:doc.source == 'Campaign'",
@@ -1226,6 +1227,15 @@
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:doc.is_recurring==1",
"fieldname": "recurring_print_format",
"fieldtype": "Link",
"label": "Recurring Print Format",
"options": "Print Format",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "against_income_account",
"fieldtype": "Small Text",
@@ -1243,7 +1253,7 @@
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
"modified": "2015-05-27 02:48:02.897865",
"modified": "2015-07-03 03:25:40.519956",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",

View File

@@ -65,8 +65,7 @@ class SalesInvoice(SellingController):
self.set_against_income_account()
self.validate_c_form()
self.validate_time_logs_are_submitted()
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
"items")
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", "items")
def on_submit(self):
super(SalesInvoice, self).on_submit()
@@ -170,6 +169,7 @@ class SalesInvoice(SellingController):
if pos:
if not for_validate and not self.customer:
self.customer = pos.customer
self.mode_of_payment = pos.mode_of_payment
# self.set_customer_defaults()
for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name',
@@ -236,9 +236,7 @@ class SalesInvoice(SellingController):
reconcile_against_document(lst)
def validate_debit_to_acc(self):
root_type, account_type = frappe.db.get_value("Account", self.debit_to, ["root_type", "account_type"])
if root_type != "Asset":
frappe.throw(_("Debit To account must be a liability account"))
account_type = frappe.db.get_value("Account", self.debit_to, "account_type")
if account_type != "Receivable":
frappe.throw(_("Debit To account must be a Receivable account"))
@@ -266,20 +264,11 @@ class SalesInvoice(SellingController):
},
})
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(SalesInvoice, self).validate_with_previous_doc({
"Sales Order Item": {
"ref_dn_field": "so_detail",
"compare_fields": [["rate", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
},
"Delivery Note Item": {
"ref_dn_field": "dn_detail",
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
self.validate_rate_with_reference_doc([
["Sales Order", "sales_order", "so_detail"],
["Delivery Note", "delivery_note", "dn_detail"]
])
def set_against_income_account(self):
"""Set against account for debit to account"""
@@ -506,7 +495,7 @@ class SalesInvoice(SellingController):
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": self.debit_to,
"against": self.customer,
"credit": flt(tax.base_tax_amount_after_discount_amount),
"remarks": self.remarks,
"cost_center": tax.cost_center
@@ -520,7 +509,7 @@ class SalesInvoice(SellingController):
gl_entries.append(
self.get_gl_dict({
"account": item.income_account,
"against": self.debit_to,
"against": self.customer,
"credit": item.base_net_amount,
"remarks": self.remarks,
"cost_center": item.cost_center
@@ -551,7 +540,7 @@ class SalesInvoice(SellingController):
gl_entries.append(
self.get_gl_dict({
"account": self.cash_bank_account,
"against": self.debit_to,
"against": self.customer,
"debit": self.paid_amount,
"remarks": self.remarks,
})
@@ -575,7 +564,7 @@ class SalesInvoice(SellingController):
gl_entries.append(
self.get_gl_dict({
"account": self.write_off_account,
"against": self.debit_to,
"against": self.customer,
"debit": self.write_off_amount,
"remarks": self.remarks,
"cost_center": self.write_off_cost_center
@@ -590,7 +579,7 @@ def get_list_context(context=None):
@frappe.whitelist()
def get_bank_cash_account(mode_of_payment, company):
account = frappe.db.get_value("Mode of Payment Account",
account = frappe.db.get_value("Mode of Payment Account",
{"parent": mode_of_payment, "company": company}, "default_account")
if not account:
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
@@ -614,7 +603,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s'
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype)})
@frappe.whitelist()
def make_delivery_note(source_name, target_doc=None):

View File

@@ -68,6 +68,23 @@
"reqd": 1,
"width": "200px"
},
{
"fieldname": "image",
"fieldtype": "Attach",
"hidden": 1,
"label": "Image",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "image_view",
"fieldtype": "Image",
"label": "Image View",
"options": "image",
"permlevel": 0,
"precision": "",
"print_hide": 1
},
{
"fieldname": "quantity_and_rate",
"fieldtype": "Section Break",
@@ -505,7 +522,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2015-06-02 14:18:45.176726",
"modified": "2015-07-02 02:59:08.413213",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, cstr
from frappe.utils import flt, cstr, cint
from frappe import _
from frappe.model.meta import get_field_precision
from erpnext.accounts.utils import validate_expense_against_budget
@@ -82,14 +82,15 @@ def make_entry(args, adv_adj, update_outstanding):
gle.submit()
def validate_account_for_auto_accounting_for_stock(gl_map):
if gl_map[0].voucher_type=="Journal Entry":
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
where account_type = 'Warehouse' and ifnull(warehouse, '')!=''""")]
if cint(frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock")) \
and gl_map[0].voucher_type=="Journal Entry":
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
where account_type = 'Warehouse' and ifnull(warehouse, '')!=''""")]
for entry in gl_map:
if entry.account in aii_accounts:
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
.format(entry.account), StockAccountInvalidTransaction)
for entry in gl_map:
if entry.account in aii_accounts:
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
.format(entry.account), StockAccountInvalidTransaction)
def round_off_debit_credit(gl_map):
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),

View File

@@ -171,7 +171,7 @@ class ReceivablePayableReport(object):
def get_gl_entries(self, party_type):
if not hasattr(self, "gl_entries"):
conditions, values = self.prepare_conditions(party_type)
self.gl_entries = frappe.db.sql("""select posting_date, account, party_type, party, debit, credit,
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party, debit, credit,
voucher_type, voucher_no, against_voucher_type, against_voucher from `tabGL Entry`
where docstatus < 2 and party_type=%s {0} order by posting_date, party"""
.format(conditions), values, as_dict=True)

View File

@@ -210,7 +210,7 @@ def get_gl_entries(company, from_date, to_date, root_lft, root_rgt, ignore_closi
if from_date:
additional_conditions.append("and posting_date >= %(from_date)s")
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit from `tabGL Entry`
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening from `tabGL Entry`
where company=%(company)s
{additional_conditions}
and posting_date <= %(to_date)s

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, getdate
from frappe.utils import flt, getdate, cstr
from frappe import _
def execute(filters=None):
@@ -66,7 +66,7 @@ def get_gl_entries(filters):
gl_entries = frappe.db.sql("""select posting_date, account, party_type, party,
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
voucher_type, voucher_no, cost_center, remarks, against
voucher_type, voucher_no, cost_center, remarks, against, is_opening
from `tabGL Entry`
where company=%(company)s {conditions}
{group_by_condition}
@@ -155,7 +155,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
for gle in gl_entries:
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
if (filters.get("account") or filters.get("party") or filters.get("group_by_account")) \
and gle.posting_date < from_date:
and (gle.posting_date < from_date or cstr(gle.is_opening) == "Yes"):
gle_map[gle.account].opening += amount
if filters.get("account") or filters.get("party"):
opening += amount

View File

@@ -175,16 +175,15 @@ class GrossProfitGenerator(object):
else:
if row.update_stock or row.dn_detail:
parenttype, parent, item_row = row.parenttype, row.parent, row.item_row
if row.dn_detail:
row.parenttype = "Delivery Note"
row.parent = row.delivery_note
row.item_row = row.dn_detail
parenttype, parent, item_row = "Delivery Note", row.delivery_note, row.dn_detail
my_sle = self.sle.get((item_code, row.warehouse))
for i, sle in enumerate(my_sle):
# find the stock valution rate from stock ledger entry
if sle.voucher_type == row.parenttype and row.parent == sle.voucher_no and \
sle.voucher_detail_no == row.item_row:
if sle.voucher_type == parenttype and parent == sle.voucher_no and \
sle.voucher_detail_no == item_row:
previous_stock_value = len(my_sle) > i+1 and \
flt(my_sle[i+1].stock_value) or 0.0
return previous_stock_value - flt(sle.stock_value)

View File

@@ -9,8 +9,9 @@ from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
validate_filters(filters)
columns = get_columns(filters)
entries = get_entries(filters)
invoice_posting_date_map = get_invoice_posting_date_map(filters)
against_date = ""
@@ -36,11 +37,18 @@ def execute(filters=None):
data.append(row)
return columns, data
def validate_filters(filters):
if (filters.get("payment_type") == "Incoming" and filters.get("party_type") == "Supplier") or \
(filters.get("payment_type") == "Outgoing" and filters.get("party_type") == "Customer"):
frappe.throw(_("{0} payment entries can not be filtered by {1}")\
.format(filters.payment_type, filters.party_type))
def get_columns():
def get_columns(filters):
return [_("Journal Entry") + ":Link/Journal Entry:140",
_("Party Type") + ":Link/DocType:100", _("Party") + ":Dynamic Link/party_type:140",
_("Posting Date") + ":Date:100", _("Against Invoice") + ":Link/Purchase Invoice:130",
_("Party Type") + ":Link/DocType:100", _("Party") + ":Dynamic Link/Party Type:140",
_("Posting Date") + ":Date:100",
_("Against Invoice") + (":Link/Purchase Invoice:130" if filters.get("payment_type") == "Outgoing" else ":Link/Sales Invoice:130"),
_("Against Invoice Posting Date") + ":Date:130", _("Debit") + ":Currency:120", _("Credit") + ":Currency:120",
_("Reference No") + "::100", _("Reference Date") + ":Date:100", _("Remarks") + "::150", _("Age") +":Int:40",
"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", _("90-Above") + ":Currency:100"

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cint, flt, getdate, formatdate
from frappe.utils import cint, flt, getdate, formatdate, cstr
from erpnext.accounts.report.financial_statements import filter_accounts, get_gl_entries
value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit")
@@ -90,7 +90,7 @@ def get_rootwise_opening_balances(filters, report_type):
where
company=%(company)s
{additional_conditions}
and posting_date < %(from_date)s
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
and account in (select name from `tabAccount` where report_type=%(report_type)s)
group by account""".format(additional_conditions=additional_conditions),
{
@@ -128,16 +128,18 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters)
for d in accounts:
d.update(init.copy())
# add opening
d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0)
d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0)
for entry in gl_entries_by_account.get(d.name, []):
d["debit"] += flt(entry.debit)
d["credit"] += flt(entry.credit)
if cstr(entry.is_opening) != "Yes":
d["debit"] += flt(entry.debit)
d["credit"] += flt(entry.credit)
total_row["debit"] += d["debit"]
total_row["credit"] += d["credit"]
# add opening
d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0)
d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0)
return total_row

View File

@@ -53,7 +53,7 @@
"fieldtype": "Data",
"hidden": 0,
"in_list_view": 0,
"label": "Name",
"label": "Supplier Name",
"permlevel": 0,
"read_only": 1
},
@@ -457,7 +457,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -868,12 +868,21 @@
"no_copy": 1,
"permlevel": 0,
"print_hide": 1
},
{
"depends_on": "eval:doc.is_recurring==1",
"fieldname": "recurring_print_format",
"fieldtype": "Link",
"label": "Recurring Print Format",
"options": "Print Format",
"permlevel": 0,
"precision": ""
}
],
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
"modified": "2015-06-02 17:15:44.711032",
"modified": "2015-07-03 03:26:43.080551",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",

View File

@@ -439,7 +439,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -660,7 +660,7 @@
"icon": "icon-shopping-cart",
"idx": 1,
"is_submittable": 1,
"modified": "2015-06-02 17:15:57.283516",
"modified": "2015-06-15 15:39:08.954248",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation",

View File

@@ -0,0 +1,17 @@
- Performance upgrade in Trial Balance, General Ledger, AR/AP, Balance Sheet and P&L Statement reports
- Add index on Account and GL Entry, Sales Invoice and Purchase Invoice table
- Don't create Time Logs against Production Order if Workstation is not specified in Operations
- Task should be mandatory in Time Log only when Project is mentioned but Production Order is not
- Supplier invoice no unique validation and supplier invoice date can not be after posting date
- Removed BOM No from mandatory from Stock Entry against Production Order
- Load tasks in project for printing purpose
- Added Customers Not Buying Since Long Time against Sales Invoice
- POS - search by Item Group
- Payment period based on invoice date: show party columns and filter based on party
- Barcode added to Purchase Receipt
- Fetch item name and desc on change of item code in Quality Inspection
- Show item name in item grid view based 'In List View' property
- Validate and update manufactured qty in Stock Entry
- Show only users with Expense Approver role in Expense Claim Approver field
- Over Production Allowance Percentage Setting added to Manufacturing Settings
- Activity Cost - Mandatory removed for Employee

View File

@@ -0,0 +1 @@
- Open notification of Sales Order and Purchase Order based on whether Invoice is created against them. For eg. If a Sales Order is not Invoiced, it will be considered as open. Previously it was considered open if Delivery Note was created against Sales Order.

View File

@@ -0,0 +1,8 @@
- Item variants is now manageable via dedicated tool **Manage Variants**. To learn about it, check [Manual Page for Item variants](https://manual.erpnext.com/contents/stock/item/item-variants)
- Against account in General Ledger will show Party instead of Account (which is not useful)
- Print format for recurring documents can be set by the users
- Recurring documents won't be created for Stopped Sales / Purchase Orders.
- Lead status will be changed to 'Opportunity' when Lead converted to Opportunity
- Amount in Journal Entry list view
- Currency exchange rate is now automatically fetched from fixer.io, instead of jsonrates.com
- Item image is now available in Sales / Purchase Invoice

View File

@@ -0,0 +1,3 @@
- Hide zero balance rows in batch-wise balance history report
- Autocomplete issue fixed in Manage Variants
- Remove user permission (Employee role) if user id is unset from Employee record

View File

@@ -0,0 +1,4 @@
- Mode of Payment added to POS Profile
- Expired Batch is not allowed in stock entry of type manufacturing / repack
- Validate item rate against reference document with tolerance 0.009
- Set Customer name in opportunity as per company name in lead

View File

@@ -73,6 +73,11 @@ def get_data():
"label": _("Setup"),
"icon": "icon-cog",
"items": [
{
"type": "doctype",
"name": "Company",
"description": _("Company (not Customer or Supplier) master.")
},
{
"type": "doctype",
"name": "Fiscal Year",

View File

@@ -103,6 +103,12 @@ def get_data():
"name": "Completed Production Orders",
"doctype": "Production Order"
},
{
"type": "report",
"is_query_report": True,
"name": "BOM Search",
"doctype": "BOM"
},
]
},
{

View File

@@ -237,6 +237,12 @@ def get_data():
"route": "query-report/Sales Person Target Variance Item Group-Wise",
"doctype": "Sales Person",
},
{
"type": "report",
"is_query_report": True,
"name": "BOM Search",
"doctype": "BOM"
},
{
"type": "report",
"is_query_report": True,

View File

@@ -110,43 +110,7 @@ def get_data():
"description": _("Setup SMS gateway settings")
},
]
},
{
"label": _("Masters"),
"icon": "icon-star",
"items": [
{
"type": "doctype",
"name": "Company",
"description": _("Company (not Customer or Supplier) master.")
},
{
"type": "doctype",
"name": "Item",
"description": _("Item master.")
},
{
"type": "doctype",
"name": "Customer",
"description": _("Customer master.")
},
{
"type": "doctype",
"name": "Supplier",
"description": _("Supplier master.")
},
{
"type": "doctype",
"name": "Contact",
"description": _("Contact master.")
},
{
"type": "doctype",
"name": "Address",
"description": _("Address master.")
},
]
},
}
]
for module, label, icon in (

View File

@@ -194,7 +194,7 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
and tabBOM.is_active=1
and tabBOM.%(key)s like "%(txt)s"
%(fcond)s %(mcond)s
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % txt,
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % frappe.db.escape(txt),
'fcond': get_filters_cond(doctype, filters, conditions),
'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len})
@@ -207,7 +207,7 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
where `tabProject`.status not in ("Completed", "Cancelled")
and %(cond)s `tabProject`.name like "%(txt)s" %(mcond)s
order by `tabProject`.name asc
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % txt,
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % frappe.db.escape(txt),
'mcond':get_match_cond(doctype),'start': start, 'page_len': page_len})
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
@@ -229,9 +229,10 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
if not filters.get("posting_date"):
filters["posting_date"] = nowdate()
cond = ""
if filters.get("posting_date"):
cond = "and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)"
batch_nos = None
args = {
'item_code': filters.get("item_code"),
@@ -251,23 +252,23 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
and sle.warehouse = %(warehouse)s
and sle.batch_no like %(txt)s
and batch.docstatus < 2
and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)
{0}
{match_conditions}
group by batch_no having sum(sle.actual_qty) > 0
order by batch.expiry_date, sle.batch_no desc
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
if batch_nos:
return batch_nos
else:
return frappe.db.sql("""select name, expiry_date from `tabBatch`
return frappe.db.sql("""select name, expiry_date from `tabBatch` batch
where item = %(item_code)s
and name like %(txt)s
and docstatus < 2
and (ifnull(expiry_date, '')='' or expiry_date >= %(posting_date)s)
{0}
{match_conditions}
order by expiry_date, name desc
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args, debug=1)
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
filter_list = []

View File

@@ -33,11 +33,13 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
next_date = next_date or nowdate()
date_field = date_field_map[doctype]
condition = " and ifnull(status, '') != 'Stopped'" if doctype in ("Sales Order", "Purchase Order") else ""
recurring_documents = frappe.db.sql("""select name, recurring_id
from `tab{}` where ifnull(is_recurring, 0)=1
and docstatus=1 and next_date='{}'
and next_date <= ifnull(end_date, '2199-12-31')""".format(doctype, next_date))
from `tab{0}` where ifnull(is_recurring, 0)=1
and docstatus=1 and next_date=%s
and next_date <= ifnull(end_date, '2199-12-31') {1}""".format(doctype, condition), next_date)
exception_list = []
for ref_document, recurring_id in recurring_documents:
@@ -124,7 +126,7 @@ def send_notification(new_rv):
frappe.sendmail(new_rv.notification_email_address,
subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name)])
attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name, print_format=new_rv.recurring_print_format)])
def notify_errors(doc, doctype, party, owner):
from frappe.utils.user import get_system_managers

View File

@@ -29,7 +29,7 @@
"fieldtype": "Data",
"in_filter": 1,
"in_list_view": 0,
"label": "Contact Name",
"label": "Person Name",
"oldfieldname": "lead_name",
"oldfieldtype": "Data",
"permlevel": 0,
@@ -344,7 +344,7 @@
],
"icon": "icon-user",
"idx": 1,
"modified": "2015-04-02 15:13:02.621854",
"modified": "2015-07-03 03:26:18.579905",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",

View File

@@ -75,8 +75,7 @@ class Lead(SellingController):
return frappe.db.get_value("Customer", {"lead_name": self.name})
def has_opportunity(self):
return frappe.db.get_value("Opportunity", {"lead": self.name, "docstatus": 1,
"status": ["!=", "Lost"]})
return frappe.db.get_value("Opportunity", {"lead": self.name, "status": ["!=", "Lost"]})
@frappe.whitelist()
def make_customer(source_name, target_doc=None):

View File

@@ -79,7 +79,8 @@ class Opportunity(TransactionBase):
if self.customer:
self.customer_name = frappe.db.get_value("Customer", self.customer, "customer_name")
elif self.lead:
self.customer_name = frappe.db.get_value("Lead", self.lead, "lead_name")
lead_name, company_name = frappe.db.get_value("Lead", self.lead, ["lead_name", "company_name"])
self.customer_name = company_name or lead_name
def get_cust_address(self,name):
details = frappe.db.sql("""select customer_name, address, territory, customer_group

View File

@@ -5,7 +5,7 @@ app_publisher = "Frappe Technologies Pvt. Ltd. and Contributors"
app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
app_icon = "icon-th"
app_color = "#e74c3c"
app_version = "5.0.23"
app_version = "5.1.4"
error_report_email = "support@erpnext.com"
@@ -25,8 +25,13 @@ on_logout = "erpnext.shopping_cart.utils.clear_cart_count"
# website
update_website_context = "erpnext.shopping_cart.utils.update_website_context"
my_account_context = "erpnext.shopping_cart.utils.update_my_account_context"
email_append_to = ["Job Applicant", "Opportunity", "Issue"]
calendars = ["Task", "Production Order", "Time Log", "Leave Application"]
website_generators = ["Item Group", "Item", "Sales Partner"]
website_context = {
"favicon": "/assets/erpnext/images/favicon.png",
"splash_image": "/assets/erpnext/images/splash.png"
@@ -52,14 +57,10 @@ dump_report_map = "erpnext.startup.report_data_map.data_map"
before_tests = "erpnext.setup.utils.before_tests"
website_generators = ["Item Group", "Item", "Sales Partner"]
standard_queries = {
"Customer": "erpnext.selling.doctype.customer.customer.get_customer_list"
}
communication_covert_to = ["Lead", "Issue", "Job Application"]
doc_events = {
"Stock Entry": {
"on_submit": "erpnext.stock.doctype.material_request.material_request.update_completed_and_requested_qty",
@@ -78,8 +79,10 @@ doc_events = {
}
scheduler_events = {
"hourly": [
"erpnext.controllers.recurring_document.create_recurring_documents"
],
"daily": [
"erpnext.controllers.recurring_document.create_recurring_documents",
"erpnext.stock.reorder_item.reorder_item",
"erpnext.setup.doctype.email_digest.email_digest.send",
"erpnext.support.doctype.issue.issue.auto_close_tickets",
@@ -104,4 +107,3 @@ get_translated_dict = {
("page", "setup-wizard"): "frappe.geo.country_info.get_translated_dict",
("doctype", "Global Defaults"): "frappe.geo.country_info.get_translated_dict"
}

View File

@@ -45,6 +45,10 @@ class Employee(Document):
if self.user_id:
self.validate_for_enabled_user_id()
self.validate_duplicate_user_id()
else:
existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
if existing_user_id:
frappe.permissions.remove_user_permission("Employee", self.name, existing_user_id)
def on_update(self):
if self.user_id:

View File

@@ -63,7 +63,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) {
cur_frm.set_query("exp_approver", function() {
return {
filters: [["UserRole", "role", "=", "Expense Approver"]]
query: "erpnext.hr.doctype.expense_claim.expense_claim.get_expense_approver"
};
});
}

View File

@@ -58,4 +58,13 @@ class ExpenseClaim(Document):
def validate_sanctioned_amount(self):
for d in self.get('expenses'):
if flt(d.sanctioned_amount) > flt(d.claim_amount):
frappe.throw(_("Sanctioned Amount cannot be greater than Claim Amount in Row {0}.").format(d.idx))
frappe.throw(_("Sanctioned Amount cannot be greater than Claim Amount in Row {0}.").format(d.idx))
@frappe.whitelist()
def get_expense_approver(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""
select u.name, concat(u.first_name, ' ', u.last_name)
from tabUser u, tabUserRole r
where u.name = r.parent and r.role = 'Expense Approver' and u.name like %s
""", ("%" + txt + "%"))

View File

@@ -339,6 +339,7 @@ def add_block_dates(events, start, end, employee, company):
events.append({
"doctype": "Leave Block List Date",
"from_date": block_date.block_date,
"to_date": block_date.block_date,
"title": _("Leave Blocked") + ": " + block_date.reason,
"name": "_" + str(cnt),
})
@@ -355,6 +356,7 @@ def add_holidays(events, start, end, employee, company):
events.append({
"doctype": "Holiday",
"from_date": holiday.holiday_date,
"to_date": holiday.holiday_date,
"title": _("Holiday") + ": " + cstr(holiday.description),
"name": holiday.name
})

View File

@@ -1,30 +1,44 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
var display_activity_log = function(msg) {
cur_frm.cscript.display_activity_log = function(msg) {
if(!cur_frm.ss_html)
cur_frm.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div');
cur_frm.ss_html.innerHTML =
'<div class="padding"><h4>'+__("Activity Log:")+'</h4>'+msg+'</div>';
if(msg) {
cur_frm.ss_html.innerHTML =
'<div class="padding"><h4>'+__("Activity Log:")+'</h4>'+msg+'</div>';
} else {
cur_frm.ss_html.innerHTML = "";
}
}
//Create salary slip
//-----------------------
cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
cur_frm.cscript.display_activity_log("");
var callback = function(r, rt){
if (r.message)
display_activity_log(r.message);
cur_frm.cscript.display_activity_log(r.message);
}
return $c('runserverobj', args={'method':'create_sal_slip','docs':doc},callback);
}
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
cur_frm.cscript.display_activity_log("");
var check = confirm(__("Do you really want to Submit all Salary Slip for month {0} and year {1}", [doc.month, doc.fiscal_year]));
if(check){
// clear all in locals
if(locals["Salary Slip"]) {
$.each(locals["Salary Slip"], function(name, d) {
frappe.model.remove_from_locals("Salary Slip", name);
});
}
var callback = function(r, rt){
if (r.message)
display_activity_log(r.message);
cur_frm.cscript.display_activity_log(r.message);
}
return $c('runserverobj', args={'method':'submit_salary_slip','docs':doc},callback);
}
}
@@ -47,4 +61,4 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
frappe.ui.form.on("Salary Manager", "refresh", function(frm) {
frm.disable_save();
});
});

View File

@@ -101,7 +101,7 @@ class SalaryManager(Document):
log = "<p>No employee for the above selected criteria OR salary slip already created</p>"
if ss_list:
log = "<b>Salary Slip Created For</b>\
<br><br>%s" % '<br>'.join(ss_list)
<br><br>%s" % '<br>'.join(self.format_as_links(ss_list))
return log
@@ -144,7 +144,7 @@ class SalaryManager(Document):
else:
all_ss = [d[0] for d in all_ss]
submitted_ss = list(set(all_ss) - set(not_submitted_ss))
submitted_ss = self.format_as_links(list(set(all_ss) - set(not_submitted_ss)))
if submitted_ss:
mail_sent_msg = self.send_email and " (Mail has been sent to the employee)" or ""
log = """
@@ -164,6 +164,9 @@ class SalaryManager(Document):
"""% ('<br>'.join(not_submitted_ss))
return log
def format_as_links(self, ss_list):
return ['<a href="#Form/Salary Slip/{0}">{0}</a>'.format(s) for s in ss_list]
def get_total_salary(self):
"""

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt
from frappe.utils import cstr, flt, getdate
from frappe.model.naming import make_autoname
from frappe import _
from frappe.model.mapper import get_mapped_doc
@@ -14,6 +14,13 @@ from erpnext.hr.utils import set_employee_name
class SalaryStructure(Document):
def autoname(self):
self.name = make_autoname(self.employee + '/.SST' + '/.#####')
def validate(self):
self.check_existing()
self.validate_amount()
self.validate_employee()
self.validate_joining_date()
set_employee_name(self)
def get_employee_details(self):
ret = {}
@@ -77,14 +84,11 @@ class SalaryStructure(Document):
old_employee = frappe.db.get_value("Salary Structure", self.name, "employee")
if old_employee and self.employee != old_employee:
frappe.throw(_("Employee can not be changed"))
def validate(self):
self.check_existing()
self.validate_amount()
self.validate_employee()
set_employee_name(self)
def validate_joining_date(self):
joining_date = getdate(frappe.db.get_value("Employee", self.employee, "date_of_joining"))
if getdate(self.from_date) < joining_date:
frappe.throw(_("From Date in Salary Structure cannot be lesser than Employee Joining Date."))
@frappe.whitelist()
def make_salary_slip(source_name, target_doc=None):

View File

@@ -75,8 +75,20 @@ def get_conditions(filters):
filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"].index(filters["month"]) + 1
from frappe.model.document import Document
fiscal_years = frappe.get_doc("Fiscal Year",filters["fiscal_year"])
import datetime
year_start = fiscal_years.year_start_date.strftime("%Y")
year_end = fiscal_years.year_end_date.strftime("%Y")
dt_test = datetime.datetime.strptime(year_end + "-" + str(100+int(filters["month"]))[2:3] + "-01", "%Y-%m-%d")
date_test = datetime.date(dt_test.year, dt_test.month, dt_test.day)
if date_test > fiscal_years.year_end_date:
year_target = year_start
else:
year_target = year_end
from calendar import monthrange
filters["total_days_in_month"] = monthrange(cint(filters["fiscal_year"].split("-")[-1]),
filters["total_days_in_month"] = monthrange(cint(year_target),
filters["month"])[1]
conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s"

View File

@@ -61,7 +61,7 @@ var get_bom_material_detail= function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
return frappe.call({
doc: cur_frm.doc,
doc: doc,
method: "get_bom_material_detail",
args: {
'item_code': d.item_code,
@@ -234,5 +234,3 @@ frappe.ui.form.on("BOM", "with_operations", function(frm) {
cur_frm.cscript.image = function() {
refresh_field("image_view");
}

View File

@@ -12,7 +12,7 @@
"fieldname": "item",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 0,
"in_list_view": 1,
"label": "Item",
"oldfieldname": "item",
"oldfieldtype": "Link",
@@ -54,7 +54,7 @@
"fieldname": "is_active",
"fieldtype": "Check",
"hidden": 0,
"in_list_view": 0,
"in_list_view": 1,
"label": "Is Active",
"no_copy": 1,
"oldfieldname": "is_active",
@@ -67,7 +67,7 @@
"default": "1",
"fieldname": "is_default",
"fieldtype": "Check",
"in_list_view": 0,
"in_list_view": 1,
"label": "Is Default",
"no_copy": 1,
"oldfieldname": "is_default",
@@ -279,7 +279,7 @@
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"modified": "2015-03-03 14:22:44.725097",
"modified": "2015-06-26 02:02:30.705279",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM",

View File

@@ -55,6 +55,13 @@
"label": "Time Between Operations (in mins)",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "over_production_allowance_percentage",
"fieldtype": "Percent",
"label": "Over Production Allowance Percentage",
"permlevel": 0,
"precision": ""
}
],
"hide_heading": 0,
@@ -65,7 +72,7 @@
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"modified": "2015-04-21 07:57:40.260862",
"modified": "2015-06-15 05:52:22.986958",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Manufacturing Settings",

View File

@@ -90,8 +90,9 @@ class ProductionOrder(Document):
(self.sales_order, self.production_item))[0][0]
# total qty in SO
so_qty = flt(so_item_qty) + flt(dnpi_qty)
if total_qty > so_qty:
allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings", "over_production_allowance_percentage"))
if total_qty > so_qty + (allowance_percentage/100 * so_qty):
frappe.throw(_("Cannot produce more Item {0} than Sales Order quantity {1}").format(self.production_item,
so_qty), OverProductionError)
@@ -217,12 +218,14 @@ class ProductionOrder(Document):
for i, d in enumerate(self.operations):
self.set_operation_start_end_time(i, d)
if not d.workstation:
continue
time_log = make_time_log(self.name, d.operation, d.planned_start_time, d.planned_end_time,
flt(self.qty) - flt(d.completed_qty), self.project_name, d.workstation, operation_id=d.name)
if d.workstation:
# validate operating hours if workstation [not mandatory] is specified
self.check_operation_fits_in_working_hours(d)
# validate operating hours if workstation [not mandatory] is specified
self.check_operation_fits_in_working_hours(d)
original_start_time = time_log.from_time
while True:

View File

@@ -166,4 +166,8 @@ erpnext.patches.v5_0.portal_fixes
erpnext.patches.v5_0.reset_values_in_tools
execute:frappe.delete_doc("Page", "users")
erpnext.patches.v5_0.update_material_transferred_for_manufacturing_again
erpnext.patches.v5_0.index_on_account_and_gl_entry
erpnext.patches.v5_0.index_on_account_and_gl_entry
execute:frappe.db.sql("""delete from `tabProject Task`""")
erpnext.patches.v5_0.item_variants
erpnext.patches.v5_0.update_item_desc_in_invoice
erpnext.patches.v5_1.fix_against_account

View File

@@ -30,8 +30,8 @@ def create_receivable_payable_account():
account_id = account.name
frappe.db.set_value("Company", args["company"], ("default_receivable_account"
if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
frappe.db.set_value("Company", args["company"], ("default_receivable_account"
if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account_id)

View File

@@ -5,18 +5,26 @@ import frappe
def execute():
index_map = {
"Account": ["parent_account", "lft", "rgt"],
"GL Entry": ["posting_date", "account", 'party', "voucher_no"]
"GL Entry": ["posting_date", "account", 'party', "voucher_no"],
"Sales Invoice": ["posting_date", "debit_to", "customer"],
"Purchase Invoice": ["posting_date", "credit_to", "supplier"]
}
for dt, indexes in index_map.items():
existing_indexes = [d.Key_name for d in frappe.db.sql("""show index from `tab{0}`
existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}`
where Column_name != 'name'""".format(dt), as_dict=1)]
for old in existing_indexes:
if old in ("parent", "group_or_ledger", "is_pl_account", "debit_or_credit", "account_name", "company"):
for old, column in existing_indexes:
if column in ("parent", "group_or_ledger", "is_group", "is_pl_account", "debit_or_credit",
"account_name", "company", "project_name", "voucher_date", "due_date", "bill_no",
"bill_date", "is_opening", "fiscal_year", "outstanding_amount"):
frappe.db.sql("alter table `tab{0}` drop index {1}".format(dt, old))
existing_indexes.remove(old)
existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}`
where Column_name != 'name'""".format(dt), as_dict=1)]
existing_indexed_columns = list(set([x[1] for x in existing_indexes]))
for new in indexes:
if new not in existing_indexes:
if new not in existing_indexed_columns:
frappe.db.sql("alter table `tab{0}` add index ({1})".format(dt, new))

View File

@@ -0,0 +1,19 @@
import frappe
def execute():
frappe.reload_doctype("Item")
for dt in ["manage_variants", "manage_variants_item", "variant_attribute"]:
frappe.reload_doc("stock", "doctype", dt)
for d in frappe.get_list("Item", filters={"has_variants":1}):
manage_variant = frappe.new_doc("Manage Variants")
manage_variant.item_code = d.name
manage_variant.attributes = frappe.db.sql("select item_attribute as attribute, item_attribute_value as attribute_value \
from `tabItem Variant` where parent = %s", d.name, as_dict=1)
if manage_variant.attributes:
if not frappe.get_list("Item", filters={"variant_of": d.name}, limit_page_length=1):
frappe.db.sql("delete from `tabItem Variant` where parent=%s", d.name)
else:
manage_variant.generate_combinations()
manage_variant.create_variants()
frappe.delete_doc("DocType", "Item Variant")

View File

@@ -7,6 +7,6 @@ def execute():
account_settings = frappe.get_doc("Accounts Settings")
if not account_settings.frozen_accounts_modifier and account_settings.bde_auth_role:
frappe.db.set_value("Account Settings", None,
frappe.db.set_value("Accounts Settings", None,
"frozen_accounts_modifier", account_settings.bde_auth_role)

View File

@@ -0,0 +1,51 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
from frappe.website.utils import find_first_image
from frappe.utils import cstr
import re
def execute():
item_details = frappe._dict()
for d in frappe.db.sql("select name, description, image from `tabItem`", as_dict=1):
description = cstr(d.description).strip()
item_details.setdefault(d.name, frappe._dict({
"description": description,
"image": d.image
}))
dt_list= ["Sales Invoice Item","Purchase Invoice Item"]
for dt in dt_list:
frappe.reload_doctype(dt)
records = frappe.db.sql("""select name, item_code, description from `tab{0}`
where ifnull(item_code, '') != '' and description is not null """.format(dt), as_dict=1)
count = 1
for d in records:
if item_details.get(d.item_code) and cstr(d.description) == item_details.get(d.item_code).description:
desc = item_details.get(d.item_code).description
image = item_details.get(d.item_code).image
else:
desc, image = extract_image_and_description(cstr(d.description))
if not image:
item_detail = item_details.get(d.item_code)
if item_detail:
image = item_detail.image
frappe.db.sql("""update `tab{0}` set description = %s, image = %s
where name = %s """.format(dt), (desc, image, d.name))
count += 1
if count % 500 == 0:
frappe.db.commit()
def extract_image_and_description(data):
image_url = find_first_image(data)
desc = data
for tag in ("img", "table", "tr", "td"):
desc = re.sub("\</*{0}[^>]*\>".format(tag), "", desc)
return desc, image_url

View File

View File

@@ -0,0 +1,37 @@
from __future__ import unicode_literals
import frappe
from erpnext.accounts.doctype.gl_entry.gl_entry import update_against_account
def execute():
from_date = "2015-05-01"
for doc in frappe.get_all("Journal Entry",
filters={"creation": (">", from_date), "docstatus": "1"}):
# update in gl_entry
update_against_account("Journal Entry", doc.name)
# update in jv
doc = frappe.get_doc("Journal Entry", doc.name)
doc.set_against_account()
doc.db_update()
for doc in frappe.get_all("Sales Invoice",
filters={"creation": (">", from_date), "docstatus": "1"},
fields=["name", "customer"]):
frappe.db.sql("""update `tabGL Entry` set against=%s
where voucher_type='Sales Invoice' and voucher_no=%s
and credit > 0 and ifnull(party, '')=''""",
(doc.customer, doc.name))
for doc in frappe.get_all("Purchase Invoice",
filters={"creation": (">", from_date), "docstatus": "1"},
fields=["name", "supplier"]):
frappe.db.sql("""update `tabGL Entry` set against=%s
where voucher_type='Purchase Invoice' and voucher_no=%s
and debit > 0 and ifnull(party, '')=''""",
(doc.supplier, doc.name))

View File

@@ -9,41 +9,6 @@
"doctype": "DocType",
"document_type": "Master",
"fields": [
{
"allow_on_submit": 0,
"fieldname": "employee",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Employee",
"no_copy": 0,
"options": "Employee",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0
},
{
"fieldname": "employee_name",
"fieldtype": "Data",
"label": "Employee Name",
"options": "",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"allow_on_submit": 0,
"fieldname": "activity_type",
@@ -64,6 +29,41 @@
"search_index": 0,
"set_only_once": 0
},
{
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"allow_on_submit": 0,
"fieldname": "employee",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Employee",
"no_copy": 0,
"options": "Employee",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0
},
{
"fieldname": "employee_name",
"fieldtype": "Data",
"label": "Employee Name",
"options": "",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "section_break_4",
"fieldtype": "Section Break",
@@ -136,7 +136,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"modified": "2015-06-11 06:50:47.999788",
"modified": "2015-06-16 03:12:25.644839",
"modified_by": "Administrator",
"module": "Projects",
"name": "Activity Cost",

View File

@@ -15,12 +15,21 @@ class ActivityCost(Document):
self.check_unique()
def set_title(self):
if not self.employee_name:
self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
self.title = _("{0} for {1}").format(self.employee_name, self.activity_type)
if self.employee:
if not self.employee_name:
self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
self.title = _("{0} for {1}").format(self.employee_name, self.activity_type)
else:
self.title = self.activity_type
def check_unique(self):
if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
(self.employee_name, self.activity_type, self.name)):
frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
.format(self.employee, self.activity_type), DuplicationError)
if self.employee:
if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
(self.employee_name, self.activity_type, self.name)):
frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
.format(self.employee, self.activity_type), DuplicationError)
else:
if frappe.db.sql("""select name from `tabActivity Cost` where ifnull(employee, '')='' and activity_type= %s and name != %s""",
(self.activity_type, self.name)):
frappe.throw(_("Default Activity Cost exists for Activity Type - {0}")
.format(self.activity_type), DuplicationError)

View File

@@ -163,6 +163,7 @@
"fieldtype": "Percent",
"in_list_view": 0,
"label": "% Tasks Completed",
"no_copy": 1,
"permlevel": 0,
"read_only": 1
},
@@ -356,7 +357,7 @@
"icon": "icon-puzzle-piece",
"idx": 1,
"max_attachments": 4,
"modified": "2015-04-27 07:37:44.239930",
"modified": "2015-06-12 09:00:54.080220",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",

View File

@@ -35,6 +35,7 @@ class Project(Document):
def validate(self):
self.validate_dates()
self.sync_tasks()
self.tasks = []
def validate_dates(self):
if self.expected_start_date and self.expected_end_date:
@@ -45,6 +46,8 @@ class Project(Document):
"""sync tasks and remove table"""
if self.flags.dont_sync_tasks: return
task_added_or_deleted = False
task_names = []
for t in self.tasks:
if t.task_id:
@@ -52,6 +55,7 @@ class Project(Document):
else:
task = frappe.new_doc("Task")
task.project = self.name
task_added_or_deleted = True
task.update({
"subject": t.title,
@@ -69,17 +73,22 @@ class Project(Document):
# delete
for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}):
frappe.delete_doc("Task", t.name)
task_added_or_deleted = True
if task_added_or_deleted:
self.update_project()
self.tasks = []
def update_project(self):
self.update_percent_complete()
self.update_costing()
def update_percent_complete(self):
total = frappe.db.sql("""select count(*) from tabTask where project=%s""",
self.name)[0][0]
total = frappe.db.sql("""select count(*) from tabTask where project=%s""", self.name)[0][0]
if total:
completed = frappe.db.sql("""select count(*) from tabTask where
project=%s and status in ('Closed', 'Cancelled')""", self.name)[0][0]
frappe.db.set_value("Project", self.name, "percent_complete",
int(float(completed) / total * 100))
self.percent_complete = flt(completed) / total * 100
def update_costing(self):
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount,

View File

@@ -5,3 +5,4 @@ from __future__ import unicode_literals
import frappe
test_records = frappe.get_test_records('Project')
test_ignore = ["Sales Order"]

View File

@@ -43,15 +43,8 @@ class Task(Document):
def on_update(self):
self.check_recursion()
self.reschedule_dependent_tasks()
self.update_percentage()
self.update_project()
def update_percentage(self):
"""update percent complete in project"""
if self.project and not self.flags.from_project:
project = frappe.get_doc("Project", self.project)
project.run_method("update_percent_complete")
def update_total_expense_claim(self):
self.total_expense_claim = frappe.db.sql("""select sum(total_sanctioned_amount) from `tabExpense Claim`
where project = %s and task = %s and approval_status = "Approved" and docstatus=1""",(self.project, self.name))
@@ -70,10 +63,10 @@ class Task(Document):
self.act_end_date= tl.end_date
def update_project(self):
if self.project and frappe.db.exists("Project", self.project):
if self.project and not self.flags.from_project:
project = frappe.get_doc("Project", self.project)
project.flags.dont_sync_tasks = True
project.update_costing()
project.update_project()
project.save()
def check_recursion(self):
@@ -141,7 +134,7 @@ def get_project(doctype, txt, searchfield, start, page_len, filters):
%(mcond)s
order by name
limit %(start)s, %(page_len)s """ % {'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype),
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype),
'start': start, 'page_len': page_len})

View File

@@ -128,7 +128,7 @@ class TimeLog(Document):
def update_production_order(self):
"""Updates `start_date`, `end_date`, `status` for operation in Production Order."""
if self.production_order and self.for_manufacturing:
if not self.operation_id:
frappe.throw(_("Operation ID not set"))
@@ -208,22 +208,23 @@ class TimeLog(Document):
self.production_order = None
self.operation = None
self.quantity = None
def update_cost(self):
rate = get_activity_cost(self.employee, self.activity_type)
if rate:
self.costing_rate = rate.get('costing_rate')
self.billing_rate = rate.get('billing_rate')
self.billing_rate = rate.get('billing_rate')
self.costing_amount = self.costing_rate * self.hours
if self.billable:
self.billing_amount = self.billing_rate * self.hours
else:
self.billing_amount = 0
def validate_task(self):
if self.project and not self.task:
# if a time log is being created against a project without production order
if (self.project and not self.production_order) and not self.task:
frappe.throw(_("Task is Mandatory if Time Log is against a project"))
def update_task(self):
if self.task and frappe.db.exists("Task", self.task):
task = frappe.get_doc("Task", self.task)
@@ -266,9 +267,12 @@ def get_events(start, end, filters=None):
d.title += " for Project: " + d.project
return data
@frappe.whitelist()
def get_activity_cost(employee=None, activity_type=None):
rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where employee= %s
and activity_type= %s""", (employee, activity_type), as_dict=1)
if not rate:
rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where ifnull(employee, '')=''
and activity_type= %s""", (activity_type), as_dict=1)
return rate[0] if rate else {}

View File

@@ -37,6 +37,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if(this.frm.fields_dict["items"]) {
this["items_remove"] = this.calculate_taxes_and_totals;
}
if(this.frm.fields_dict["recurring_print_format"]) {
this.frm.set_query("recurring_print_format", function(doc) {
return{
filters: [
['Print Format', 'doc_type', '=', cur_frm.doctype],
]
}
});
}
},
onload_post_render: function() {
@@ -782,3 +792,5 @@ frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) {
cur_frm.cscript.set_dynamic_labels();
cur_frm.cscript.calculate_taxes_and_totals();
})

View File

@@ -401,7 +401,8 @@ erpnext.pos.PointOfSale = Class.extend({
this.with_modes_of_payment(function() {
// prefer cash payment!
var default_mode = me.modes_of_payment.indexOf(__("Cash"))!==-1 ? __("Cash") : undefined;
var default_mode = me.frm.doc.mode_of_payment ? me.frm.doc.mode_of_payment :
me.modes_of_payment.indexOf(__("Cash"))!==-1 ? __("Cash") : undefined;
// show payment wizard
var dialog = new frappe.ui.Dialog({

View File

@@ -488,7 +488,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -858,7 +858,7 @@
"idx": 1,
"is_submittable": 1,
"max_attachments": 1,
"modified": "2015-05-27 02:48:00.388847",
"modified": "2015-06-15 15:37:39.199814",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation",

View File

@@ -2,7 +2,9 @@ frappe.listview_settings['Quotation'] = {
add_fields: ["customer_name", "base_grand_total", "status",
"company", "currency"],
get_indicator: function(doc) {
if(doc.status==="Ordered") {
if(doc.status==="Submitted") {
return [__("Submitted"), "blue", "status,=,Submitted"];
} else if(doc.status==="Ordered") {
return [__("Ordered"), "green", "status,=,Ordered"];
} else if(doc.status==="Lost") {
return [__("Lost"), "darkgrey", "status,=,Lost"];

View File

@@ -183,5 +183,3 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
cur_frm.email_doc(frappe.boot.notification_settings.sales_order_message);
}
};
;

View File

@@ -52,7 +52,7 @@
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 0,
"label": "Name",
"label": "Customer Name",
"permlevel": 0,
"read_only": 1
},
@@ -493,7 +493,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -1074,13 +1074,22 @@
"no_copy": 1,
"permlevel": 0,
"print_hide": 1
},
{
"depends_on": "eval:doc.is_recurring==1",
"fieldname": "recurring_print_format",
"fieldtype": "Link",
"label": "Recurring Print Format",
"options": "Print Format",
"permlevel": 0,
"precision": ""
}
],
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
"issingle": 0,
"modified": "2015-05-27 02:48:01.160307",
"modified": "2015-07-03 03:25:20.180721",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",

View File

@@ -58,7 +58,7 @@
"fieldname": "description",
"fieldtype": "Small Text",
"in_filter": 1,
"in_list_view": 1,
"in_list_view": 0,
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Small Text",
@@ -498,7 +498,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2015-05-27 02:47:15.134435",
"modified": "2015-07-02 05:37:29.289574",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",

View File

@@ -122,7 +122,7 @@ erpnext.SalesChart = Class.extend({
if(me.ctype == "Sales Person") {
fields.splice(-1, 0, {fieldtype:'Link', fieldname:'employee', label:__('Employee'),
options:'Employee', description: __("Please enter Employee Id of this sales parson")});
options:'Employee', description: __("Please enter Employee Id of this sales person")});
}
// the dialog

View File

@@ -71,7 +71,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} else {
filters = {
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date,
'posting_date': me.frm.doc.posting_date || nowdate(),
}
if(item.warehouse) filters["warehouse"] = item.warehouse

View File

@@ -66,20 +66,6 @@
"label": "Disable Rounded Total",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "section_break_8",
"fieldtype": "Section Break",
"permlevel": 0,
"precision": ""
},
{
"description": "For automatic exchange rates go to jsonrates.com and signup for an API key",
"fieldname": "jsonrates_api_key",
"fieldtype": "Data",
"label": "jsonrates.com API Key",
"permlevel": 0,
"precision": ""
}
],
"hide_toolbar": 0,
@@ -87,7 +73,7 @@
"idx": 1,
"in_create": 1,
"issingle": 1,
"modified": "2015-05-07 05:43:49.760061",
"modified": "2015-06-30 03:00:26.420003",
"modified_by": "Administrator",
"module": "Setup",
"name": "Global Defaults",

View File

@@ -17,7 +17,6 @@ keydict = {
'hide_currency_symbol':'hide_currency_symbol',
'account_url':'account_url',
'disable_rounded_total': 'disable_rounded_total',
'jsonrates_api_key': 'jsonrates_api_key'
}
from frappe.model.document import Document

View File

@@ -26,7 +26,8 @@ class NamingSeries(Document):
except frappe.DoesNotExistError:
continue
prefixes = prefixes + "\n" + options
if options:
prefixes = prefixes + "\n" + options
prefixes.replace("\n\n", "\n")
prefixes = "\n".join(sorted(prefixes.split()))

View File

@@ -60,20 +60,21 @@ def before_tests():
@frappe.whitelist()
def get_exchange_rate(from_currency, to_currency):
jsonrates_api_key = frappe.conf.jsonrates_api_key or frappe.db.get_default("jsonrates_api_key")
if jsonrates_api_key:
try:
cache = frappe.cache()
key = "currency_exchange_rate:{0}:{1}".format(from_currency, to_currency)
value = cache.get(key)
if not value:
import requests
response = requests.get("http://jsonrates.com/get/?from={0}&to={1}&apiKey={2}".format(from_currency,
to_currency, jsonrates_api_key))
response = requests.get("http://api.fixer.io/latest", params={
"base": from_currency,
"symbols": to_currency
})
# expire in 24 hours
value = response.json().get("rate")
response.raise_for_status()
value = response.json()["rates"][to_currency]
cache.setex(key, value, 24 * 60 * 60)
return flt(value)
else:
except:
exchange = "%s-%s" % (from_currency, to_currency)
return flt(frappe.db.get_value("Currency Exchange", exchange, "exchange_rate"))

View File

@@ -14,7 +14,7 @@ def get_notification_config():
"Contact": {"status": "Open"},
"Opportunity": {"status": "Open"},
"Quotation": {"docstatus": 0},
"Sales Order": { "per_delivered": ("<", 100), "status": ("!=", "Stopped"), "docstatus": ("<", 2) },
"Sales Order": { "per_billed": ("<", 100), "status": ("!=", "Stopped"), "docstatus": ("<", 2) },
"Journal Entry": {"docstatus": 0},
"Sales Invoice": { "outstanding_amount": (">", 0), "docstatus": ("<", 2) },
"Purchase Invoice": {"docstatus": 0},
@@ -25,7 +25,7 @@ def get_notification_config():
"Delivery Note": {"docstatus": 0},
"Stock Entry": {"docstatus": 0},
"Material Request": {"docstatus": 0},
"Purchase Order": { "per_received": ("<", 100), "status": ("!=", "Stopped"), "docstatus": ("<", 2) },
"Purchase Order": { "per_billed": ("<", 100), "status": ("!=", "Stopped"), "docstatus": ("<", 2) },
"Production Order": { "status": "In Process" },
"BOM": {"docstatus": 0},
"Timesheet": {"docstatus": 0},

View File

@@ -517,7 +517,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -1070,7 +1070,7 @@
"idx": 1,
"in_create": 0,
"is_submittable": 1,
"modified": "2015-05-27 02:47:59.778147",
"modified": "2015-06-15 15:37:54.699371",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",

View File

@@ -108,11 +108,9 @@ class DeliveryNote(SellingController):
if not self.installation_status: self.installation_status = 'Not Installed'
def validate_with_previous_doc(self):
items = self.get("items")
for fn in (("Sales Order", "against_sales_order", "so_detail"),
("Sales Invoice", "against_sales_invoice", "si_detail")):
if filter(None, [getattr(d, fn[1], None) for d in items]):
if filter(None, [getattr(d, fn[1], None) for d in self.get("items")]):
super(DeliveryNote, self).validate_with_previous_doc({
fn[0]: {
"ref_dn_field": fn[1],
@@ -120,15 +118,10 @@ class DeliveryNote(SellingController):
["currency", "="]],
},
})
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(DeliveryNote, self).validate_with_previous_doc({
fn[0] + " Item": {
"ref_dn_field": fn[2],
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
["Sales Invoice", "sales_invoice", "si_detail"]])
def validate_proj_cust(self):
"""check for does customer belong to same project as entered.."""

View File

@@ -5,39 +5,6 @@ frappe.provide("erpnext.item");
frappe.ui.form.on("Item", {
onload: function(frm) {
var df = frappe.meta.get_docfield("Item Variant", "item_attribute_value");
df.on_make = function(field) {
field.$input.autocomplete({
minLength: 0,
minChars: 0,
source: function(request, response) {
frappe.call({
method:"frappe.client.get_list",
args:{
doctype:"Item Attribute Value",
filters: [
["parent","=", field.doc.item_attribute],
["attribute_value", "like", request.term + "%"]
],
fields: ["attribute_value"]
},
callback: function(r) {
response($.map(r.message, function(d) { return d.attribute_value; }));
}
});
},
select: function(event, ui) {
field.$input.val(ui.item.value);
field.$input.trigger("change");
},
focus: function( event, ui ) {
if(ui.item.action) {
return false;
}
},
});
}
erpnext.item.setup_queries(frm);
},
@@ -55,6 +22,9 @@ frappe.ui.form.on("Item", {
// read only if any stock ledger entry exists
erpnext.item.make_dashboard(frm);
// clear intro
frm.set_intro();
if (frm.doc.has_variants) {
frm.set_intro(__("This Item is a Template and cannot be used in transactions. Item attributes will be copied over into the variants unless 'No Copy' is set"), true);
frm.add_custom_button(__("Show Variants"), function() {
@@ -85,7 +55,7 @@ frappe.ui.form.on("Item", {
erpnext.item.weight_to_validate(frm);
erpnext.item.variants_can_not_be_created_manually(frm);
},
image: function(frm) {
refresh_field("image_view");
},
@@ -110,8 +80,14 @@ frappe.ui.form.on("Item", {
method: "copy_specification_from_item_group"
});
},
is_stock_item: function(frm) {
erpnext.item.toggle_reqd(frm);
},
manage_variants: function(frm) {
frappe.route_options = {"item_code": frm.doc.name };
frappe.set_route("List", "Manage Variants");
}
});
@@ -209,11 +185,11 @@ $.extend(erpnext.item, {
validated = 0;
}
},
variants_can_not_be_created_manually: function(frm) {
if (frm.doc.__islocal && frm.doc.variant_of)
frappe.throw(__("Variants can not be created manually, add item attributes in the template item"))
}
});

View File

@@ -12,7 +12,7 @@
{
"fieldname": "name_and_description_section",
"fieldtype": "Section Break",
"label": "Name and Description",
"label": "",
"no_copy": 0,
"oldfieldtype": "Section Break",
"options": "icon-flag",
@@ -167,16 +167,17 @@
"search_index": 0
},
{
"depends_on": "eval:!!!doc.variant_of",
"depends_on": "eval:!doc.variant_of",
"fieldname": "variants_section",
"fieldtype": "Section Break",
"label": "Variants",
"label": "Variant",
"permlevel": 0,
"precision": ""
},
{
"default": "0",
"description": "Automatically set. If this item has variants, then it cannot be selected in sales orders etc.",
"depends_on": "",
"description": "If this item has variants, then it cannot be selected in sales orders etc.",
"fieldname": "has_variants",
"fieldtype": "Check",
"label": "Has Variants",
@@ -186,15 +187,37 @@
"read_only": 0
},
{
"depends_on": "has_variants",
"description": "A new variant (Item) will be created for each attribute value combination",
"fieldname": "variants",
"fieldtype": "Table",
"label": "Variants",
"options": "Item Variant",
"fieldname": "column_break_18",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "has_variants",
"fieldname": "manage_variants",
"fieldtype": "Button",
"label": "Manage Variants",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "section_break_20",
"fieldtype": "Section Break",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "variant_of",
"fieldname": "attributes",
"fieldtype": "Table",
"hidden": 0,
"label": "Attributes",
"no_copy": 1,
"options": "Variant Attribute",
"permlevel": 0,
"precision": "",
"read_only": 0
},
{
"fieldname": "inventory",
"fieldtype": "Section Break",
@@ -707,7 +730,7 @@
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default BOM",
"no_copy": 0,
"no_copy": 1,
"oldfieldname": "default_bom",
"oldfieldtype": "Link",
"options": "BOM",
@@ -877,9 +900,9 @@
}
],
"icon": "icon-tag",
"idx": 1,
"idx": 1,
"max_attachments": 1,
"modified": "2015-05-22 02:16:57.435105",
"modified": "2015-07-01 17:20:18.204558",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@@ -9,10 +9,9 @@ from frappe.website.website_generator import WebsiteGenerator
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for, get_parent_item_groups
from frappe.website.render import clear_cache
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
import copy
from erpnext.stock.doctype.manage_variants.manage_variants import update_variant
class WarehouseNotSet(frappe.ValidationError): pass
class DuplicateVariant(frappe.ValidationError): pass
class ItemTemplateCannotHaveStock(frappe.ValidationError): pass
class Item(WebsiteGenerator):
@@ -48,9 +47,6 @@ class Item(WebsiteGenerator):
if self.image and not self.website_image:
self.website_image = self.image
if self.variant_of:
self.copy_attributes_to_variant(frappe.get_doc("Item", self.variant_of), self)
self.check_warehouse_is_set_for_stock_item()
self.check_stock_uom_with_bin()
self.add_default_uom_in_conversion_factor_table()
@@ -63,9 +59,10 @@ class Item(WebsiteGenerator):
self.cant_change()
self.validate_reorder_level()
self.validate_warehouse_for_reorder()
self.validate_variants()
self.update_item_desc()
self.synced_with_hub = 0
self.validate_has_variants()
self.validate_stock_for_template_must_be_zero()
if not self.get("__islocal"):
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
@@ -77,7 +74,7 @@ class Item(WebsiteGenerator):
invalidate_cache_for_item(self)
self.validate_name_with_item_group()
self.update_item_price()
self.sync_variants()
self.update_variants()
def get_context(self, context):
context["parent_groups"] = get_parent_item_groups(self.item_group) + \
@@ -133,142 +130,6 @@ class Item(WebsiteGenerator):
if not matched:
frappe.throw(_("Default Unit of Measure can not be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
def validate_variants(self):
self.validate_variants_are_unique()
self.validate_stock_for_template_must_be_zero()
def validate_stock_for_template_must_be_zero(self):
if self.has_variants:
stock_in = frappe.db.sql_list("""select warehouse from tabBin
where item_code=%s and ifnull(actual_qty, 0) > 0""", self.name)
if stock_in:
frappe.throw(_("Item Template cannot have stock and varaiants. Please remove stock from warehouses {0}").format(", ".join(stock_in)),
ItemTemplateCannotHaveStock)
def validate_variants_are_unique(self):
if not self.has_variants:
self.variants = []
return
if self.variants:
if self.variant_of:
frappe.throw(_("Item cannot be a variant of a variant"))
variants, attributes = [], {}
for d in self.variants:
key = (d.item_attribute, d.item_attribute_value)
if key in variants:
frappe.throw(_("{0} {1} is entered more than once in Item Variants table")
.format(d.item_attribute, d.item_attribute_value), DuplicateVariant)
variants.append(key)
attributes.setdefault(d.item_attribute, [t.attribute_value for t in frappe.db.get_all("Item Attribute Value",
fields=["attribute_value"], filters={"parent": d.item_attribute })])
if d.item_attribute_value not in attributes.get(d.item_attribute):
frappe.throw(_("Attribute value {0} does not exist in Item Attribute Master.").format(d.item_attribute_value))
else:
frappe.throw(_("Please enter atleast one attribute row in Item Variants table"))
def sync_variants(self):
variant_item_codes = self.get_variant_item_codes()
# delete missing variants
existing_variants = [d.name for d in frappe.get_all("Item",
filters={"variant_of":self.name})]
updated, deleted = [], []
for existing_variant in existing_variants:
if existing_variant not in variant_item_codes:
frappe.delete_doc("Item", existing_variant)
deleted.append(existing_variant)
else:
self.update_variant(existing_variant)
updated.append(existing_variant)
inserted = []
for item_code in variant_item_codes:
if item_code not in existing_variants:
self.make_variant(item_code)
inserted.append(item_code)
if inserted:
frappe.msgprint(_("Item Variants {0} created").format(", ".join(inserted)))
if updated:
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
if deleted:
frappe.msgprint(_("Item Variants {0} deleted").format(", ".join(deleted)))
def get_variant_item_codes(self):
"""Get all possible suffixes for variants"""
if not self.variants:
return []
self.variant_attributes = {}
variant_dict = {}
variant_item_codes = []
for d in self.variants:
variant_dict.setdefault(d.item_attribute, []).append(d.item_attribute_value)
all_attributes = [d.name for d in frappe.get_all("Item Attribute", order_by = "priority asc")]
# sort attributes by their priority
attributes = filter(None, map(lambda d: d if d in variant_dict else None, all_attributes))
def add_attribute_suffixes(item_code, my_attributes, attributes):
attr = frappe.get_doc("Item Attribute", attributes[0])
for value in attr.item_attribute_values:
if value.attribute_value in variant_dict[attr.name]:
_my_attributes = copy.deepcopy(my_attributes)
_my_attributes.append([attr.name, value.attribute_value])
if len(attributes) > 1:
add_attribute_suffixes(item_code + "-" + value.abbr, _my_attributes, attributes[1:])
else:
variant_item_codes.append(item_code + "-" + value.abbr)
self.variant_attributes[item_code + "-" + value.abbr] = _my_attributes
add_attribute_suffixes(self.name, [], attributes)
return variant_item_codes
def make_variant(self, item_code):
item = frappe.new_doc("Item")
item.item_code = item_code
self.copy_attributes_to_variant(self, item, insert=True)
item.insert()
def update_variant(self, item_code):
item = frappe.get_doc("Item", item_code)
item.item_code = item_code
self.copy_attributes_to_variant(self, item)
item.save()
def copy_attributes_to_variant(self, template, variant, insert=False):
from frappe.model import no_value_fields
for field in self.meta.fields:
if field.fieldtype not in no_value_fields and (insert or not field.no_copy)\
and field.fieldname not in ("item_code", "item_name"):
if variant.get(field.fieldname) != template.get(field.fieldname):
variant.set(field.fieldname, template.get(field.fieldname))
variant.__dirty = True
variant.description += "\n"
if not getattr(template, "variant_attributes", None):
template.get_variant_item_codes()
for attr in template.variant_attributes[variant.item_code]:
variant.description += "<p>" + attr[0] + ": " + attr[1] + "</p>"
variant.item_name = self.item_name + variant.item_code[len(self.name):]
variant.variant_of = template.name
variant.has_variants = 0
variant.show_in_website = 0
def update_template_tables(self):
template = frappe.get_doc("Item", self.variant_of)
@@ -313,15 +174,6 @@ class Item(WebsiteGenerator):
if bom_item not in (self.name, self.variant_of):
frappe.throw(_("Default BOM ({0}) must be active for this item or its template").format(bom_item))
if self.is_purchase_item != "Yes":
bom_mat = frappe.db.sql("""select distinct t1.parent
from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
and t2.docstatus = 1 and t1.docstatus =1 """, self.name)
if bom_mat and bom_mat[0][0]:
frappe.throw(_("Item must be a purchase item, as it is present in one or many Active BOMs"))
def fill_customer_code(self):
""" Append all the customer codes and insert into "customer_code" field of item table """
cust_code=[]
@@ -361,7 +213,8 @@ class Item(WebsiteGenerator):
vals.has_batch_no != self.has_batch_no or
cstr(vals.valuation_method) != cstr(self.valuation_method)):
if self.check_if_sle_exists() == "exists":
frappe.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Has Batch No', 'Is Stock Item' and 'Valuation Method'"))
frappe.throw(_("As there are existing stock transactions for this item, \
you can not change the values of 'Has Serial No', 'Has Batch No', 'Is Stock Item' and 'Valuation Method'"))
def validate_reorder_level(self):
if cint(self.apply_warehouse_wise_reorder_level):
@@ -460,9 +313,33 @@ class Item(WebsiteGenerator):
def update_item_desc(self):
if frappe.db.get_value('BOM',self.name, 'description') != self.description:
frappe.db.sql("""update `tabBOM` set description = %s where item = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Item` set description = %s where item_code = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Explosion Item` set description = %s where item_code = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Item` set description = %s where
item_code = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Explosion Item` set description = %s where
item_code = %s and docstatus < 2""",(self.description, self.name))
def update_variants(self):
if self.has_variants:
updated = []
variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
for d in variants:
update_variant(self.name, d)
updated.append(d.item_code)
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
def validate_has_variants(self):
if not self.has_variants and frappe.db.get_value("Item", self.name, "has_variants"):
if frappe.db.exists("Item", {"variant_of": self.name}):
frappe.throw(_("Item has variants."))
def validate_stock_for_template_must_be_zero(self):
if self.has_variants:
stock_in = frappe.db.sql_list("""select warehouse from tabBin
where item_code=%s and (ifnull(actual_qty, 0) > 0 or ifnull(ordered_qty, 0) > 0
or ifnull(reserved_qty, 0) > 0 or ifnull(indented_qty, 0) > 0 or ifnull(planned_qty, 0) > 0)""", self.name)
if stock_in:
frappe.throw(_("Item Template cannot have stock or Open Sales/Purchase/Production Orders."), ItemTemplateCannotHaveStock)
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life:
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")
@@ -567,3 +444,4 @@ def invalidate_cache_for_item(doc):
if doc.get("old_item_group") and doc.get("old_item_group") != doc.item_group:
invalidate_cache_for(doc, doc.old_item_group)

View File

@@ -6,7 +6,7 @@ import unittest
import frappe
from frappe.test_runner import make_test_records
from erpnext.stock.doctype.item.item import WarehouseNotSet, DuplicateVariant, ItemTemplateCannotHaveStock
from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
test_ignore = ["BOM"]
@@ -20,60 +20,14 @@ class TestItem(unittest.TestCase):
item.insert()
else:
item = frappe.get_doc("Item", item_code)
return item
def test_duplicate_variant(self):
item = frappe.copy_doc(test_records[11])
item.append("variants", {"item_attribute": "Test Size", "item_attribute_value": "Small"})
self.assertRaises(DuplicateVariant, item.insert)
def test_template_cannot_have_stock(self):
item = self.get_item(10)
se = make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
item.has_variants = 1
item.append("variants", {"item_attribute": "Test Size", "item_attribute_value": "Small"})
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_variant_item_codes(self):
item = self.get_item(11)
variants = ['_Test Variant Item-S', '_Test Variant Item-M', '_Test Variant Item-L']
self.assertEqual(item.get_variant_item_codes(), variants)
for v in variants:
self.assertTrue(frappe.db.get_value("Item", {"variant_of": item.name, "name": v}))
item.append("variants", {"item_attribute": "Test Colour", "item_attribute_value": "Red"})
item.append("variants", {"item_attribute": "Test Colour", "item_attribute_value": "Blue"})
item.append("variants", {"item_attribute": "Test Colour", "item_attribute_value": "Green"})
self.assertEqual(item.get_variant_item_codes(), ['_Test Variant Item-S-R',
'_Test Variant Item-S-G', '_Test Variant Item-S-B',
'_Test Variant Item-M-R', '_Test Variant Item-M-G',
'_Test Variant Item-M-B', '_Test Variant Item-L-R',
'_Test Variant Item-L-G', '_Test Variant Item-L-B'])
self.assertEqual(item.variant_attributes['_Test Variant Item-L-R'], [['Test Size', 'Large'], ['Test Colour', 'Red']])
self.assertEqual(item.variant_attributes['_Test Variant Item-S-G'], [['Test Size', 'Small'], ['Test Colour', 'Green']])
# check stock entry cannot be made
def test_stock_entry_cannot_be_made_for_template(self):
item = self.get_item(11)
se = frappe.new_doc("Stock Entry")
se.purpose = "Material Receipt"
se.append("items", {
"item_code": item.name,
"t_warehouse": "Stores - _TC",
"qty": 1,
"incoming_rate": 1
})
se.insert()
self.assertRaises(ItemTemplateCannotHaveStock, se.submit)
item = self.get_item(10)
se = make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
item.has_variants = 1
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_default_warehouse(self):
item = frappe.copy_doc(test_records[0])
item.is_stock_item = "Yes"

View File

@@ -273,11 +273,6 @@
"item_name": "_Test Variant Item",
"stock_uom": "_Test UOM",
"has_variants": 1,
"variants": [
{"item_attribute": "Test Size", "item_attribute_value": "Small"},
{"item_attribute": "Test Size", "item_attribute_value": "Medium"},
{"item_attribute": "Test Size", "item_attribute_value": "Large"}
],
"apply_warehouse_wise_reorder_level": 1,
"reorder_levels": [
{

View File

@@ -8,8 +8,14 @@ from frappe import _
class ItemAttribute(Document):
def validate(self):
self.validate_duplication()
self.validate_attribute_values()
def validate_duplication(self):
values, abbrs = [], []
for d in self.item_attribute_values:
d.abbr = d.abbr.upper()
if d.attribute_value in values:
frappe.throw(_("{0} must appear only once").format(d.attribute_value))
values.append(d.attribute_value)
@@ -17,3 +23,14 @@ class ItemAttribute(Document):
if d.abbr in abbrs:
frappe.throw(_("{0} must appear only once").format(d.abbr))
abbrs.append(d.abbr)
def validate_attribute_values(self):
attribute_values = []
for d in self.item_attribute_values:
attribute_values.append(d.attribute_value)
variant_attributes = frappe.db.sql("select DISTINCT attribute_value from `tabVariant Attribute` where attribute=%s", self.name)
if variant_attributes:
for d in variant_attributes:
if d[0] not in attribute_values:
frappe.throw(_("Attribute Value {0} cannot be removed from {1} as Item Variants exist with this Attribute.").format(d[0], self.name))

View File

@@ -0,0 +1,56 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Manage Variants", {
onload: function(frm) {
var df = frappe.meta.get_docfield("Variant Attribute", "attribute_value", "Manage Variants");
df.on_make = function(field) {
$(field.input_area).addClass("ui-front");
field.$input.autocomplete({
minLength: 0,
minChars: 0,
source: function(request, response) {
frappe.call({
method:"frappe.client.get_list",
args:{
doctype:"Item Attribute Value",
filters: [
["parent","=", field.doc.attribute],
["attribute_value", "like", request.term + "%"]
],
fields: ["attribute_value"]
},
callback: function(r) {
response($.map(r.message, function(d) { return d.attribute_value; }));
}
});
},
select: function(event, ui) {
field.$input.val(ui.item.value);
field.$input.trigger("change");
}
});
}
},
refresh: function(frm) {
frm.disable_save();
frm.page.set_primary_action(__("Create Variants"), function() {
frappe.call({
method: "create_variants",
doc:frm.doc
})
});
},
item_code:function(frm) {
return frappe.call({
method: "get_item_details",
doc:frm.doc,
callback: function(r) {
refresh_field('attributes');
refresh_field('variants');
}
})
}
});

View File

@@ -0,0 +1,103 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"creation": "2015-05-19 05:39:59.345901",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"fields": [
{
"fieldname": "item_code",
"fieldtype": "Link",
"label": "Item Code",
"options": "Item",
"permlevel": 0,
"precision": "",
"reqd": 1
},
{
"fieldname": "section_break_2",
"fieldtype": "Section Break",
"label": "Item Variant Attributes",
"permlevel": 0,
"precision": ""
},
{
"allow_on_submit": 0,
"fieldname": "attributes",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Attributes",
"no_copy": 0,
"options": "Variant Attribute",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0
},
{
"fieldname": "generate_combinations",
"fieldtype": "Button",
"label": "Generate Combinations",
"options": "generate_combinations",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "section_break_4",
"fieldtype": "Section Break",
"label": "Item Variants",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "variants",
"fieldtype": "Table",
"label": "Variants",
"options": "Manage Variants Item",
"permlevel": 0,
"precision": ""
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"in_create": 1,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"modified": "2015-06-30 13:40:59.946655",
"modified_by": "Administrator",
"module": "Stock",
"name": "Manage Variants",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 0,
"role": "Material Master Manager",
"share": 1,
"write": 1
}
],
"read_only": 1,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC"
}

View File

@@ -0,0 +1,207 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
import copy
import json
class DuplicateAttribute(frappe.ValidationError): pass
class ManageVariants(Document):
def get_item_details(self):
self.clear_tables()
if self.item_code:
self.get_attributes()
self.get_variants()
def generate_combinations(self):
self.validate_attributes()
self.validate_template_item()
self.validate_attribute_values()
self.validate_attributes_are_unique()
self.get_variant_item_codes()
def create_variants(self):
self.sync_variants()
def clear_tables(self):
self.set('attributes', [])
self.set('variants', [])
def get_attributes(self):
attributes = {}
self.set('attributes', [])
for d in frappe.db.sql("""select attr.attribute, attr.attribute_value from `tabVariant Attribute` as attr,
`tabItem` as item where attr.parent = item.name and item.variant_of = %s""", self.item_code, as_dict=1):
attributes.setdefault(d.attribute, []).append(d.attribute_value)
for d in attributes:
attribute_values = set(attributes[d])
for value in attribute_values:
self.append('attributes',{"attribute": d, "attribute_value": value})
def get_variants(self):
variants = [d.name for d in frappe.get_all("Item",
filters={"variant_of":self.item_code})]
data = frappe.db.sql("""select parent, attribute, attribute_value from `tabVariant Attribute`""", as_dict=1)
for d in variants:
variant_attributes, attributes = "", []
for attribute in data:
if attribute.parent == d:
variant_attributes += attribute.attribute_value + " | "
attributes.append([attribute.attribute, attribute.attribute_value])
self.append('variants',{"variant": d, "variant_attributes": variant_attributes[: -3], "attributes": json.dumps(attributes)})
def validate_attributes(self):
if not self.attributes:
frappe.throw(_("Enter atleast one Attribute & its Value in Attribute table."))
def validate_template_item(self):
if not frappe.db.get_value("Item", self.item_code, "has_variants"):
frappe.throw(_("Selected Item cannot have Variants."))
if frappe.db.get_value("Item", self.item_code, "variant_of"):
frappe.throw(_("Item cannot be a variant of a variant"))
def validate_attribute_values(self):
attributes = {}
for t in frappe.db.get_all("Item Attribute Value", fields=["parent", "attribute_value"]):
attributes.setdefault(t.parent, []).append(t.attribute_value)
for d in self.attributes:
if d.attribute_value not in attributes.get(d.attribute):
frappe.throw(_("Attribute value {0} does not exist in Item Attribute Master.").format(d.attribute_value))
def validate_attributes_are_unique(self):
attributes = []
for d in self.attributes:
key = (d.attribute, d.attribute_value)
if key in attributes:
frappe.throw(_("{0} {1} is entered more than once in Attributes table")
.format(d.attribute, d.attribute_value), DuplicateAttribute)
attributes.append(key)
def get_variant_item_codes(self):
"""Get all possible suffixes for variants"""
variant_dict = {}
self.set('variants', [])
for d in self.attributes:
variant_dict.setdefault(d.attribute, []).append(d.attribute_value)
all_attributes = [d.name for d in frappe.get_all("Item Attribute", order_by = "priority asc")]
# sort attributes by their priority
attributes = filter(None, map(lambda d: d if d in variant_dict else None, all_attributes))
def add_attribute_suffixes(item_code, my_attributes, attributes):
attr = frappe.get_doc("Item Attribute", attributes[0])
for value in attr.item_attribute_values:
if value.attribute_value in variant_dict[attr.name]:
_my_attributes = copy.deepcopy(my_attributes)
_my_attributes.append([attr.name, value.attribute_value])
if len(attributes) > 1:
add_attribute_suffixes(item_code + "-" + value.abbr, _my_attributes, attributes[1:])
else:
variant_attributes = ""
for d in _my_attributes:
variant_attributes += d[1] + " | "
self.append('variants', {"variant": item_code + "-" + value.abbr,
"attributes": json.dumps(_my_attributes), "variant_attributes": variant_attributes[: -3]})
add_attribute_suffixes(self.item_code, [], attributes)
def sync_variants(self):
variant_item_codes = []
item_variants_attributes = {}
inserted, updated, old_variant_name, new_variant_name, deleted = [], [], [], [], []
for v in self.variants:
variant_item_codes.append(v.variant)
existing_variants = [d.name for d in frappe.get_all("Item",
filters={"variant_of":self.item_code})]
for d in existing_variants:
attributes = []
for attribute in frappe.db.sql("""select attribute, attribute_value from `tabVariant Attribute` where parent = %s""", d):
attributes.append([attribute[0], attribute[1]])
item_variants_attributes.setdefault(d, []).append(attributes)
for existing_variant in existing_variants:
if existing_variant not in variant_item_codes:
att = item_variants_attributes[existing_variant][0]
for variant in self.variants:
if sorted(json.loads(variant.attributes) ,key=lambda x: x[0]) == \
sorted(att ,key=lambda x: x[0]):
rename_variant(existing_variant, variant.variant)
old_variant_name.append(existing_variant)
new_variant_name.append(variant.variant)
if existing_variant not in old_variant_name:
delete_variant(existing_variant)
deleted.append(existing_variant)
for item_code in variant_item_codes:
if item_code not in existing_variants:
if item_code not in new_variant_name:
make_variant(self.item_code, item_code, self.variants)
inserted.append(item_code)
else:
update_variant(self.item_code, item_code, self.variants)
updated.append(item_code)
if inserted:
frappe.msgprint(_("Item Variants {0} created").format(", ".join(inserted)))
if updated:
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
if old_variant_name:
frappe.msgprint(_("Item Variants {0} renamed").format(", ".join(old_variant_name)))
if deleted:
frappe.msgprint(_("Item Variants {0} deleted").format(", ".join(deleted)))
def make_variant(item, variant_code, variant_attribute):
variant = frappe.new_doc("Item")
variant.item_code = variant_code
copy_attributes_to_variant(item, variant, variant_attribute, insert=True)
variant.insert()
def update_variant(item, variant_code, variant_attribute=None):
variant = frappe.get_doc("Item", variant_code)
copy_attributes_to_variant(item, variant, variant_attribute, insert=True)
variant.save()
def rename_variant(old_variant_code, new_variant_code):
frappe.rename_doc("Item", old_variant_code, new_variant_code)
def delete_variant(variant_code):
frappe.delete_doc("Item", variant_code)
def copy_attributes_to_variant(item, variant, variant_attribute=None, insert=False):
template = frappe.get_doc("Item", item)
from frappe.model import no_value_fields
for field in template.meta.fields:
if field.fieldtype not in no_value_fields and (insert or not field.no_copy)\
and field.fieldname not in ("item_code", "item_name"):
if variant.get(field.fieldname) != template.get(field.fieldname):
variant.set(field.fieldname, template.get(field.fieldname))
variant.item_name = template.item_name + variant.item_code[len(template.name):]
variant.variant_of = template.name
variant.has_variants = 0
variant.show_in_website = 0
if variant_attribute:
for d in variant_attribute:
if d.variant == variant.item_code:
variant.attributes= []
for a in json.loads(d.attributes):
variant.append('attributes', {"attribute": a[0], "attribute_value": a[1]})
if variant.attributes:
variant.description += "\n"
for d in variant.attributes:
variant.description += "<p>" + d.attribute + ": " + d.attribute_value + "</p>"

View File

@@ -0,0 +1,49 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest
import frappe
from erpnext.stock.doctype.manage_variants.manage_variants import DuplicateAttribute
class TestManageVariants(unittest.TestCase):
def test_variant_item_codes(self):
manage_variant = frappe.new_doc("Manage Variants")
manage_variant.update({
"item": "_Test Variant Item",
"attributes": [
{
"attribute": "Test Size",
"attribute_value": "Small"
},
{
"attribute": "Test Size",
"attribute_value": "Large"
}
]
})
manage_variant.generate_combinations()
self.assertEqual(manage_variant.variants[0].variant, "_Test Variant Item-S")
self.assertEqual(manage_variant.variants[1].variant, "_Test Variant Item-L")
self.assertEqual(manage_variant.variants[0].variant_attributes, "Small")
self.assertEqual(manage_variant.variants[1].variant_attributes, "Large")
manage_variant.create_variants()
def test_attributes_are_unique(self):
manage_variant = frappe.new_doc("Manage Variants")
manage_variant.update({
"item": "_Test Variant Item",
"attributes": [
{
"attribute": "Test Size",
"attribute_value": "Small"
},
{
"attribute": "Test Size",
"attribute_value": "Small"
}
]
})
self.assertRaises(DuplicateAttribute, manage_variant.generate_combinations)

View File

@@ -0,0 +1,76 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "",
"creation": "2015-05-19 05:55:31.155672",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Other",
"fields": [
{
"allow_on_submit": 0,
"fieldname": "variant",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Variant",
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0
},
{
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "variant_attributes",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Variant Attributes",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "attributes",
"fieldtype": "Text",
"hidden": 1,
"label": "attributes",
"permlevel": 0,
"precision": "",
"read_only": 1
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "",
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-06-30 03:19:07.548196",
"modified_by": "Administrator",
"module": "Stock",
"name": "Manage Variants Item",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC"
}

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class ManageVariantsItem(Document):
pass

View File

@@ -443,7 +443,7 @@
{
"fieldname": "base_discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount (Company Currency)",
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@@ -854,7 +854,7 @@
"icon": "icon-truck",
"idx": 1,
"is_submittable": 1,
"modified": "2015-05-27 02:48:00.763945",
"modified": "2015-06-15 15:38:43.754869",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",

View File

@@ -104,15 +104,8 @@ class PurchaseReceipt(BuyingController):
}
})
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
super(PurchaseReceipt, self).validate_with_previous_doc({
"Purchase Order Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
self.validate_rate_with_reference_doc([["Purchase Order", "prevdoc_docname", "prevdoc_detail_docname"]])
def po_required(self):
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':

View File

@@ -180,7 +180,7 @@ class SerialNo(StockController):
where fieldname='serial_no' and fieldtype='Text'"""):
for item in frappe.db.sql("""select name, serial_no from `tab%s`
where serial_no like '%%%s%%'""" % (dt[0], old)):
where serial_no like '%%%s%%'""" % (dt[0], frappe.db.escape(old))):
serial_nos = map(lambda i: i==old and new or i, item[1].split('\n'))
frappe.db.sql("""update `tab%s` set serial_no = %s

View File

@@ -411,14 +411,21 @@ cur_frm.fields_dict['items'].grid.get_field('batch_no').get_query = function(doc
var item = locals[cdt][cdn];
if(!item.item_code) {
frappe.throw(__("Please enter Item Code to get batch no"));
} else {
var filters = {
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date,
}
else {
if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"], doc.purpose)) {
var filters = {
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date || nowdate()
}
} else {
var filters = {
'item_code': item.item_code
}
}
if(item.s_warehouse) filters["warehouse"] = item.s_warehouse
return {
query : "erpnext.controllers.queries.get_batch_no",
filters: filters
@@ -498,9 +505,9 @@ cur_frm.cscript.uom = function(doc, cdt, cdn) {
}
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_items(doc);
if($.inArray(cur_frm.doc.purpose, ["Purchase Return", "Sales Return"])!==-1)
validated = cur_frm.cscript.get_doctype_docname() ? true : false;
cur_frm.cscript.validate_items(doc);
}
cur_frm.cscript.validate_items = function(doc) {

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
import frappe.defaults
from frappe.utils import cstr, cint, flt, comma_or, get_datetime
from frappe.utils import cstr, cint, flt, comma_or, get_datetime, getdate
from frappe import _
from erpnext.stock.utils import get_incoming_rate
@@ -66,6 +66,7 @@ class StockEntry(StockController):
self.validate_valuation_rate()
self.set_total_incoming_outgoing_value()
self.set_total_amount()
self.validate_batch()
def on_submit(self):
self.update_stock_ledger()
@@ -359,8 +360,11 @@ class StockEntry(StockController):
if self.purpose == "Subcontract" and self.purchase_order:
purchase_order = frappe.get_doc("Purchase Order", self.purchase_order)
for se_item in self.items:
total_allowed = [d.required_qty for d in purchase_order.supplied_items \
if d.rm_item_code == se_item.item_code][0]
total_allowed = sum([flt(d.required_qty) for d in purchase_order.supplied_items \
if d.rm_item_code == se_item.item_code])
if not total_allowed:
frappe.throw(_("Item {0} not found in 'Raw Materials Supplied' table in Purchase Order {1}")
.format(se_item.item_code, self.purchase_order))
total_supplied = frappe.db.sql("""select sum(qty)
from `tabStock Entry Detail`, `tabStock Entry`
where `tabStock Entry`.purchase_order = %s
@@ -721,6 +725,13 @@ class StockEntry(StockController):
mreq_item.warehouse != (item.s_warehouse if self.purpose== "Material Issue" else item.t_warehouse):
frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx),
frappe.MappingMismatchError)
def validate_batch(self):
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
for item in self.get("items"):
if item.batch_no:
if getdate(self.posting_date) > getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")):
frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
@frappe.whitelist()
def get_party_details(ref_dt, ref_dn):
@@ -859,8 +870,6 @@ def make_return_jv(stock_entry):
"account": r.get("account"),
"party_type": r.get("party_type"),
"party": r.get("party"),
"against_invoice": r.get("against_invoice"),
"against_voucher": r.get("against_voucher"),
"balance": get_balance_on(r.get("account"), se.posting_date) if r.get("account") else 0
})
@@ -871,8 +880,7 @@ def make_return_jv_from_sales_invoice(se, ref):
parent = {
"account": ref.doc.debit_to,
"party_type": "Customer",
"party": ref.doc.customer,
"against_invoice": ref.doc.name,
"party": ref.doc.customer
}
# income account entries
@@ -946,9 +954,6 @@ def make_return_jv_from_delivery_note(se, ref):
break
if len(invoices_against_delivery) == 1:
parent["against_invoice"] = invoices_against_delivery[0]
result = [parent] + [{"account": account} for account in children]
return result
@@ -1004,9 +1009,6 @@ def make_return_jv_from_purchase_receipt(se, ref):
break
if len(invoice_against_receipt) == 1:
parent["against_voucher"] = invoice_against_receipt[0]
result = [parent] + [{"account": account} for account in children]
return result

Some files were not shown because too many files have changed in this diff Show More