summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilliam <wan@odoo.com>2020-06-02 11:55:26 +0000
committerwilliam <wan@odoo.com>2020-08-05 11:57:09 +0000
commit276ba8e90c87f8294286f915508766761a58d1e2 (patch)
treed8f316e9114cd94e9b5f7043ae45999fc412550f
parent2b4981ec1f2eb50b374fe0dd2e9b2562ae1557f6 (diff)
[FIX] account: do not store account internal type on aml
It was removed here https://github.com/odoo/odoo/pull/32303 but readded later. We still don't want it for the same reasons. Having it on related (non stored) is enough.
-rw-r--r--addons/account/models/account_move.py2
-rw-r--r--addons/account/models/account_payment.py23
-rw-r--r--addons/sale/models/sales_team.py5
3 files changed, 16 insertions, 14 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 888406b7ed5..4c5e0046e26 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -2722,7 +2722,7 @@ class AccountMoveLine(models.Model):
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
check_company=True,
tracking=True)
- account_internal_type = fields.Selection(related='account_id.user_type_id.type', string="Internal Type", store=True, readonly=True)
+ account_internal_type = fields.Selection(related='account_id.user_type_id.type', string="Internal Type", readonly=True)
account_root_id = fields.Many2one(related='account_id.root_id', string="Account Root", store=True, readonly=True)
sequence = fields.Integer(default=10)
name = fields.Text(string='Label', tracking=True)
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index fa0470265ed..c3ece2d28f6 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -439,16 +439,17 @@ class AccountPayment(models.Model):
FROM account_payment payment
JOIN account_move move ON move.id = payment.move_id
JOIN account_move_line line ON line.move_id = move.id
- JOIN account_partial_reconcile part ON
- part.debit_move_id = line.id
- OR
+ JOIN account_partial_reconcile part ON
+ part.debit_move_id = line.id
+ OR
part.credit_move_id = line.id
- JOIN account_move_line counterpart_line ON
+ JOIN account_move_line counterpart_line ON
part.debit_move_id = counterpart_line.id
- OR
+ OR
part.credit_move_id = counterpart_line.id
JOIN account_move invoice ON invoice.id = counterpart_line.move_id
- WHERE line.account_internal_type IN ('receivable', 'payable')
+ JOIN account_account account ON account.id = line.account_id
+ WHERE account.internal_type IN ('receivable', 'payable')
AND line.id != counterpart_line.id
AND invoice.move_type in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')
GROUP BY payment.id
@@ -469,13 +470,13 @@ class AccountPayment(models.Model):
JOIN account_journal journal ON journal.id = move.journal_id
JOIN account_move_line line ON line.move_id = move.id
JOIN account_account account ON account.id = line.account_id
- JOIN account_partial_reconcile part ON
- part.debit_move_id = line.id
- OR
+ JOIN account_partial_reconcile part ON
+ part.debit_move_id = line.id
+ OR
part.credit_move_id = line.id
- JOIN account_move_line counterpart_line ON
+ JOIN account_move_line counterpart_line ON
part.debit_move_id = counterpart_line.id
- OR
+ OR
part.credit_move_id = counterpart_line.id
WHERE (account.id = journal.payment_debit_account_id OR account.id = journal.payment_credit_account_id)
AND line.id != counterpart_line.id
diff --git a/addons/sale/models/sales_team.py b/addons/sale/models/sales_team.py
index dde443f25ed..da500582a2b 100644
--- a/addons/sale/models/sales_team.py
+++ b/addons/sale/models/sales_team.py
@@ -78,7 +78,8 @@ class CrmTeam(models.Model):
move.team_id AS team_id,
SUM(-line.balance) AS amount_untaxed_signed
FROM account_move move
- LEFT JOIN account_move_line line ON line.move_id = move.id
+ JOIN account_move_line line ON line.move_id = move.id
+ JOIN account_account account ON account.id = line.account_id
WHERE move.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')
AND move.payment_state IN ('in_payment', 'paid')
AND move.state = 'posted'
@@ -86,7 +87,7 @@ class CrmTeam(models.Model):
AND move.date BETWEEN %s AND %s
AND line.tax_line_id IS NULL
AND line.display_type IS NULL
- AND line.account_internal_type NOT IN ('receivable', 'payable')
+ AND account.internal_type NOT IN ('receivable', 'payable')
GROUP BY move.team_id
'''
today = fields.Date.today()