Skip to content
Permalink
Browse files

[FIX] product, website_sale: clean dead code

The `_get_pl()` method introduced with bcb3956 was replaced by
`_get_pl_partner_order()` in afe1d20.
After that, it looks like this method was never called again.

Plus, add a missing ensure_one() (not critical).
  • Loading branch information...
rdeodoo committed Mar 12, 2019
1 parent 25a8b50 commit 08a17b68832b1c035730b4effa4cabbcc9580091
@@ -24,7 +24,7 @@ def _default_website(self):
selectable = fields.Boolean(help="Allow the end user to choose this price list")

def clear_cache(self):
# website._get_pl() is cached to avoid to recompute at each request the
# website._get_pl_partner_order() is cached to avoid to recompute at each request the
# list of available pricelists. So, we need to invalidate the cache when
# we change the config of website price list to force to recompute.
website = self.env['website']
@@ -55,6 +55,7 @@ def _get_pl_partner_order(self, country_code, show_visible, website_pl, current_
:param int order_pl: the current cart pricelist
:returns: list of pricelist ids
"""
self.ensure_one()
pricelists = self.env['product.pricelist']
if country_code:
for cgroup in self.env['res.country.group'].search([('country_ids.code', '=', country_code)]):
@@ -76,6 +77,7 @@ def _get_pl_partner_order(self, country_code, show_visible, website_pl, current_
# This method is cached, must not return records! See also #8795
return pricelists.ids

# DEPRECATED (Not used anymore) -> Remove me in master (saas12.3)
def _get_pl(self, country_code, show_visible, website_pl, current_pl, all_pl):
pl_ids = self._get_pl_partner_order(country_code, show_visible, website_pl, current_pl, all_pl)
return self.env['product.pricelist'].browse(pl_ids)
@@ -47,14 +47,14 @@ def setUp(self):
self.addCleanup(patcher.stop)

def get_pl(self, show, current_pl, country):
pls = self.website._get_pl(
pl_ids = self.website._get_pl_partner_order(
country,
show,
self.website.pricelist_id.id,
current_pl,
self.website.pricelist_ids
)
return pls
return self.env['product.pricelist'].browse(pl_ids)

def test_get_pricelist_available_show(self):
show = True

1 comment on commit 08a17b6

@rdeodoo

This comment has been minimized.

Copy link
Contributor Author

rdeodoo commented on 08a17b6 Mar 18, 2019

Coming from #28301

Please sign in to comment.
You can’t perform that action at this time.