예제 #1
0
    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_profiles_item_details, get_pos_profiles
        pos = get_pos_profiles(self.company)

        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()

            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_profiles_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()
예제 #2
0
	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_profiles_item_details, get_pos_profiles
		pos = get_pos_profiles(self.company)

		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()

			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_profiles_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()