Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMP factor: add store attribute and filter #22

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions account_factoring_receivable_balance/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,11 @@ msgstr "Montant non taxé"
msgid "Use Factor"
msgstr "Utiliser le factor"

#. module: account_factoring_receivable_balance
#: model_terms:ir.ui.view,arch_db:account_factoring_receivable_balance.view_account_invoice_filter
msgid "Use factor"
msgstr "Utiliser le factor"

#. module: account_factoring_receivable_balance
#: model:ir.model.fields,help:account_factoring_receivable_balance.field_res_company__factor_config_currency_id
msgid "Use to configure account and journal"
Expand Down
13 changes: 9 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 @@ -13,21 +13,26 @@ class AccountMove(models.Model):
use_factor = fields.Boolean(
compute="_compute_use_factor",
help="Depending on partner factor settings and skip factor field",
store=True,
)
factor_journal_id = fields.Many2one(
comodel_name="account.journal",
related="commercial_partner_id.factor_journal_id",
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
26 changes: 26 additions & 0 deletions account_factoring_receivable_balance/views/account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,30 @@
</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>
<field name="inherit_id" ref="account.view_account_invoice_filter" />
<field name="arch" type="xml">
<filter name="to_check" position="after">
<separator />
<filter
string="Use factor"
name="use_factor"
domain="[('use_factor','=',True)]"
/>
<separator />
</filter>
</field>
</record>
</odoo>
Loading