Skip to content

Commit

Permalink
Clean deletion of analytic_tag_id setting parameter and pre-commit co…
Browse files Browse the repository at this point in the history
…rrections
  • Loading branch information
NoeBerdoz committed Jul 11, 2024
1 parent 6b1ae79 commit daae4db
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 50 deletions.
1 change: 0 additions & 1 deletion account_analytic_compassion/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
],
"data": [
"views/product_view.xml",
"views/res_config_setting_view.xml",
"views/account_asset_view.xml",
],
"demo": ["analytic_account_data.xml"],
Expand Down
23 changes: 0 additions & 23 deletions account_analytic_compassion/views/res_config_setting_view.xml

This file was deleted.

13 changes: 6 additions & 7 deletions account_offbalance_sponsorship/models/account_bank_statement.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from odoo import _, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
from odoo import models


class AccountBankStatementLine(models.Model):

_inherit = "account.bank.statement.line"

def button_undo_reconciliation(self):
"""remove all income allocation from the payment move
"""
return super(AccountBankStatementLine, self.with_context(bypass_offbalance_operations=True)).button_undo_reconciliation()
"""remove all income allocation from the payment move"""
return super(
AccountBankStatementLine,
self.with_context(bypass_offbalance_operations=True),
).button_undo_reconciliation()
63 changes: 46 additions & 17 deletions account_offbalance_sponsorship/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,41 @@ def get_account_offbalance(self, company):
)

def reconcile(self):
#check if there is a currency diff and relaod the invoice with the rate received
filtered_item = self.filtered(lambda l: l.journal_id != self.company_id.currency_exchange_journal_id)
# check if there is a currency diff
# and reload the invoice with the rate received
filtered_item = self.filtered(
lambda line: line.journal_id != self.company_id.currency_exchange_journal_id
)
total = total_curr = 0
for l in filtered_item:
total = l.debit - l.credit + total
total_curr = l.amount_currency + total_curr
for line in filtered_item:
total = line.debit - line.credit + total
total_curr = line.amount_currency + total_curr
if total != 0 and total_curr == 0:
inv_to_refresh = filtered_item.filtered(lambda l: l.move_id.journal_id.type == 'sale').move_id
nr = filtered_item.filtered(lambda l: l.move_id.journal_id.type != 'sale')
new_rate = sum(n.amount_currency for n in nr) / sum(n.debit - n.credit for n in nr)
inv_to_refresh = filtered_item.filtered(
lambda line: line.move_id.journal_id.type == "sale"
).move_id
nr = filtered_item.filtered(
lambda line: line.move_id.journal_id.type != "sale"
)
new_rate = sum(n.amount_currency for n in nr) / sum(
n.debit - n.credit for n in nr
)
inv_to_refresh.button_draft()
for line in inv_to_refresh.line_ids.with_context(check_move_validity=False):
line.debit = abs(line.amount_currency / new_rate) if line.amount_currency > 0 else 0
line.credit = abs(line.amount_currency / new_rate) if line.amount_currency < 0 else 0
line.debit = (
abs(line.amount_currency / new_rate)
if line.amount_currency > 0
else 0
)
line.credit = (
abs(line.amount_currency / new_rate)
if line.amount_currency < 0
else 0
)
inv_to_refresh.action_post()
#reconcile
# reconcile
res = super().reconcile()
#check if the reconcile is regarding off balance moves
# check if the reconcile is regarding off balance moves
(
account_offbalance_receivable,
account_offbalance_asset,
Expand All @@ -76,10 +93,16 @@ def remove_off_balance_lines(self, inv_move, pmt_move):
off_rec, off_ass = rec_lines.get_account_offbalance(inv_move.company_id)
if rec_lines.filtered(lambda r: r.account_id.id == off_rec):
for pmt in pmt_move:
pmt.with_context(skip_account_move_synchronization=True).write({"state": "draft"})
pmt.with_context(skip_account_move_synchronization=True).write(
{"state": "draft"}
)
ids_to_unlink = self.env["account.move.line"]
for move_name in inv_move.mapped("name"):
ids_to_unlink += rec_lines.filtered(lambda l: l.account_id.id != off_rec and l.name == move_name)
ids_to_unlink += rec_lines.filtered(
lambda line, current_name=move_name: line.account_id.id
!= off_rec
and line.name == current_name
)
pmt.line_ids -= ids_to_unlink
pmt.write({"state": "posted"})

Expand Down Expand Up @@ -156,8 +179,14 @@ def add_off_balance_lines(

def remove_move_reconcile(self):
"""Undo a reconciliation"""
if not self._context.get('bypass_offbalance_operations'):
inv_move = self.matched_debit_ids.debit_move_id.move_id+self.matched_credit_ids.debit_move_id.move_id
pmt_move = self.matched_credit_ids.credit_move_id.move_id+self.matched_debit_ids.credit_move_id.move_id
if not self._context.get("bypass_offbalance_operations"):
inv_move = (
self.matched_debit_ids.debit_move_id.move_id
+ self.matched_credit_ids.debit_move_id.move_id
)
pmt_move = (
self.matched_credit_ids.credit_move_id.move_id
+ self.matched_debit_ids.credit_move_id.move_id
)
self.remove_off_balance_lines(inv_move, pmt_move)
super().remove_move_reconcile()
9 changes: 7 additions & 2 deletions recurring_contract/models/contract_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def _generate_invoices(self, invoicer):
starting_offset, group.advance_billing_months + 1, group.month_interval
):
# Calculate the current invoicing date for this offset
current_invoicing_date = invoicing_date + relativedelta(months=invoice_offset)
current_invoicing_date = invoicing_date + relativedelta(
months=invoice_offset
)

# Check if invoice generation should be skipped for this date
if group._should_skip_invoice_generation(current_invoicing_date):
Expand Down Expand Up @@ -331,7 +333,10 @@ def _should_skip_invoice_generation(self, invoicing_date):
]
)
# Check for contract group suspension
is_suspended = self.invoice_suspended_until and self.invoice_suspended_until > invoicing_date
is_suspended = (
self.invoice_suspended_until
and self.invoice_suspended_until > invoicing_date
)

return bool(dangling_invoices) or is_suspended

Expand Down

0 comments on commit daae4db

Please sign in to comment.