Skip to content

Commit

Permalink
Merge PR #717 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 19, 2024
2 parents efef39e + 2a8d523 commit 3b20d1d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion base_multi_company/models/multi_company_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _patch_company_domain(self, args):
if args is None:
args = []
for arg in args:
if type(arg) == list and arg[:2] == ["company_id", "in"]:
if type(arg) in {list, tuple} and list(arg[:2]) == ["company_id", "in"]:
fix = []
for _i in range(len(arg[2]) - 1):
fix.append("|")
Expand Down Expand Up @@ -115,3 +115,10 @@ def _name_search(
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
new_domain = self._patch_company_domain(domain)
return super().search_read(new_domain, fields, offset, limit, order)

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
args = self._patch_company_domain(args)
return super().search(
args, offset=offset, limit=limit, order=order, count=count
)
7 changes: 7 additions & 0 deletions base_multi_company/tests/test_multi_company_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def test_search_company_id(self):
)
self.assertEqual([{"id": self.record_1.id, "name": self.record_1.name}], result)

def test_search_in_false_company(self):
"""Records with no company are shared across companies but we need to convert
those queries with an or operator"""
self.record_1.company_ids = False
result = self.test_model.search([("company_id", "in", [1, False])])
self.assertEqual(result, self.record_1)

def test_patch_company_domain(self):
new_domain = self.test_model._patch_company_domain(
[["company_id", "in", [False, self.company_2.id]]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_purchase_locked_sale_product_container_deposit_inter_company(self):
# With the "update_order_container_deposit_quantity" context
# We can update order container deposit quantity on PO and locked SO also
purchase.with_context(
skip_update_container_deposit=False
skip_update_container_deposit=False, allow_update_locked_sales=True
).update_order_container_deposit_quantity()
# PO product packaging container deposit quantities
po_pallet_line = purchase.order_line.filtered(
Expand Down

0 comments on commit 3b20d1d

Please sign in to comment.