def set_pos_fields(self, for_validate=False): """Set retail related fields from POS Profiles""" if cint(self.is_pos) != 1: return from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile pos = get_pos_profile(self.company) if not self.get('payments') and not for_validate: pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None update_multi_mode_option(self, pos_profile) if not self.account_for_change_amount: self.account_for_change_amount = frappe.db.get_value( 'Company', self.company, 'default_cash_account') if pos: if not for_validate and not self.customer: self.customer = pos.customer self.mode_of_payment = pos.mode_of_payment # self.set_customer_defaults() if pos.get('account_for_change_amount'): self.account_for_change_amount = pos.get( 'account_for_change_amount') for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name', 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account', 'write_off_account', 'write_off_cost_center', 'apply_discount_on'): if (not for_validate) or (for_validate and not self.get(fieldname)): self.set(fieldname, pos.get(fieldname)) if not for_validate: self.update_stock = cint(pos.get("update_stock")) # set pos values in items for item in self.get("items"): if item.get('item_code'): for fname, val in get_pos_profile_item_details( pos, frappe._dict(item.as_dict()), pos).items(): if (not for_validate) or (for_validate and not item.get(fname)): item.set(fname, val) # fetch terms if self.tc_name and not self.terms: self.terms = frappe.db.get_value("Terms and Conditions", self.tc_name, "terms") # fetch charges if self.taxes_and_charges and not len(self.get("taxes")): self.set_taxes() return pos
def set_pos_fields(self, for_validate=False): """Set retail related fields from POS Profiles""" if cint(self.is_pos) != 1: return from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile if not self.pos_profile: pos_profile = get_pos_profile(self.company) or {} self.pos_profile = pos_profile.get('name') pos = {} if self.pos_profile: pos = frappe.get_doc('POS Profile', self.pos_profile) if not self.get('payments') and not for_validate: update_multi_mode_option(self, pos) if not self.account_for_change_amount: self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account') if pos: self.allow_print_before_pay = pos.allow_print_before_pay if not for_validate and not self.customer: self.customer = pos.customer if pos.get('account_for_change_amount'): self.account_for_change_amount = pos.get('account_for_change_amount') for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name', 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account', 'write_off_account', 'write_off_cost_center', 'apply_discount_on'): if (not for_validate) or (for_validate and not self.get(fieldname)): self.set(fieldname, pos.get(fieldname)) if not for_validate: self.update_stock = cint(pos.get("update_stock")) # set pos values in items for item in self.get("items"): if item.get('item_code'): for fname, val in get_pos_profile_item_details(pos, frappe._dict(item.as_dict()), pos).items(): if (not for_validate) or (for_validate and not item.get(fname)): item.set(fname, val) # fetch terms if self.tc_name and not self.terms: self.terms = frappe.db.get_value("Terms and Conditions", self.tc_name, "terms") # fetch charges if self.taxes_and_charges and not len(self.get("taxes")): self.set_taxes() return pos
def set_pos_fields(self, for_validate=False): """Set retail related fields from POS Profiles""" if cint(self.is_pos) != 1: return from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile pos = get_pos_profile(self.company) if not self.get("payments") and not for_validate: pos_profile = frappe.get_doc("POS Profile", pos.name) if pos else None update_multi_mode_option(self, pos_profile) if not self.account_for_change_amount: self.account_for_change_amount = frappe.db.get_value("Company", self.company, "default_cash_account") if pos: if not for_validate and not self.customer: self.customer = pos.customer self.mode_of_payment = pos.mode_of_payment # self.set_customer_defaults() if pos.get("account_for_change_amount"): self.account_for_change_amount = pos.get("account_for_change_amount") for fieldname in ( "territory", "naming_series", "currency", "taxes_and_charges", "letter_head", "tc_name", "selling_price_list", "company", "select_print_heading", "cash_bank_account", "write_off_account", "write_off_cost_center", ): if (not for_validate) or (for_validate and not self.get(fieldname)): self.set(fieldname, pos.get(fieldname)) if not for_validate: self.update_stock = cint(pos.get("update_stock")) # set pos values in items for item in self.get("items"): if item.get("item_code"): for fname, val in get_pos_profile_item_details(pos, frappe._dict(item.as_dict()), pos).items(): if (not for_validate) or (for_validate and not item.get(fname)): item.set(fname, val) # fetch terms if self.tc_name and not self.terms: self.terms = frappe.db.get_value("Terms and Conditions", self.tc_name, "terms") # fetch charges if self.taxes_and_charges and not len(self.get("taxes")): self.set_taxes() return pos