[website] [partners listing] first cut

This commit is contained in:
Anand Doshi
2013-06-13 14:40:57 +05:30
parent 48519ef8ae
commit 8e2ea5fed6
6 changed files with 185 additions and 58 deletions

View File

@@ -8,44 +8,50 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes.utils import cint, cstr, filter_strip_join
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
def validate(self):
import string
if not (self.doc.address_line1) and not (self.doc.address_line2) and not (self.doc.city) and not (self.doc.state) and not (self.doc.country) and not (self.doc.pincode):
return "Please enter address"
else:
address =["address_line1", "address_line2", "city", "state", "country", "pincode"]
comp_address=''
for d in address:
if self.doc.fields[d]:
comp_address += self.doc.fields[d] + "\n"
self.doc.address = comp_address
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))
return contact_details
else:
return ''
def on_update(self):
if cint(self.doc.show_in_website):
from webnotes.webutils import update_page_name
update_page_name(self.doc, self.doc.partner_name)
if self.doc.page_name:
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))
return contact_details
else:
return ''
def prepare_template_args(self):
address = webnotes.conn.get_value("Address",
{"sales_partner": self.doc.name, "is_primary_address": 1},
"*", as_dict=True)
if address:
city_state = ", ".join(filter(None, [address.city, address.state]))
address_rows = [address.address_line1, address.address_line2,
city_state, address.pincode, address.country]
self.doc.fields.update({
"email": address.email_id,
"partner_address": filter_strip_join(address_rows, "\n<br>"),
"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
})

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-01-10 16:34:24",
"creation": "2013-04-12 15:34:06",
"docstatus": 0,
"modified": "2013-01-22 15:04:05",
"modified": "2013-06-13 14:40:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -25,6 +25,7 @@
"permlevel": 0
},
{
"amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Sales Partner",
@@ -39,14 +40,6 @@
"doctype": "DocType",
"name": "Sales Partner"
},
{
"description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts",
"doctype": "DocField",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"label": "Sales Partner Details",
"oldfieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "partner_name",
@@ -69,6 +62,14 @@
"options": "\nChannel Partner\nDistributor\nDealer\nAgent\nRetailer\nImplementation Partner\nReseller",
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "territory",
"fieldtype": "Link",
"label": "Territory",
"options": "Territory",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break0",
@@ -85,14 +86,6 @@
"oldfieldtype": "Currency",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "territory",
"fieldtype": "Link",
"label": "Territory",
"options": "Territory",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "address_contacts",
@@ -162,7 +155,67 @@
"options": "Budget Distribution"
},
{
"amend": 0,
"doctype": "DocField",
"fieldname": "website",
"fieldtype": "Section Break",
"label": "Website"
},
{
"doctype": "DocField",
"fieldname": "show_in_website",
"fieldtype": "Check",
"label": "Show In Website"
},
{
"depends_on": "eval:cint(doc.show_in_website)",
"doctype": "DocField",
"fieldname": "section_break_17",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "logo",
"fieldtype": "Select",
"label": "Logo",
"options": "attach_files:"
},
{
"doctype": "DocField",
"fieldname": "partner_website",
"fieldtype": "Data",
"label": "Partner's Website"
},
{
"doctype": "DocField",
"fieldname": "column_break_20",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "page_name",
"fieldtype": "Data",
"label": "Page Name",
"read_only": 1
},
{
"depends_on": "eval:cint(doc.show_in_website)",
"doctype": "DocField",
"fieldname": "section_break_22",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "introduction",
"fieldtype": "Text",
"label": "Introduction"
},
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Text Editor",
"label": "Description"
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
@@ -170,7 +223,6 @@
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
@@ -178,18 +230,10 @@
"write": 0
},
{
"amend": 0,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales Master Manager",
"write": 1
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "System Manager",
"write": 1
}
]