[IMP] product, *: remove deprecated fields and methods

* = mrp, sale, website_forum, website_sale, website_sale_comparison

closes odoo/odoo#34121

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Sébastien Theys
2019-06-14 12:17:35 +00:00
parent cecb3db386
commit 9bdecc7b61
12 changed files with 13 additions and 161 deletions
+1 -1
View File
@@ -314,7 +314,7 @@ class MrpBomLine(models.Model):
if not self.parent_product_tmpl_id:
return {}
return {'domain': {'attribute_value_ids': [
('id', 'in', self.parent_product_tmpl_id._get_valid_product_attribute_values().ids),
('id', 'in', self.parent_product_tmpl_id.valid_product_attribute_value_ids.ids),
('attribute_id.create_variant', '!=', 'no_variant')
]}}
-7
View File
@@ -373,8 +373,6 @@ class ProductProduct(models.Model):
self.clear_caches()
self.env['product.template'].invalidate_cache(
fnames=[
'valid_archived_variant_ids',
'valid_existing_variant_ids',
'product_variant_ids',
'product_variant_id',
'product_variant_count'
@@ -662,11 +660,6 @@ class ProductProduct(models.Model):
return prices
# compatibility to remove after v10 - DEPRECATED
@api.multi
def price_get(self, ptype='list_price'):
return self.price_compute(ptype)
@api.model
def get_empty_list_help(self, help):
self = self.with_context(
@@ -290,12 +290,6 @@ class Pricelist(models.Model):
self.ensure_one()
return self._compute_price_rule([(product, quantity, partner)], date=date, uom_id=uom_id)[product.id]
# Compatibility to remove after v10 - DEPRECATED
@api.model
def _price_rule_get_multi(self, pricelist, products_by_qty_by_partner):
""" Low level method computing the result tuple for a given pricelist and multi products - return tuple """
return pricelist._compute_price_rule(products_by_qty_by_partner)
@api.multi
def price_get(self, prod_id, qty, partner=None):
""" Multi pricelist, mono product - returns price per pricelist """
@@ -318,16 +312,6 @@ class Pricelist(models.Model):
return pricelist.get_products_price(
list(zip(**products_by_qty_by_partner)))
# DEPRECATED (Not used anymore, see d39d583b2) -> Remove me in master (saas12.3)
def _get_partner_pricelist(self, partner_id, company_id=None):
""" Retrieve the applicable pricelist for a given partner in a given company.
:param company_id: if passed, used for looking up properties,
instead of current user's company
"""
res = self._get_partner_pricelist_multi([partner_id], company_id)
return res[partner_id].id
def _get_partner_pricelist_multi_search_domain_hook(self):
return []
+4 -91
View File
@@ -135,12 +135,6 @@ class ProductTemplate(models.Model):
compute="_compute_valid_attributes", string='Valid Product Attribute Values Without No Variant Attributes', help="Technical compute")
valid_product_attribute_wnva_ids = fields.Many2many('product.attribute',
compute="_compute_valid_attributes", string='Valid Product Attributes Without No Variant Attributes', help="Technical compute")
# valid_archived_variant_ids deprecated
valid_archived_variant_ids = fields.Many2many('product.product',
compute="_compute_valid_archived_variant_ids", string='Valid Archived Variants', help="Technical compute")
# valid_existing_variant_ids deprecated
valid_existing_variant_ids = fields.Many2many('product.product',
compute="_compute_valid_existing_variant_ids", string='Valid Existing Variants', help="Technical compute")
product_variant_ids = fields.One2many('product.product', 'product_tmpl_id', 'Products', required=True)
# performance: product_variant_id provides prefetching on the first product variant only
@@ -482,11 +476,6 @@ class ProductTemplate(models.Model):
return prices
# compatibility to remove after v10 - DEPRECATED
@api.model
def _price_get(self, products, ptype='list_price'):
return products.price_compute(ptype)
@api.multi
def create_variant_ids(self):
Product = self.env["product.product"]
@@ -500,7 +489,7 @@ class ProductTemplate(models.Model):
variants_to_unlink = self.env['product.product']
# adding an attribute with only one value should not recreate product
# write this attribute on every product to make sure we don't lose them
variant_alone = tmpl_id._get_valid_product_template_attribute_lines().filtered(lambda line: line.attribute_id.create_variant == 'always' and len(line.value_ids) == 1).mapped('value_ids')
variant_alone = tmpl_id.valid_product_template_attribute_line_ids.filtered(lambda line: line.attribute_id.create_variant == 'always' and len(line.value_ids) == 1).mapped('value_ids')
for value_id in variant_alone:
updated_products = tmpl_id.product_variant_ids.filtered(lambda product: value_id.attribute_id not in product.mapped('attribute_value_ids.attribute_id'))
updated_products.write({'attribute_value_ids': [(4, value_id.id)]})
@@ -588,7 +577,7 @@ class ProductTemplate(models.Model):
:rtype: bool
"""
self.ensure_one()
return any(a.create_variant == 'dynamic' for a in self._get_valid_product_attributes())
return any(a.create_variant == 'dynamic' for a in self.valid_product_attribute_ids)
@api.multi
def _compute_valid_attributes(self):
@@ -622,51 +611,6 @@ class ProductTemplate(models.Model):
record.valid_product_attribute_ids = record.valid_product_template_attribute_line_ids.mapped('attribute_id')
record.valid_product_attribute_wnva_ids = record.valid_product_template_attribute_line_wnva_ids.mapped('attribute_id')
@api.multi
def _compute_valid_archived_variant_ids(self):
"""This compute is done outside of `_compute_valid_attributes` because
it is often not needed, and it can be very bad on performance."""
archived_variants = self.env['product.product'].search([('product_tmpl_id', 'in', self.ids), ('active', '=', False)])
for record in self:
valid_value_ids = record.valid_product_attribute_value_wnva_ids
valid_attribute_ids = record.valid_product_attribute_wnva_ids
record.valid_archived_variant_ids = archived_variants.filtered(
lambda v: v.product_tmpl_id == record and v._has_valid_attributes(valid_attribute_ids, valid_value_ids)
)
@api.multi
def _compute_valid_existing_variant_ids(self):
"""This compute is done outside of `_compute_valid_attributes` because
it is often not needed, and it can be very bad on performance."""
existing_variants = self.env['product.product'].search([('product_tmpl_id', 'in', self.ids), ('active', '=', True)])
for record in self:
valid_value_ids = record.valid_product_attribute_value_wnva_ids
valid_attribute_ids = record.valid_product_attribute_wnva_ids
record.valid_existing_variant_ids = existing_variants.filtered(
lambda v: v.product_tmpl_id == record and v._has_valid_attributes(valid_attribute_ids, valid_value_ids)
)
@api.multi
def _get_valid_product_template_attribute_lines(self):
"""deprecated, use `valid_product_template_attribute_line_ids`"""
self.ensure_one()
return self.valid_product_template_attribute_line_ids
@api.multi
def _get_valid_product_attributes(self):
"""deprecated, use `valid_product_attribute_ids`"""
self.ensure_one()
return self.valid_product_attribute_ids
@api.multi
def _get_valid_product_attribute_values(self):
"""deprecated, use `valid_product_attribute_value_ids`"""
self.ensure_one()
return self.valid_product_attribute_value_ids
@api.multi
def _get_possible_variants(self, parent_combination=None):
"""Return the existing variants that are possible.
@@ -707,10 +651,6 @@ class ProductTemplate(models.Model):
- exclusions: from this product itself
- parent_combination: ids of the given parent_combination
- parent_exclusions: from the parent_combination
- archived_combinations: deprecated
- existing_combinations: deprecated
- has_dynamic_attributes: deprecated
- no_variant_product_template_attribute_value_ids: deprecated
- parent_product_name: the name of the parent product if any, used in the interface
to explain why some combinations are not available.
(e.g: Not available with Customizable Desk (Legs: Steel))
@@ -724,10 +664,6 @@ class ProductTemplate(models.Model):
'exclusions': self._complete_inverse_exclusions(self._get_own_attribute_exclusions()),
'parent_exclusions': self._get_parent_attribute_exclusions(parent_combination),
'parent_combination': parent_combination.ids,
'archived_combinations': [],
'has_dynamic_attributes': self.has_dynamic_attributes(),
'existing_combinations': [],
'no_variant_product_template_attribute_value_ids': [],
'parent_product_name': parent_name,
'mapped_attribute_names': self._get_mapped_attribute_names(parent_combination),
}
@@ -756,7 +692,7 @@ class ProductTemplate(models.Model):
the value is an array with the other ptav that they exclude (empty if no exclusion).
"""
self.ensure_one()
product_template_attribute_values = self._get_valid_product_template_attribute_lines().mapped('product_template_value_ids')
product_template_attribute_values = self.valid_product_template_attribute_line_ids.product_template_value_ids
return {
ptav.id: [
value_id
@@ -793,29 +729,6 @@ class ProductTemplate(models.Model):
return result
@api.multi
def _get_archived_combinations(self):
"""Deprecated"""
self.ensure_one()
return [archived_variant.product_template_attribute_value_ids.ids
for archived_variant in self.valid_archived_variant_ids]
@api.multi
def _get_existing_combinations(self):
"""Deprecated"""
self.ensure_one()
return [variant.product_template_attribute_value_ids.ids
for variant in self.valid_existing_variant_ids]
@api.multi
def _get_no_variant_product_template_attribute_values(self):
"""Deprecated"""
self.ensure_one()
product_template_attribute_values = self._get_valid_product_template_attribute_lines().mapped('product_template_value_ids')
return product_template_attribute_values.filtered(
lambda v: v.attribute_id.create_variant == 'no_variant'
).ids
@api.multi
def _get_mapped_attribute_names(self, parent_combination=None):
""" The name of every attribute values based on their id,
@@ -826,7 +739,7 @@ class ProductTemplate(models.Model):
the parent combination if provided.
"""
self.ensure_one()
all_product_attribute_values = self._get_valid_product_template_attribute_lines().mapped('product_template_value_ids')
all_product_attribute_values = self.valid_product_template_attribute_line_ids.product_template_value_ids
if parent_combination:
all_product_attribute_values |= parent_combination
@@ -156,7 +156,7 @@ class TestProductAttributeValueSetup(TransactionCase):
"""
if not model:
model = self.computer
return model._get_valid_product_template_attribute_lines().filtered(
return model.valid_product_template_attribute_line_ids.filtered(
lambda l: l.attribute_id == product_attribute_value.attribute_id
).product_template_value_ids.filtered(
lambda v: v.product_attribute_value_id == product_attribute_value
+2 -17
View File
@@ -1373,21 +1373,6 @@ class SaleOrderLine(models.Model):
}
return res
@api.multi
def invoice_line_create(self, invoice_id, qty):
""" Create an invoice line. The quantity to invoice can be positive (invoice) or negative (refund).
.. deprecated:: 12.0
Replaced by :func:`invoice_line_create_vals` which can be used for creating
`account.invoice.line` records in batch
:param invoice_id: integer
:param qty: float quantity to invoice
:returns recordset of account.invoice.line created
"""
return self.env['account.invoice.line'].create(
self.invoice_line_create_vals(invoice_id, qty))
def invoice_line_create_vals(self, invoice_id, qty):
""" Create an invoice line. The quantity to invoice can be positive (invoice) or negative
(refund).
@@ -1454,12 +1439,12 @@ class SaleOrderLine(models.Model):
# remove the is_custom values that don't belong to this template
for pacv in self.product_custom_attribute_value_ids:
if pacv.attribute_value_id not in self.product_id.product_tmpl_id._get_valid_product_attribute_values():
if pacv.attribute_value_id not in self.product_id.product_tmpl_id.valid_product_attribute_value_ids:
self.product_custom_attribute_value_ids -= pacv
# remove the no_variant attributes that don't belong to this template
for ptav in self.product_no_variant_attribute_value_ids:
if ptav.product_attribute_value_id not in self.product_id.product_tmpl_id._get_valid_product_attribute_values():
if ptav.product_attribute_value_id not in self.product_id.product_tmpl_id.valid_product_attribute_value_ids:
self.product_no_variant_attribute_value_ids -= ptav
vals = {}
+1 -1
View File
@@ -3,7 +3,7 @@
<template id="variants">
<t t-set="attribute_exclusions" t-value="product._get_attribute_exclusions(parent_combination, parent_name)"/>
<ul t-attf-class="list-unstyled js_add_cart_variants #{ul_class}" t-att-data-attribute_exclusions="json.dumps(attribute_exclusions)">
<t t-foreach="product._get_valid_product_template_attribute_lines()" t-as="variant_id">
<t t-foreach="product.valid_product_template_attribute_line_ids" t-as="variant_id">
<!-- Attributes selection is hidden if there is only one value available and it's not a custom value -->
<li t-att-data-attribute_id="variant_id.attribute_id.id"
t-att-data-attribute_name="variant_id.attribute_id.name"
-18
View File
@@ -36,24 +36,6 @@ class WebsiteForum(WebsiteProfile):
values['forum'] = request.env['forum.forum'].browse(kwargs.pop('forum_id'))
return values
# User and validation
# --------------------------------------------------
# TODO DBE : Those 3 are deprecated. To remove in v13.
@http.route('/forum/send_validation_email', type='json', auth='user', website=True)
def send_forum_validation_email(self, forum_id=None, **kwargs):
_logger.warning("The method send_forum_validation_email() is deprecated and should be removed in v13.")
return self.send_forum_validation_email(forum_id=forum_id, **kwargs)
@http.route('/forum/validate_email', type='http', auth='public', website=True, sitemap=False)
def forum_validate_email(self, token, user_id, email, forum_id=None, **kwargs):
_logger.warning("The method forum_validate_email() is deprecated and should be removed in v13.")
return self.forum_validate_email(token=token, user_id=user_id, email=email, forum_id=forum_id, **kwargs)
@http.route('/forum/validate_email/close', type='json', auth='public', website=True)
def forum_validate_email_done(self, **kwargs):
_logger.warning("The method forum_validate_email_done() is deprecated and should be removed in v13.")
return self.validate_email_done(**kwargs)
# Forum
# --------------------------------------------------
+2 -2
View File
@@ -224,7 +224,7 @@ class ProductTemplate(models.Model):
:rtype: bool
"""
self.ensure_one()
return any(a.create_variant == 'no_variant' for a in self._get_valid_product_attributes())
return any(a.create_variant == 'no_variant' for a in self.valid_product_attribute_ids)
@api.multi
def _has_is_custom_values(self):
@@ -235,7 +235,7 @@ class ProductTemplate(models.Model):
:return: True if at least one is_custom attribute value, False otherwise
:rtype: bool
"""
return any(v.is_custom for v in self._get_valid_product_attribute_values())
return any(v.is_custom for v in self.valid_product_attribute_value_ids)
@api.multi
def _get_possible_variants_sorted(self, parent_combination=None):
-5
View File
@@ -118,11 +118,6 @@ class Website(models.Model):
# 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)
def _get_pricelist_available(self, req, show_visible=False):
""" Return the list of pricelists that can be used on website for the current user.
Country restrictions will be detected with GeoIP (if installed).
@@ -20,7 +20,7 @@ class WebsiteSaleProductComparison(WebsiteSale):
res = {}
for num, product in enumerate(products):
for var in product.product_tmpl_id._get_valid_product_template_attribute_lines():
for var in product.product_tmpl_id.valid_product_template_attribute_line_ids:
cat_name = var.attribute_id.category_id.name or _('Uncategorized')
att_name = var.attribute_id.name
if not var.attribute_id.create_variant:
@@ -26,6 +26,6 @@ class ProductTemplate(models.Model):
def get_variant_groups(self):
res = OrderedDict()
for var in self._get_valid_product_template_attribute_lines():
for var in self.valid_product_template_attribute_line_ids:
res.setdefault(var.attribute_id.category_id.name or _('Uncategorized'), []).append(var)
return res