Skip to content

Commit

Permalink
UPD _compute_use_factor
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudelva committed Nov 5, 2024
1 parent 586ae7a commit b202530
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions account_factoring_receivable_balance/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models


class AccountMove(models.Model):
Expand All @@ -21,14 +21,18 @@ class AccountMove(models.Model):
store=False,
)

@api.depends(
"factor_journal_id",
"factor_journal_id.factor_start_date",
"factor_journal_id.factor_invoice_journal_ids",
)
def _compute_use_factor(self):
for rec in self:
use_factor = False
rec = rec.with_company(rec.company_id.id)
factor_journal = rec.commercial_partner_id.factor_journal_id
if factor_journal:
if rec.factor_journal_id:
# TODO replace by adhoc odoo method : domain to python expression
domain = factor_journal._get_domain_for_factor()
domain = rec.factor_journal_id._get_domain_for_factor()
domain.extend([("id", "=", rec.id), ("skip_factor", "=", False)])
if rec.search(domain):
use_factor = True
Expand Down
10 changes: 10 additions & 0 deletions account_factoring_receivable_balance/views/account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
</field>
</record>

<record id="view_move_tree" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_out_invoice_tree" />
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="use_factor" optional="hide" />
</field>
</field>
</record>

<record id="view_account_invoice_filter" model="ir.ui.view">
<field name="name">account.invoice.filter</field>
<field name="model">account.move</field>
Expand Down

0 comments on commit b202530

Please sign in to comment.