Skip to content

Commit

Permalink
fix: not able to make inter-company po from so (backport #38826) (#38828
Browse files Browse the repository at this point in the history
)

fix: not able to make inter-company po from so (#38826)

(cherry picked from commit 23042df)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 18, 2023
1 parent 8d79365 commit 32a608f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2382,9 +2382,18 @@ def update_item(source, target, source_parent):


def get_received_items(reference_name, doctype, reference_fieldname):
reference_field = "inter_company_invoice_reference"
if doctype == "Purchase Order":
reference_field = "inter_company_order_reference"

filters = {
reference_field: reference_name,
"docstatus": 1,
}

target_doctypes = frappe.get_all(
doctype,
filters={"inter_company_invoice_reference": reference_name, "docstatus": 1},
filters=filters,
as_list=True,
)

Expand Down
6 changes: 5 additions & 1 deletion erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ def set_incoming_rate(self):

rate = flt(outgoing_rate * (d.conversion_factor or 1), d.precision("rate"))
else:
field = "incoming_rate" if self.get("is_internal_supplier") else "rate"
field = (
"incoming_rate"
if self.get("is_internal_supplier") and not self.doctype == "Purchase Order"
else "rate"
)
rate = flt(
frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), field)
* (d.conversion_factor or 1),
Expand Down

0 comments on commit 32a608f

Please sign in to comment.