def set_pos_fields(self, for_validate=False): """Set retail related fields from pos settings""" if cint(self.doc.is_pos) != 1: return from selling.utils import get_pos_settings, apply_pos_settings pos = get_pos_settings(self.doc.company) if pos: if not for_validate and not self.doc.customer: self.doc.customer = pos.customer self.set_customer_defaults() for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name', 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account'): if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): self.doc.fields[fieldname] = pos.get(fieldname) if not for_validate: self.doc.update_stock = cint(pos.get("update_stock")) # set pos values in items for item in self.doclist.get({"parentfield": "entries"}): if item.fields.get('item_code'): for fieldname, val in apply_pos_settings(pos, item.fields).items(): if (not for_validate) or (for_validate and not item.fields.get(fieldname)): item.fields[fieldname] = val # fetch terms if self.doc.tc_name and not self.doc.terms: self.doc.terms = webnotes.conn.get_value("Terms and Conditions", self.doc.tc_name, "terms") # fetch charges if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})): self.set_taxes("other_charges", "charge")
def set_pos_fields(self, for_validate=False): """Set retail related fields from pos settings""" if cint(self.doc.is_pos) != 1: return from selling.utils import get_pos_settings, apply_pos_settings pos = get_pos_settings(self.doc.company) if pos: self.doc.conversion_rate = flt(pos.conversion_rate) if not self.doc.debit_to: self.doc.debit_to = self.doc.customer and webnotes.conn.get_value( "Account", { "name": self.doc.customer + " - " + self.get_company_abbr(), "docstatus": ["!=", 2] }) or pos.customer_account if self.doc.debit_to and not self.doc.customer: self.doc.customer = webnotes.conn.get_value( "Account", { "name": self.doc.debit_to, "master_type": "Customer" }, "master_name") for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name', 'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'): if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): self.doc.fields[fieldname] = pos.get(fieldname) if not for_validate: self.doc.update_stock = cint(pos.get("update_stock")) # set pos values in items for item in self.doclist.get({"parentfield": "entries"}): if item.fields.get('item_code'): for fieldname, val in apply_pos_settings( pos, item.fields).items(): if (not for_validate) or ( for_validate and not item.fields.get(fieldname)): item.fields[fieldname] = val # fetch terms if self.doc.tc_name and not self.doc.terms: self.doc.terms = webnotes.conn.get_value( "Terms and Conditions", self.doc.tc_name, "terms") # fetch charges if self.doc.charge and not len( self.doclist.get({"parentfield": "other_charges"})): self.set_taxes("other_charges", "charge")