Skip to content

Commit

Permalink
Merge pull request #89 from akretion/16-sale_import_base-hook-address…
Browse files Browse the repository at this point in the history
…-merge

[IMP] Add hook to allow to disable the invoice and delivery address merge
  • Loading branch information
florian-dacosta authored Jun 12, 2024
2 parents eb51b52 + 8447277 commit ac6fa9a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sale_import_base/models/sale_channel_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ def _prepare_partner(self, data, parent_id=None, archived=None):
result["state_id"] = state.id
return result

def _should_merge_addresses(self, vals_addr_invoice, vals_addr_shipping):
return vals_addr_invoice == vals_addr_shipping

def _process_addresses(self, parent, address_invoice, address_shipping):
vals_addr_invoice = self._prepare_partner(address_invoice, parent.id, True)
vals_addr_shipping = self._prepare_partner(address_shipping, parent.id, True)
if vals_addr_invoice == vals_addr_shipping:
if self._should_merge_addresses(vals_addr_invoice, vals_addr_shipping):
# not technically correct for the shipping addr, but this shouldn't matter
vals_addr_invoice["type"] = "invoice"
result = self.env["res.partner"].create(vals_addr_invoice)
Expand Down

0 comments on commit ac6fa9a

Please sign in to comment.