[REF] stock, stock_account: indices for fast move unlink
Stock moves records can be unlinked in some cases, for example when confirming a move containing a kit, the original move is unlinked and replaced by the moves of the components of the kit. This commit adds two indices to accelerate the unlink of stock move records. The fields were the indices are added are foreign key on stock move, and postgres checks the foreign keys of the rows before deleting them. closes odoo/odoo#44426 X-original-commit: e34a176dd438fe0f4f1a384889bfdc196f2c4b4f Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
@@ -141,7 +141,9 @@ class StockMove(models.Model):
|
||||
inventory_id = fields.Many2one('stock.inventory', 'Inventory', check_company=True)
|
||||
move_line_ids = fields.One2many('stock.move.line', 'move_id')
|
||||
move_line_nosuggest_ids = fields.One2many('stock.move.line', 'move_id', domain=['|', ('product_qty', '=', 0.0), ('qty_done', '!=', 0.0)])
|
||||
origin_returned_move_id = fields.Many2one('stock.move', 'Origin return move', copy=False, help='Move that created the return move', check_company=True)
|
||||
origin_returned_move_id = fields.Many2one(
|
||||
'stock.move', 'Origin return move', copy=False, index=True,
|
||||
help='Move that created the return move', check_company=True)
|
||||
returned_move_ids = fields.One2many('stock.move', 'origin_returned_move_id', 'All returned moves', help='Optional: all returned moves created from this move')
|
||||
reserved_availability = fields.Float(
|
||||
'Quantity Reserved', compute='_compute_reserved_availability',
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo import fields, models, api, _
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
stock_move_id = fields.Many2one('stock.move', string='Stock Move')
|
||||
stock_move_id = fields.Many2one('stock.move', string='Stock Move', index=True)
|
||||
stock_valuation_layer_ids = fields.One2many('stock.valuation.layer', 'account_move_id', string='Stock Valuation Layer')
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -28,7 +28,7 @@ class StockValuationLayer(models.Model):
|
||||
description = fields.Char('Description', readonly=True)
|
||||
stock_valuation_layer_id = fields.Many2one('stock.valuation.layer', 'Linked To', readonly=True, check_company=True)
|
||||
stock_valuation_layer_ids = fields.One2many('stock.valuation.layer', 'stock_valuation_layer_id')
|
||||
stock_move_id = fields.Many2one('stock.move', 'Stock Move', readonly=True, check_company=True)
|
||||
stock_move_id = fields.Many2one('stock.move', 'Stock Move', readonly=True, check_company=True, index=True)
|
||||
account_move_id = fields.Many2one('account.move', 'Journal Entry', readonly=True, check_company=True)
|
||||
|
||||
def init(self):
|
||||
|
||||
Reference in New Issue
Block a user