diff options
| author | Adrian Torres <adt@odoo.com> | 2019-09-23 11:52:06 +0000 |
|---|---|---|
| committer | Adrian Torres <adt@odoo.com> | 2020-03-23 15:14:10 +0000 |
| commit | 9befa3d245f058f7b687509bec88160986b2b877 (patch) | |
| tree | a4b60ecfd5950c9688f09d31dc5243c825cbc302 /addons | |
| parent | 0d16e7331cc859a6f060eeed8ea2b53801c08ca6 (diff) | |
[FIX] *: adapt code for resolve_2many_commands removal
This code adapts all business code instances of calls to
`resolve_2many_commands` and replaces them by calls to `new` which
returns a record-like object whose api is more familiar than the
`resolve_2many_commands` api.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/models/account_move.py | 9 | ||||
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 4 | ||||
| -rw-r--r-- | addons/sale/models/payment.py | 4 | ||||
| -rw-r--r-- | addons/stock/models/stock_warehouse.py | 5 | ||||
| -rw-r--r-- | addons/website_forum/models/forum.py | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 2b7c8352f3e..bde55d46f4c 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3253,8 +3253,8 @@ class AccountMoveLine(models.Model): if move.is_invoice(include_receipts=True): currency = move.currency_id partner = self.env['res.partner'].browse(vals.get('partner_id')) - taxes = self.resolve_2many_commands('tax_ids', vals.get('tax_ids', []), fields=['id']) - tax_ids = set(tax['id'] for tax in taxes) + taxes = self.new({'tax_ids': vals.get('tax_ids', [])}).tax_ids + tax_ids = set(taxes.ids) taxes = self.env['account.tax'].browse(tax_ids) # Ensure consistency between accounting & business fields. @@ -3322,8 +3322,7 @@ class AccountMoveLine(models.Model): tax = repartition_line.invoice_tax_id or repartition_line.refund_tax_id vals['tax_exigible'] = tax.tax_exigibility == 'on_invoice' elif vals.get('tax_ids'): - tax_ids = [v['id'] for v in self.resolve_2many_commands('tax_ids', vals['tax_ids'], fields=['id'])] - taxes = self.env['account.tax'].browse(tax_ids).flatten_taxes_hierarchy() + taxes = self.new({'tax_ids': vals['tax_ids']}).tax_ids.flatten_taxes_hierarchy() vals['tax_exigible'] = not any(tax.tax_exigibility == 'on_payment' for tax in taxes) lines = super(AccountMoveLine, self).create(vals_list) @@ -3346,7 +3345,7 @@ class AccountMoveLine(models.Model): return line[field_name].id != vals[field_name] if field.type in ('one2many', 'many2many'): current_ids = set(line[field_name].ids) - after_write_ids = set(r['id'] for r in line.resolve_2many_commands(field_name, vals[field_name], fields=['id'])) + after_write_ids = set(line.new({field_name: vals[field_name]})[field_name].ids) return current_ids != after_write_ids if field.type == 'monetary' and line[field.currency_field]: return not line[field.currency_field].is_zero(line[field_name] - vals[field_name]) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 6453965ff5f..afe2a1fe65b 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -865,8 +865,8 @@ class PaymentTransaction(models.Model): @api.model def _compute_reference_prefix(self, values): if values and values.get('invoice_ids'): - many_list = self.resolve_2many_commands('invoice_ids', values['invoice_ids'], fields=['name']) - return ','.join(dic['name'] for dic in many_list) + invoices = self.new({'invoice_ids': values['invoice_ids']}).invoice_ids + return ','.join(invoices.mapped('name')) return None @api.model diff --git a/addons/sale/models/payment.py b/addons/sale/models/payment.py index 59689215508..9000db0caea 100644 --- a/addons/sale/models/payment.py +++ b/addons/sale/models/payment.py @@ -138,8 +138,8 @@ class PaymentTransaction(models.Model): def _compute_reference_prefix(self, values): prefix = super(PaymentTransaction, self)._compute_reference_prefix(values) if not prefix and values and values.get('sale_order_ids'): - many_list = self.resolve_2many_commands('sale_order_ids', values['sale_order_ids'], fields=['name']) - return ','.join(dic['name'] for dic in many_list) + sale_orders = self.new({'sale_order_ids': values['sale_order_ids']}).sale_order_ids + return ','.join(sale_orders.mapped('name')) return prefix def action_view_sales_orders(self): diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index 39e5d9e34ee..930cbe05ff3 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -146,8 +146,9 @@ class Warehouse(models.Model): warehouses._update_reception_delivery_resupply(vals.get('reception_steps'), vals.get('delivery_steps')) if vals.get('resupply_wh_ids') and not vals.get('resupply_route_ids'): - resupply_whs = self.resolve_2many_commands('resupply_wh_ids', vals['resupply_wh_ids']) - new_resupply_whs = self.browse([wh['id'] for wh in resupply_whs]) + new_resupply_whs = self.new({ + 'resupply_wh_ids': vals['resupply_wh_ids'] + }).resupply_wh_ids._origin old_resupply_whs = {warehouse.id: warehouse.resupply_wh_ids for warehouse in warehouses} # If another partner assigned diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 7f862506369..5aba126395d 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -484,7 +484,7 @@ class Post(models.Model): tag_ids = False if 'tag_ids' in vals: - tag_ids = set(tag.get('id') for tag in self.resolve_2many_commands('tag_ids', vals['tag_ids'])) + tag_ids = set(self.new({'tag_ids': vals['tag_ids']}).tag_ids.ids) for post in self: if 'state' in vals: |
