Skip to content

Commit

Permalink
[IMP] connector_woocommerce_apg_nif: included hooks to separate NIF f…
Browse files Browse the repository at this point in the history
…rom connector_woocommerce
  • Loading branch information
KNVx committed Sep 12, 2024
1 parent 8b7fac2 commit 1b5e4cc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions connector_woocommerce_apg_nif/models/sale_order/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,21 @@ def _get_shipping(self, value, hash_fields):
if item["key"] == "_shipping_nif":
value["shipping"]["nif"] = item["value"]
super()._get_shipping(value, hash_fields)

def _get_partner_parent_domain(self, dir_type, value):
domain = super()._get_partner_parent_domain(dir_type, value)
if value[dir_type].get("nif"):
domain.append(("vat", "=", value[dir_type]["nif"]))
else:
if (
dir_type == "shipping"
and value["shipping"]["name"] == value["billing"]["name"]
):
domain.append(("id", "=", value["billing"]["parent"]))
return domain

def _additional_partner_parent_fields(self, value, dir_type):
return {
**super()._additional_partner_parent_fields(value, dir_type),
"vat": value[dir_type].get("nif"),
}

0 comments on commit 1b5e4cc

Please sign in to comment.