diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-06-14 08:45:04 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-06-14 12:17:35 +0000 |
| commit | 9bdecc7b6158490796d670d04873ae89eb9ae4f3 (patch) | |
| tree | f87f12c1591d8668f46a04a0761ade68fa80c066 /addons | |
| parent | cecb3db386836fd48c3a124a1c9910438aa5048b (diff) | |
[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>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/mrp/models/mrp_bom.py | 2 | ||||
| -rw-r--r-- | addons/product/models/product.py | 7 | ||||
| -rw-r--r-- | addons/product/models/product_pricelist.py | 16 | ||||
| -rw-r--r-- | addons/product/models/product_template.py | 95 | ||||
| -rw-r--r-- | addons/product/tests/test_product_attribute_value_config.py | 2 | ||||
| -rw-r--r-- | addons/sale/models/sale.py | 19 | ||||
| -rw-r--r-- | addons/sale/views/variant_templates.xml | 2 | ||||
| -rw-r--r-- | addons/website_forum/controllers/main.py | 18 | ||||
| -rw-r--r-- | addons/website_sale/models/product.py | 4 | ||||
| -rw-r--r-- | addons/website_sale/models/website.py | 5 | ||||
| -rw-r--r-- | addons/website_sale_comparison/controllers/main.py | 2 | ||||
| -rw-r--r-- | addons/website_sale_comparison/models/website_sale_comparison.py | 2 |
12 files changed, 13 insertions, 161 deletions
diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index 6ace858bc78..7e106d7315b 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -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') ]}} diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 936b3350f54..cf1f70b579d 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -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( diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index 730d972405c..03ac7876101 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -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 [] diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index a6b1b43251d..b249acb9fda 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -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): @@ -623,51 +612,6 @@ class ProductTemplate(models.Model): 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 @@ -794,29 +730,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, used to explain in the interface why that combination is not available @@ -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 diff --git a/addons/product/tests/test_product_attribute_value_config.py b/addons/product/tests/test_product_attribute_value_config.py index 497f6fbeba3..5f53bf906c6 100644 --- a/addons/product/tests/test_product_attribute_value_config.py +++ b/addons/product/tests/test_product_attribute_value_config.py @@ -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 diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index d6afcd519bf..966588c4750 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -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 = {} diff --git a/addons/sale/views/variant_templates.xml b/addons/sale/views/variant_templates.xml index d9d28998e64..8ea33efeb05 100644 --- a/addons/sale/views/variant_templates.xml +++ b/addons/sale/views/variant_templates.xml @@ -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" diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index bd62e519338..86ce6993a90 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -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 # -------------------------------------------------- diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index e5bf6ca82f4..65b8db17882 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -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): diff --git a/addons/website_sale/models/website.py b/addons/website_sale/models/website.py index 742e60c3d61..c2b476feb65 100644 --- a/addons/website_sale/models/website.py +++ b/addons/website_sale/models/website.py @@ -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). diff --git a/addons/website_sale_comparison/controllers/main.py b/addons/website_sale_comparison/controllers/main.py index f6cb6cfc0fe..09a5984d64a 100644 --- a/addons/website_sale_comparison/controllers/main.py +++ b/addons/website_sale_comparison/controllers/main.py @@ -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: diff --git a/addons/website_sale_comparison/models/website_sale_comparison.py b/addons/website_sale_comparison/models/website_sale_comparison.py index 9c2fbca9082..0cf2c04e950 100644 --- a/addons/website_sale_comparison/models/website_sale_comparison.py +++ b/addons/website_sale_comparison/models/website_sale_comparison.py @@ -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 |
