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): @@ -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 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 @@