diff options
| author | Raphael Collet <rco@odoo.com> | 2020-04-07 13:51:30 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-05-18 09:51:43 +0000 |
| commit | ea3e39506a2b360545ec0cd1d3235e69ad16ea6c (patch) | |
| tree | 9d103c7a40911c988e1a3cbecfd8d6a76a3a9a85 /addons/account | |
| parent | 2e56191c8b86d05bbce17790de8a4732c0478013 (diff) | |
[IMP] models: use slots for BaseModel
This restricts the attributes of a BaseModel instance to `env`, `_ids`
and `_prefetch_ids`. This way, one can only assign fields on a record;
other assignments are programming errors.
This also reduces the memory footprint of records from 168 to 64 bytes
(-62%), and makes their instanciation faster.
closes odoo/odoo#51075
Related: odoo/enterprise#10529
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'addons/account')
| -rw-r--r-- | addons/account/models/account_bank_statement.py | 2 | ||||
| -rw-r--r-- | addons/account/tests/test_account_bank_statement.py | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 461b40b33e8..7607712215e 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -1252,7 +1252,7 @@ class AccountBankStatementLine(models.Model): # Update the payment date to match the current bank statement line's date. if counterpart_line.payment_id: - counterpart_line.payment_id.payment_date = self.date + counterpart_line.payment_id.date = self.date # ------------------------------------------------------------------------- # BUSINESS METHODS diff --git a/addons/account/tests/test_account_bank_statement.py b/addons/account/tests/test_account_bank_statement.py index 6cca0200e57..3af6a02fa0f 100644 --- a/addons/account/tests/test_account_bank_statement.py +++ b/addons/account/tests/test_account_bank_statement.py @@ -1249,15 +1249,15 @@ class TestAccountBankStatement(TestAccountBankStatementCommon): test_line_1 = test_move.line_ids.filtered(lambda line: line.name == 'test line 1') test_line_2 = test_move.line_ids.filtered(lambda line: line.name == 'test line 2') - def _prepare_reconciliation_with_payments(lines_vals_list): - statement_line_wo_patch = self.env['account.bank.statement.line'].browse(self.statement_line.id) - return statement_line_wo_patch._prepare_reconciliation(lines_vals_list, create_payment_for_invoice=True) - - with patch.object( - self.statement_line, - '_prepare_reconciliation', - lambda *args, **kwargs: _prepare_reconciliation_with_payments(*args) - ): + statement_line = self.statement_line + StatementLine_prepare_reconciliation = type(statement_line)._prepare_reconciliation + + def _prepare_reconciliation(self, lines_vals_list, create_payment_for_invoice=False): + if self == statement_line: + create_payment_for_invoice = True + return StatementLine_prepare_reconciliation(self, lines_vals_list, create_payment_for_invoice) + + with patch.object(type(statement_line), '_prepare_reconciliation', _prepare_reconciliation): self.statement_line.reconcile([ {'id': test_line_1.id, 'balance': -50.0}, {'id': test_line_2.id}, |
