[fix] [minor] set customer/supplier defaults

This commit is contained in:
Anand Doshi 2013-07-25 17:46:02 +05:30
parent c9c00c904f
commit f2045fb92e
4 changed files with 26 additions and 14 deletions

View File

@ -89,11 +89,11 @@ class DocType(BuyingController):
return ret
def set_supplier_defaults(self):
self.doc.fields.update(self.get_cust())
self.doc.fields.update(self.get_supplier())
self.doc.fields.update(self.get_credit_to())
super(DocType, self).set_supplier_defaults()
def get_cust(self):
def get_supplier(self):
ret = {}
if self.doc.credit_to:
acc = webnotes.conn.get_value('Account',self.doc.credit_to,['master_name', 'credit_days'])

View File

@ -47,17 +47,12 @@ class BuyingController(StockController):
# set contact and address details for supplier, if they are not mentioned
if self.doc.supplier and not (self.doc.contact_person and self.doc.supplier_address):
for fieldname, val in self.get_default_address_and_contact("supplier").items():
for fieldname, val in self.get_supplier_defaults().items():
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
self.set_missing_item_details(get_item_details)
def set_supplier_defaults(self):
for fieldname, val in self.get_default_address_and_contact("supplier").items():
if self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
def get_purchase_tax_details(self):
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
self.set_taxes("purchase_tax_details", "purchase_other_charges")

View File

@ -97,9 +97,10 @@ class DocType:
""" Get raw material details like uom, desc and rate"""
if not args:
args = webnotes.form_dict.get('args')
import json
args = json.loads(args)
if isinstance(args, basestring):
import json
args = json.loads(args)
item = self.get_item_det(args['item_code'])
self.validate_rm_item(item)

View File

@ -94,8 +94,10 @@ class TransactionBase(StatusUpdater):
webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \
self.doc.price_list
self.doc.fields.update(customer_defaults)
for fieldname, val in customer_defaults.items():
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
if self.meta.get_field("sales_team"):
self.set_sales_team_for_customer()
@ -121,7 +123,21 @@ class TransactionBase(StatusUpdater):
# add child
self.doclist.append(sales_person)
def get_supplier_defaults(self):
out = self.get_default_address_and_contact("supplier")
supplier = webnotes.doc("Supplier", self.doc.supplier)
out["supplier_name"] = supplier.supplier_name
out["currency"] = supplier.default_currency
return out
def set_supplier_defaults(self):
for fieldname, val in self.get_supplier_defaults().items():
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
def get_lead_defaults(self):
out = self.get_default_address_and_contact("lead")