Fixed mapping of conversion rate for PO-PR and PO-PV
This commit is contained in:
51
erpnext/patches/jan_mar_2012/map_conversion_rate.py
Normal file
51
erpnext/patches/jan_mar_2012/map_conversion_rate.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.model.doc import addchild
|
||||
|
||||
def execute():
|
||||
"""
|
||||
* Maps conversion rate in doctype mapper PO-PR
|
||||
* Maps conversion rate in doctype mapper PO-PV
|
||||
"""
|
||||
args = [
|
||||
{
|
||||
'parent': 'Purchase Order-Purchase Receipt',
|
||||
'map': [{
|
||||
'from_table': 'Purchase Order',
|
||||
'to_table': 'Purchase Receipt',
|
||||
'fields': [['conversion_rate', 'conversion_rate', 'Yes']]
|
||||
}]
|
||||
},
|
||||
{
|
||||
'parent': 'Purchase Order-Payable Voucher',
|
||||
'map': [{
|
||||
'from_table': 'Purchase Order',
|
||||
'to_table': 'Payable Voucher',
|
||||
'fields': [['conversion_rate', 'conversion_rate', 'Yes']]
|
||||
}]
|
||||
},
|
||||
]
|
||||
|
||||
for a in args:
|
||||
for m in a['map']:
|
||||
match_id = webnotes.conn.sql("""\
|
||||
SELECT match_id FROM `tabTable Mapper Detail`
|
||||
WHERE parent=%s AND from_table=%s AND to_table=%s\
|
||||
""", (a['parent'], m['from_table'], m['to_table']))[0][0]
|
||||
for f in m['fields']:
|
||||
res = webnotes.conn.sql("""\
|
||||
SELECT name FROM `tabField Mapper Detail`
|
||||
WHERE parent=%s AND from_field=%s AND to_field=%s
|
||||
AND match_id=%s""", (a['parent'], f[0], f[1], match_id))
|
||||
if not res:
|
||||
max_idx = webnotes.conn.sql("""\
|
||||
SELECT IFNULL(MAX(idx), 0) FROM `tabField Mapper Detail`
|
||||
WHERE parent=%s""", a['parent'])[0][0]
|
||||
obj = get_obj('DocType Mapper', a['parent'])
|
||||
c = addchild(obj.doc, 'field_mapper_details', 'Field Mapper Detail', obj.doclist)
|
||||
c.from_field = f[0]
|
||||
c.to_field = f[1]
|
||||
c.fields['map'] = f[2]
|
||||
c.match_id = match_id
|
||||
c.idx = max_idx + 1
|
||||
c.save()
|
||||
Reference in New Issue
Block a user