diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 0e0e5f55ec5..90242c5f343 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -153,9 +153,7 @@ class AccountTax(models.Model): for tax in self: if not tax._check_m2m_recursion('children_tax_ids'): raise ValidationError(_("Recursion found for tax '%s'.") % (tax.name,)) - if not all(child.type_tax_use in ('none', tax.type_tax_use) for child in tax.children_tax_ids): - raise ValidationError(_('The application scope of taxes in a group must be either the same as the group or left empty.')) - if not all(child.tax_scope == tax.tax_scope for child in tax.children_tax_ids): + if any(child.type_tax_use not in ('none', tax.type_tax_use) or child.tax_scope != tax.tax_scope for child in tax.children_tax_ids): raise ValidationError(_('The application scope of taxes in a group must be either the same as the group or left empty.')) @api.constrains('company_id') diff --git a/addons/google_calendar/utils/google_event.py b/addons/google_calendar/utils/google_event.py index fc962a1d073..9ebbd5ed7b2 100644 --- a/addons/google_calendar/utils/google_event.py +++ b/addons/google_calendar/utils/google_event.py @@ -167,8 +167,8 @@ class GoogleEvent(abc.Set): return self.filter(lambda e: e._odoo_id) def _get_model(self, env): - if all([e.is_recurrence() for e in self]): + if all(e.is_recurrence() for e in self): return env['calendar.recurrence'] - if all([not e.is_recurrence() for e in self]): + if all(not e.is_recurrence() for e in self): return env['calendar.event'] raise TypeError("Mixing Google events and Google recurrences") diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index fd16ee2b266..5ff2a65164f 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -846,7 +846,7 @@ class HrExpenseSheet(models.Model): @api.constrains('expense_line_ids', 'company_id') def _check_expense_lines_company(self): for sheet in self: - if not all(expense.company_id == sheet.company_id for expense in sheet.expense_line_ids): + if any(expense.company_id != sheet.company_id for expense in sheet.expense_line_ids): raise ValidationError(_('An expense report must contain only lines from the same company.')) @api.model diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index b5a1dd6c81c..d3a1ea39089 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -157,7 +157,7 @@ class AccountAnalyticLine(models.Model): if partner_id: vals['partner_id'] = partner_id # set timesheet UoM from the AA company (AA implies uom) - if 'product_uom_id' not in vals and all([v in vals for v in ['account_id', 'project_id']]): # project_id required to check this is timesheet flow + if 'product_uom_id' not in vals and all(v in vals for v in ['account_id', 'project_id']): # project_id required to check this is timesheet flow analytic_account = self.env['account.analytic.account'].sudo().browse(vals['account_id']) vals['product_uom_id'] = analytic_account.company_id.project_time_mode_id.id return vals diff --git a/addons/mail/models/ir_model.py b/addons/mail/models/ir_model.py index 9b7589318e6..386ff3760c9 100644 --- a/addons/mail/models/ir_model.py +++ b/addons/mail/models/ir_model.py @@ -66,13 +66,13 @@ class IrModel(models.Model): def write(self, vals): if self and ('is_mail_thread' in vals or 'is_mail_activity' in vals or 'is_mail_blacklist' in vals): - if not all(rec.state == 'manual' for rec in self): + if any(rec.state != 'manual' for rec in self): raise UserError(_('Only custom models can be modified.')) - if 'is_mail_thread' in vals and not all(rec.is_mail_thread <= vals['is_mail_thread'] for rec in self): + if 'is_mail_thread' in vals and any(rec.is_mail_thread > vals['is_mail_thread'] for rec in self): raise UserError(_('Field "Mail Thread" cannot be changed to "False".')) - if 'is_mail_activity' in vals and not all(rec.is_mail_activity <= vals['is_mail_activity'] for rec in self): + if 'is_mail_activity' in vals and any(rec.is_mail_activity > vals['is_mail_activity'] for rec in self): raise UserError(_('Field "Mail Activity" cannot be changed to "False".')) - if 'is_mail_blacklist' in vals and not all(rec.is_mail_blacklist <= vals['is_mail_blacklist'] for rec in self): + if 'is_mail_blacklist' in vals and any(rec.is_mail_blacklist > vals['is_mail_blacklist'] for rec in self): raise UserError(_('Field "Mail Blacklist" cannot be changed to "False".')) res = super(IrModel, self).write(vals) self.flush() diff --git a/addons/microsoft_calendar/utils/microsoft_event.py b/addons/microsoft_calendar/utils/microsoft_event.py index cd7ee255daa..2234b1ad6a9 100644 --- a/addons/microsoft_calendar/utils/microsoft_event.py +++ b/addons/microsoft_calendar/utils/microsoft_event.py @@ -216,8 +216,8 @@ class MicrosoftEvent(abc.Set): return self.filter(lambda e: e._odoo_id) def _get_model(self, env): - if all([e.is_recurrence() for e in self]): + if all(e.is_recurrence() for e in self): return env['calendar.recurrence'] - if all([not e.is_recurrence() for e in self]): + if all(not e.is_recurrence() for e in self): return env['calendar.event'] raise TypeError("Mixing Microsoft events and Microsoft recurrences") diff --git a/addons/project/models/project.py b/addons/project/models/project.py index bc415334515..dca8b1407ef 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1030,7 +1030,7 @@ class Task(models.Model): days = list(DAYS.keys()) week_start = fields.Datetime.today().weekday() - if all([d in default_fields for d in days]): + if all(d in default_fields for d in days): vals[days[week_start]] = True if 'repeat_day' in default_fields: vals['repeat_day'] = str(fields.Datetime.today().day) diff --git a/addons/project/wizard/project_delete_wizard.py b/addons/project/wizard/project_delete_wizard.py index 9dff0454549..00bb4aa5ff4 100644 --- a/addons/project/wizard/project_delete_wizard.py +++ b/addons/project/wizard/project_delete_wizard.py @@ -14,7 +14,7 @@ class ProjectDelete(models.TransientModel): def _compute_projects_archived(self): for wizard in self.with_context(active_test=False): - wizard.projects_archived = all([not p.active for p in wizard.project_ids]) + wizard.projects_archived = all(not p.active for p in wizard.project_ids) def _compute_task_count(self): for wizard in self: diff --git a/addons/purchase_requisition/models/purchase_requisition.py b/addons/purchase_requisition/models/purchase_requisition.py index 24e2f30500c..3ee35704423 100644 --- a/addons/purchase_requisition/models/purchase_requisition.py +++ b/addons/purchase_requisition/models/purchase_requisition.py @@ -114,7 +114,7 @@ class PurchaseRequisition(models.Model): def action_in_progress(self): self.ensure_one() - if not all(obj.line_ids for obj in self): + if not self.line_ids: raise UserError(_("You cannot confirm agreement '%s' because there is no product line.", self.name)) if self.type_id.quantity_copy == 'none' and self.vendor_id: for requisition_line in self.line_ids: diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index 095b5f9ccc5..7e46b06b4fb 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -54,7 +54,7 @@ class PurchaseOrder(models.Model): @api.depends('picking_ids', 'picking_ids.state') def _compute_is_shipped(self): for order in self: - if order.picking_ids and all([x.state in ['done', 'cancel'] for x in order.picking_ids]): + if order.picking_ids and all(x.state in ['done', 'cancel'] for x in order.picking_ids): order.is_shipped = True else: order.is_shipped = False diff --git a/addons/sale_mrp/models/sale.py b/addons/sale_mrp/models/sale.py index b1cd9004b04..22894b08b30 100644 --- a/addons/sale_mrp/models/sale.py +++ b/addons/sale_mrp/models/sale.py @@ -74,7 +74,7 @@ class SaleOrderLine(models.Model): # the products for this PO will set the qty_delivered. We might need to check the # state of all PO as well... but sale_mrp doesn't depend on purchase. if dropship: - if order_line.move_ids and all([m.state == 'done' for m in order_line.move_ids]): + if order_line.move_ids and all(m.state == 'done' for m in order_line.move_ids): order_line.qty_delivered = order_line.product_uom_qty else: order_line.qty_delivered = 0.0 @@ -91,7 +91,7 @@ class SaleOrderLine(models.Model): # when the product sold is made only of kits. In this case, the BOM of the stock moves # do not correspond to the product sold => no relevant BOM. elif boms: - if all([m.state == 'done' for m in order_line.move_ids]): + if all(m.state == 'done' for m in order_line.move_ids): order_line.qty_delivered = order_line.product_uom_qty else: order_line.qty_delivered = 0.0 diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index f411c3d98af..fd2f7d6681f 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -463,7 +463,7 @@ class Product(models.Model): def action_open_quants(self): domain = [('product_id', 'in', self.ids)] hide_location = not self.user_has_groups('stock.group_stock_multi_locations') - hide_lot = all([product.tracking == 'none' for product in self]) + hide_lot = all(product.tracking == 'none' for product in self) self = self.with_context( hide_location=hide_location, hide_lot=hide_lot, no_at_date=True, search_default_on_hand=True, diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 308415f0ecc..ae809c5acf0 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1595,7 +1595,7 @@ class StockMove(models.Model): else: if move.procure_method == 'make_to_order' and not move.move_orig_ids: move.state = 'waiting' - elif move.move_orig_ids and not all(orig.state in ('done', 'cancel') for orig in move.move_orig_ids): + elif move.move_orig_ids and any(orig.state not in ('done', 'cancel') for orig in move.move_orig_ids): move.state = 'waiting' else: move.state = 'confirmed' diff --git a/addons/website/models/mixins.py b/addons/website/models/mixins.py index bfbeaae6d56..5287e594a6c 100644 --- a/addons/website/models/mixins.py +++ b/addons/website/models/mixins.py @@ -170,13 +170,13 @@ class WebsitePublishedMixin(models.AbstractModel): is_publish_modified = any( [set(v.keys()) & {'is_published', 'website_published'} for v in vals_list] ) - if is_publish_modified and not all(record.can_publish for record in records): + if is_publish_modified and any(not record.can_publish for record in records): raise AccessError(self._get_can_publish_error_message()) return records def write(self, values): - if 'is_published' in values and not all(record.can_publish for record in self): + if 'is_published' in values and any(not record.can_publish for record in self): raise AccessError(self._get_can_publish_error_message()) return super(WebsitePublishedMixin, self).write(values) diff --git a/addons/website_event/views/event_templates_page_registration.xml b/addons/website_event/views/event_templates_page_registration.xml index 6375b55c293..dddaf61e59b 100644 --- a/addons/website_event/views/event_templates_page_registration.xml +++ b/addons/website_event/views/event_templates_page_registration.xml @@ -140,7 +140,7 @@ -