Skip to content

Commit

Permalink
[FIX] account_factoring_receivable_balance: remove item_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
dreispt committed Jul 16, 2024
1 parent 210df92 commit 24a95cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
16 changes: 6 additions & 10 deletions account_factoring_receivable_balance/models/subrogation_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class SubrogationReceipt(models.Model):
comodel_name="account.move.line",
inverse_name="subrogation_id",
)
item_ids = fields.Many2many(
comodel_name="account.move.line",
)

@api.constrains("factor_journal_id", "state", "company_id")
def _check_draft_per_journal(self):
Expand Down Expand Up @@ -147,9 +144,6 @@ def _get_factor_lines(self):
def action_compute_lines(self):
self.ensure_one()
self.line_ids.write({"subrogation_id": False})
lines = self._get_factor_lines()
lines.write({"subrogation_id": self.id})
vals = {"item_ids": [(6, 0, lines.ids)]}
if not self.statement_date:
statement = self.env["account.bank.statement"].search(
[
Expand All @@ -160,10 +154,12 @@ def action_compute_lines(self):
order="date DESC",
)
if statement:
vals["statement_date"] = statement.date
if self.item_ids:
vals["balance"] = sum(self.item_ids.mapped("amount_currency"))
return self.write(vals)
self.statement_date = statement.date
lines = self._get_factor_lines()
lines.write({"subrogation_id": self.id})
if self.line_ids:
self.balance = sum(self.line_ids.mapped("amount_currency"))
return True

def _get_bank_journal(self, factor_type, currency=None):
"""Get matching bank journal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
id="action_compute_lines_highlighted"
type="object"
string="Compute"
invisible="not(state == 'draft' and not item_ids)"
invisible="not(state == 'draft' and not line_ids)"
class="oe_highlight"
/>
<button
name="action_compute_lines"
id="action_compute_lines"
type="object"
string="Compute"
invisible="not(state == 'draft' and item_ids)"
invisible="not(state == 'draft' and line_ids)"
/>
<button
name="action_confirm"
type="object"
string="Confirm"
invisible="not(state =='draft' and item_ids)"
invisible="not(state =='draft' and line_ids)"
class="oe_highlight"
/>
<button
Expand All @@ -39,7 +39,7 @@
<button
name="action_goto_moves"
type="object"
invisible="not item_ids"
invisible="not line_ids"
string="See account moves"
/>
-->
Expand Down Expand Up @@ -108,7 +108,7 @@
<notebook>
<page name="lines" string="Lines">>

<field name="item_ids" colspan="4">
<field name="line_ids" colspan="4" readonly="state != 'draft'">
<tree>
<field name="id" optional="hide" />
<field name="create_date" optional="hide" />
Expand Down

0 comments on commit 24a95cb

Please sign in to comment.