Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 1 | # Copyright (c) 2012 Web Notes Technologies Pvt Ltd. |
| 2 | # License: GNU General Public License (v3). For more information see license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 6 | import webnotes.defaults |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 7 | from webnotes.utils import flt, get_fullname, fmt_money |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 8 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 9 | class WebsitePriceListMissingError(webnotes.ValidationError): pass |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 10 | |
| 11 | @webnotes.whitelist() |
Anand Doshi | edbf3e1 | 2013-07-02 11:40:16 +0530 | [diff] [blame] | 12 | def get_cart_quotation(doclist=None): |
| 13 | party = get_lead_or_customer() |
| 14 | |
| 15 | if not doclist: |
| 16 | doclist = _get_cart_quotation(party).doclist |
| 17 | |
| 18 | return { |
| 19 | "doclist": decorate_quotation_doclist(doclist), |
| 20 | "addresses": [{"name": address.name, "display": address.display} |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 21 | for address in get_address_docs(party)], |
| 22 | "shipping_rules": get_applicable_shipping_rules(party) |
Anand Doshi | edbf3e1 | 2013-07-02 11:40:16 +0530 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | @webnotes.whitelist() |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 26 | def update_cart(item_code, qty, with_doclist=0): |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 27 | quotation = _get_cart_quotation() |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 28 | |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 29 | qty = flt(qty) |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 30 | if qty == 0: |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 31 | quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]})) |
| 32 | else: |
| 33 | quotation_items = quotation.doclist.get({"item_code": item_code}) |
| 34 | if not quotation_items: |
| 35 | quotation.doclist.append({ |
| 36 | "doctype": "Quotation Item", |
| 37 | "parentfield": "quotation_details", |
| 38 | "item_code": item_code, |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 39 | "qty": qty |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 40 | }) |
| 41 | else: |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 42 | quotation_items[0].qty = qty |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 43 | |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 44 | apply_cart_settings(quotation=quotation) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 45 | |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 46 | if with_doclist: |
Anand Doshi | edbf3e1 | 2013-07-02 11:40:16 +0530 | [diff] [blame] | 47 | return get_cart_quotation(quotation.doclist) |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 48 | else: |
| 49 | return quotation.doc.name |
Anand Doshi | edbf3e1 | 2013-07-02 11:40:16 +0530 | [diff] [blame] | 50 | |
| 51 | @webnotes.whitelist() |
| 52 | def update_cart_address(address_fieldname, address_name): |
| 53 | from utilities.transaction_base import get_address_display |
| 54 | |
| 55 | quotation = _get_cart_quotation() |
| 56 | address_display = get_address_display(webnotes.doc("Address", address_name).fields) |
| 57 | |
| 58 | if address_fieldname == "shipping_address_name": |
| 59 | quotation.doc.shipping_address_name = address_name |
| 60 | quotation.doc.shipping_address = address_display |
| 61 | |
| 62 | if not quotation.doc.customer_address: |
| 63 | address_fieldname == "customer_address" |
| 64 | |
| 65 | if address_fieldname == "customer_address": |
| 66 | quotation.doc.customer_address = address_name |
| 67 | quotation.doc.address_display = address_display |
| 68 | |
| 69 | |
| 70 | quotation.ignore_permissions = True |
| 71 | quotation.save() |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 72 | |
| 73 | apply_cart_settings(quotation=quotation) |
Anand Doshi | edbf3e1 | 2013-07-02 11:40:16 +0530 | [diff] [blame] | 74 | |
| 75 | return get_cart_quotation(quotation.doclist) |
| 76 | |
| 77 | @webnotes.whitelist() |
| 78 | def get_addresses(): |
| 79 | return [d.fields for d in get_address_docs()] |
| 80 | |
| 81 | @webnotes.whitelist() |
| 82 | def save_address(fields, address_fieldname=None): |
| 83 | party = get_lead_or_customer() |
| 84 | fields = webnotes.load_json(fields) |
| 85 | |
| 86 | if fields.get("name"): |
| 87 | bean = webnotes.bean("Address", fields.get("name")) |
| 88 | else: |
| 89 | bean = webnotes.bean({"doctype": "Address", "__islocal": 1}) |
| 90 | |
| 91 | bean.doc.fields.update(fields) |
| 92 | |
| 93 | party_fieldname = party.doctype.lower() |
| 94 | bean.doc.fields.update({ |
| 95 | party_fieldname: party.name, |
| 96 | (party_fieldname + "_name"): party.fields[party_fieldname + "_name"] |
| 97 | }) |
| 98 | bean.ignore_permissions = True |
| 99 | bean.save() |
| 100 | |
| 101 | if address_fieldname: |
| 102 | update_cart_address(address_fieldname, bean.doc.name) |
| 103 | |
| 104 | return bean.doc.name |
| 105 | |
| 106 | def get_address_docs(party=None): |
| 107 | from webnotes.model.doclist import objectify |
| 108 | from utilities.transaction_base import get_address_display |
| 109 | |
| 110 | if not party: |
| 111 | party = get_lead_or_customer() |
| 112 | |
| 113 | address_docs = objectify(webnotes.conn.sql("""select * from `tabAddress` |
| 114 | where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name, |
| 115 | as_dict=True, update={"doctype": "Address"})) |
| 116 | |
| 117 | for address in address_docs: |
| 118 | address.display = get_address_display(address.fields) |
| 119 | address.display = (address.display).replace("\n", "<br>\n") |
| 120 | |
| 121 | return address_docs |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 122 | |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 123 | def get_lead_or_customer(): |
| 124 | customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer") |
| 125 | if customer: |
| 126 | return webnotes.doc("Customer", customer) |
| 127 | |
| 128 | lead = webnotes.conn.get_value("Lead", {"email_id": webnotes.session.user}) |
| 129 | if lead: |
| 130 | return webnotes.doc("Lead", lead) |
| 131 | else: |
| 132 | lead_bean = webnotes.bean({ |
| 133 | "doctype": "Lead", |
| 134 | "email_id": webnotes.session.user, |
| 135 | "lead_name": get_fullname(webnotes.session.user), |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 136 | "territory": guess_territory(), |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 137 | "status": "Open" # TODO: set something better??? |
| 138 | }) |
| 139 | lead_bean.ignore_permissions = True |
| 140 | lead_bean.insert() |
| 141 | |
| 142 | return lead_bean.doc |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 143 | |
| 144 | def guess_territory(): |
| 145 | territory = None |
| 146 | geoip_country = webnotes.session.get("session_country") |
| 147 | if geoip_country: |
| 148 | territory = webnotes.conn.get_value("Territory", geoip_country) |
| 149 | |
| 150 | return territory or \ |
| 151 | webnotes.conn.get_value("Shopping Cart Settings", None, "territory") or \ |
| 152 | "All Territories" |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 153 | |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 154 | def decorate_quotation_doclist(doclist): |
| 155 | for d in doclist: |
| 156 | if d.item_code: |
| 157 | d.fields.update(webnotes.conn.get_value("Item", d.item_code, |
| 158 | ["website_image", "web_short_description", "page_name"], as_dict=True)) |
| 159 | d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency) |
| 160 | d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency) |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 161 | elif d.charge_type: |
| 162 | d.formatted_tax_amount = fmt_money(d.tax_amount / doclist[0].conversion_rate, |
| 163 | currency=doclist[0].currency) |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 164 | |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 165 | doclist[0].formatted_grand_total_export = fmt_money(doclist[0].grand_total_export, |
| 166 | currency=doclist[0].currency) |
| 167 | |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 168 | return [d.fields for d in doclist] |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 169 | |
| 170 | def _get_cart_quotation(party=None): |
| 171 | if not party: |
| 172 | party = get_lead_or_customer() |
| 173 | |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 174 | quotation = webnotes.conn.get_value("Quotation", |
| 175 | {party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0}) |
| 176 | |
| 177 | if quotation: |
| 178 | qbean = webnotes.bean("Quotation", quotation) |
| 179 | else: |
| 180 | qbean = webnotes.bean({ |
| 181 | "doctype": "Quotation", |
| 182 | "naming_series": "QTN-CART-", |
Anand Doshi | c2a3527 | 2013-06-19 17:19:20 +0530 | [diff] [blame] | 183 | "quotation_to": party.doctype, |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 184 | "company": webnotes.defaults.get_user_default("company"), |
| 185 | "order_type": "Shopping Cart", |
| 186 | "status": "Draft", |
| 187 | "__islocal": 1, |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 188 | (party.doctype.lower()): party.name |
| 189 | }) |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 190 | qbean.run_method("onload_post_render") |
| 191 | apply_cart_settings(party, qbean) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 192 | |
| 193 | return qbean |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 194 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 195 | def apply_cart_settings(party=None, quotation=None): |
| 196 | if not party: |
| 197 | party = get_lead_or_customer() |
| 198 | if not quotation: |
| 199 | quotation = _get_cart_quotation(party) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 200 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 201 | cart_settings = webnotes.get_obj("Shopping Cart Settings") |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 202 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 203 | billing_territory = get_address_territory(quotation.doc.customer_address) or \ |
| 204 | party.territory |
| 205 | |
| 206 | set_price_list_and_rate(quotation, cart_settings, billing_territory) |
| 207 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 208 | quotation.run_method("calculate_taxes_and_totals") |
| 209 | |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 210 | set_taxes(quotation, cart_settings, billing_territory) |
| 211 | |
| 212 | _apply_shipping_rule(party, quotation, cart_settings) |
| 213 | |
| 214 | quotation.ignore_permissions = True |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 215 | quotation.save() |
| 216 | |
| 217 | def set_price_list_and_rate(quotation, cart_settings, billing_territory): |
| 218 | """set price list based on billing territory""" |
| 219 | quotation.doc.price_list_name = cart_settings.get_price_list(billing_territory) |
| 220 | |
| 221 | # reset values |
| 222 | quotation.doc.price_list_currency = quotation.doc.currency = \ |
| 223 | quotation.doc.plc_conversion_rate = quotation.doc.conversion_rate = None |
| 224 | for item in quotation.doclist.get({"parentfield": "quotation_details"}): |
| 225 | item.ref_rate = item.adj_rate = item.export_rate = item.export_amount = None |
| 226 | |
| 227 | # refetch values |
| 228 | quotation.run_method("set_price_list_and_item_details") |
| 229 | |
| 230 | def set_taxes(quotation, cart_settings, billing_territory): |
| 231 | """set taxes based on billing territory""" |
| 232 | quotation.doc.charge = cart_settings.get_tax_master(billing_territory) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 233 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 234 | # clear table |
| 235 | quotation.doclist = quotation.doc.clear_table(quotation.doclist, "other_charges") |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 236 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 237 | # append taxes |
| 238 | controller = quotation.make_controller() |
| 239 | controller.append_taxes_from_master("other_charges", "charge") |
| 240 | quotation.set_doclist(controller.doclist) |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 241 | |
| 242 | @webnotes.whitelist() |
| 243 | def apply_shipping_rule(shipping_rule): |
| 244 | quotation = _get_cart_quotation() |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 245 | |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 246 | quotation.doc.shipping_rule = shipping_rule |
| 247 | |
| 248 | apply_cart_settings(quotation=quotation) |
| 249 | |
| 250 | quotation.save() |
| 251 | |
| 252 | return get_cart_quotation(quotation.doclist) |
| 253 | |
| 254 | def _apply_shipping_rule(party=None, quotation=None, cart_settings=None): |
| 255 | shipping_rules = get_shipping_rules(party, quotation, cart_settings) |
| 256 | |
| 257 | if not shipping_rules: |
| 258 | return |
| 259 | |
| 260 | elif quotation.doc.shipping_rule not in shipping_rules: |
| 261 | quotation.doc.shipping_rule = shipping_rules[0] |
| 262 | |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 263 | quotation.run_method("apply_shipping_rule") |
Anand Doshi | 0b4943c | 2013-07-04 23:45:22 +0530 | [diff] [blame] | 264 | quotation.run_method("calculate_taxes_and_totals") |
| 265 | |
| 266 | def get_applicable_shipping_rules(party=None, quotation=None): |
| 267 | shipping_rules = get_shipping_rules(party, quotation) |
| 268 | |
| 269 | if shipping_rules: |
| 270 | rule_label_map = webnotes.conn.get_values("Shipping Rule", shipping_rules, "label") |
| 271 | # we need this in sorted order as per the position of the rule in the settings page |
| 272 | return [[rule, rule_label_map.get(rule)] for rule in shipping_rules] |
| 273 | |
| 274 | def get_shipping_rules(party=None, quotation=None, cart_settings=None): |
| 275 | if not party: |
| 276 | party = get_lead_or_customer() |
| 277 | if not quotation: |
| 278 | quotation = _get_cart_quotation() |
| 279 | if not cart_settings: |
| 280 | cart_settings = webnotes.get_obj("Shopping Cart Settings") |
| 281 | |
| 282 | # set shipping rule based on shipping territory |
| 283 | shipping_territory = get_address_territory(quotation.doc.shipping_address_name) or \ |
| 284 | party.territory |
| 285 | |
| 286 | shipping_rules = cart_settings.get_shipping_rules(shipping_territory) |
| 287 | |
| 288 | return shipping_rules |
Anand Doshi | 99100a4 | 2013-07-04 17:13:53 +0530 | [diff] [blame] | 289 | |
| 290 | def get_address_territory(address_name): |
| 291 | """Tries to match city, state and country of address to existing territory""" |
| 292 | territory = None |
| 293 | |
| 294 | if address_name: |
| 295 | address_fields = webnotes.conn.get_value("Address", address_name, |
| 296 | ["city", "state", "country"]) |
| 297 | for value in address_fields: |
| 298 | territory = webnotes.conn.get_value("Territory", value) |
| 299 | if territory: |
| 300 | break |
| 301 | |
| 302 | return territory |
| 303 | |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 304 | @webnotes.whitelist() |
| 305 | def checkout(): |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 306 | quotation = _get_cart_quotation() |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 307 | |
| 308 | quotation.ignore_permissions = True |
| 309 | quotation.submit() |
| 310 | |
Rushabh Mehta | a2a1ec7 | 2013-07-08 11:08:27 +0530 | [diff] [blame] | 311 | from selling.doctype.quotation.quotation import make_sales_order |
| 312 | |
| 313 | sales_order = webnotes.bean(make_sales_order(quotation.doc.name)) |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 314 | |
| 315 | sales_order.ignore_permissions = True |
| 316 | sales_order.insert() |
| 317 | sales_order.submit() |
| 318 | |
| 319 | return sales_order |
| 320 | |
| 321 | import unittest |
| 322 | test_dependencies = ["Item", "Price List", "Contact"] |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 323 | |
| 324 | class TestCart(unittest.TestCase): |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 325 | def test_get_lead_or_customer(self): |
| 326 | webnotes.session.user = "test@example.com" |
| 327 | party1 = get_lead_or_customer() |
| 328 | party2 = get_lead_or_customer() |
| 329 | self.assertEquals(party1.name, party2.name) |
| 330 | self.assertEquals(party1.doctype, "Lead") |
| 331 | |
| 332 | webnotes.session.user = "test_contact_customer@example.com" |
| 333 | party = get_lead_or_customer() |
| 334 | self.assertEquals(party.name, "_Test Customer") |
| 335 | |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 336 | def test_add_to_cart(self): |
| 337 | webnotes.session.user = "test@example.com" |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 338 | update_cart("_Test Item", 1) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 339 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 340 | quotation = _get_cart_quotation() |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 341 | quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) |
| 342 | self.assertTrue(quotation_items) |
| 343 | self.assertEquals(quotation_items[0].qty, 1) |
| 344 | |
| 345 | return quotation |
| 346 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 347 | def test_update_cart(self): |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 348 | self.test_add_to_cart() |
| 349 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 350 | update_cart("_Test Item", 5) |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 351 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 352 | quotation = _get_cart_quotation() |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 353 | quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) |
| 354 | self.assertTrue(quotation_items) |
| 355 | self.assertEquals(quotation_items[0].qty, 5) |
| 356 | |
| 357 | return quotation |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 358 | |
| 359 | def test_remove_from_cart(self): |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 360 | quotation0 = self.test_add_to_cart() |
| 361 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 362 | update_cart("_Test Item", 0) |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 363 | |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 364 | quotation = _get_cart_quotation() |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 365 | self.assertEquals(quotation0.doc.name, quotation.doc.name) |
| 366 | |
| 367 | quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) |
| 368 | self.assertEquals(quotation_items, []) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 369 | |
| 370 | def test_checkout(self): |
Anand Doshi | 3dceb84 | 2013-06-19 14:57:14 +0530 | [diff] [blame] | 371 | quotation = self.test_update_cart() |
Anand Doshi | e813212 | 2013-06-17 15:42:38 +0530 | [diff] [blame] | 372 | sales_order = checkout() |
| 373 | self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name) |
Anand Doshi | abc1003 | 2013-06-14 17:44:03 +0530 | [diff] [blame] | 374 | |