-
-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathaccount_invoice.py
More file actions
34 lines (27 loc) · 1.03 KB
/
account_invoice.py
File metadata and controls
34 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright 2021 Sergio Teruel <sergio.teruel@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class AccountMove(models.Model):
_inherit = "account.move"
def _get_margin_applicable_lines(self):
invoice_lines = super()._get_margin_applicable_lines()
return invoice_lines.filtered(
lambda x: not any(x.sale_line_ids.mapped("is_downpayment"))
)
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
@api.depends("purchase_price", "price_subtotal")
def _compute_margin(self):
invoice_lines_with_downpayment = self.filtered(
lambda x: any(x.sale_line_ids.mapped("is_downpayment"))
)
invoice_lines_with_downpayment.update(
{
"margin": 0.0,
"margin_signed": 0.0,
"margin_percent": 0.0,
}
)
return super(
AccountMoveLine, self - invoice_lines_with_downpayment
)._compute_margin()