[sales invoice] [fetching] fetch pos values and customer address contact values

This commit is contained in:
Anand Doshi
2013-04-26 17:21:49 +05:30
parent 205f7ce620
commit edc5f2edd0
4 changed files with 104 additions and 85 deletions

View File

@@ -0,0 +1,14 @@
test_records = [
[{
"doctype": "Address",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"address_type": "Office",
"address_title": "_Test Address",
"address_line1": "_Test Address Line 1",
"city": "_Test City",
"country": "India",
"phone": "+91 0000000000",
"is_primary_address": 1
}],
]

View File

@@ -22,6 +22,23 @@ from webnotes.model.doc import addchild
from webnotes.model.controller import DocListController
class TransactionBase(DocListController):
def get_default_address_and_contact(self, party_type):
"""get a dict of default field values of address and contact for a given party type
party_type can be one of: customer, supplier"""
ret = {}
# {customer: self.doc.fields.get("customer")}
args = {party_type: self.doc.fields.get(party_type)}
address_text, address_name = self.get_address_text(**args)
ret.update({
# customer_address
(party_type + "_address"): address_name,
"address_display": address_text
})
ret.update(self.get_contact_text(**args))
return ret
# Get Customer Default Primary Address - first load
def get_default_customer_address(self, args=''):
address_text, address_name = self.get_address_text(customer=self.doc.customer)
@@ -73,7 +90,7 @@ class TransactionBase(DocListController):
details = webnotes.conn.sql("select name, address_line1, address_line2, city, country, pincode, state, phone, fax from `tabAddress` where %s and docstatus != 2 order by is_shipping_address desc, is_primary_address desc limit 1" % cond, as_dict = 1)
else:
details = webnotes.conn.sql("select name, address_line1, address_line2, city, country, pincode, state, phone, fax from `tabAddress` where %s and docstatus != 2 order by is_primary_address desc limit 1" % cond, as_dict = 1)
extract = lambda x: details and details[0] and details[0].get(x,'') or ''
address_fields = [('','address_line1'),('\n','address_line2'),('\n','city'),('\n','state'),(' ','pincode'),('\n','country'),('\nPhone: ','phone'),('\nFax: ', 'fax')]
address_display = ''.join([a[0]+extract(a[1]) for a in address_fields if extract(a[1])])