Skip to content
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
2 changes: 1 addition & 1 deletion gift_compassion/wizards/generate_gift_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate_invoice(self, due_date=None):
birthday_gift_type = self.env.ref(
"sponsorship_compassion.gift_type_birthday"
)
gift_vals = {"sponsorship_gift_type_id": birthday_gift_type.id}
gift_vals = {"gift_type_id": birthday_gift_type.id}
gift_date = self.compute_date_birthday_invoice(
contract_id.child_id.birthdate
)
Expand Down
15 changes: 0 additions & 15 deletions sponsorship_compassion/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ msgstr "Jährliches Weihnachtsgeschenk"
msgid "BVR Ref"
msgstr "BVR Ref"

#. module: sponsorship_compassion
#: model:ir.cron,cron_name:sponsorship_compassion.recurring_invoicer_cron
msgid "Base: Auto-vacuum internal data"
msgstr "Basis: Auto-Vacuum für interne Daten"

#. module: sponsorship_compassion
#: code:addons/sponsorship_compassion/models/contracts.py:0
#, python-format
Expand Down Expand Up @@ -551,11 +546,6 @@ msgstr "Geschenk generieren"
msgid "Generated Invoices"
msgstr "Erstellte Rechnungen"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_recurring_invoicer_form
msgid "Generated invoices"
msgstr "Erstellte Rechnungen"

#. module: sponsorship_compassion
#: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__sr_total_gift
#: model:ir.model.fields,field_description:sponsorship_compassion.field_res_users__sr_total_gift
Expand Down Expand Up @@ -864,11 +854,6 @@ msgstr "Zuletzt aktualisiert am"
msgid "Last payment"
msgstr "Letzte Zahlung"

#. module: sponsorship_compassion
#: model:ir.cron,name:sponsorship_compassion.recurring_invoicer_cron
msgid "Launch friday invoice generation"
msgstr "Start der Rechnungserstellung am Freitag"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_invoice_automatic_generation
msgid "Launch invoices generation"
Expand Down
12 changes: 0 additions & 12 deletions sponsorship_compassion/i18n/fr_CH.po
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ msgstr "Cadeau de Noël annuel"
msgid "BVR Ref"
msgstr "BVR Ref"

#. module: sponsorship_compassion
#: model:ir.cron,cron_name:sponsorship_compassion.recurring_invoicer_cron
msgid "Base: Auto-vacuum internal data"
msgstr "Base : données internes sur l'aspiration automatique"

#. module: sponsorship_compassion
#: code:addons/sponsorship_compassion/models/contracts.py:0
Expand Down Expand Up @@ -553,10 +549,6 @@ msgstr "Générer une facture cadeau"
msgid "Generated Invoices"
msgstr "Factures générées"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_recurring_invoicer_form
msgid "Generated invoices"
msgstr "Factures générées"

#. module: sponsorship_compassion
#: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__sr_total_gift
Expand Down Expand Up @@ -867,10 +859,6 @@ msgstr "Dernière mise à jour le"
msgid "Last payment"
msgstr "Dernier paiement"

#. module: sponsorship_compassion
#: model:ir.cron,name:sponsorship_compassion.recurring_invoicer_cron
msgid "Launch friday invoice generation"
msgstr "Lancement de la génération de factures le vendredi"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_invoice_automatic_generation
Expand Down
12 changes: 0 additions & 12 deletions sponsorship_compassion/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ msgstr "Regalo di Natale annuale"
msgid "BVR Ref"
msgstr "Rif. BVR"

#. module: sponsorship_compassion
#: model:ir.cron,cron_name:sponsorship_compassion.recurring_invoicer_cron
msgid "Base: Auto-vacuum internal data"
msgstr "Base: Dati interni dell'autovuoto"

#. module: sponsorship_compassion
#: code:addons/sponsorship_compassion/models/contracts.py:0
Expand Down Expand Up @@ -552,10 +548,6 @@ msgstr "Genera un regalo"
msgid "Generated Invoices"
msgstr "Fatture generate"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_recurring_invoicer_form
msgid "Generated invoices"
msgstr "Fatture generate"

#. module: sponsorship_compassion
#: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__sr_total_gift
Expand Down Expand Up @@ -866,10 +858,6 @@ msgstr "Ultimo aggiornamento il"
msgid "Last payment"
msgstr "Ultimo pagamento"

#. module: sponsorship_compassion
#: model:ir.cron,name:sponsorship_compassion.recurring_invoicer_cron
msgid "Launch friday invoice generation"
msgstr "Generazione di fatture per il venerdì di lancio"

#. module: sponsorship_compassion
#: model:ir.ui.menu,name:sponsorship_compassion.menu_invoice_automatic_generation
Expand Down
12 changes: 6 additions & 6 deletions sponsorship_compassion/models/contract_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ def _compute_contains_sponsorship(self):
and s.state not in ("terminated", "cancelled")
)

def _generate_invoices(self, invoicer_id=False):
def _generate_invoices(self):
# Exclude gifts from regular generation
invoicer = super(
result = super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices(invoicer_id)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_birthday")
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_christmas")
self.env.ref("sponsorship_compassion.gift_type_christmas")
)
Comment on lines +36 to 48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The _generate_invoices method overrides the parent method but does not return its result. If other modules or callers expect a return value (such as the generated invoices or a boolean), this implicit None return could cause issues. It is safer to capture and return the result of the super() call.

Suggested change
def _generate_invoices(self):
# Exclude gifts from regular generation
invoicer = super(
super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices(invoicer_id)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_birthday")
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_christmas")
self.env.ref("sponsorship_compassion.gift_type_christmas")
)
def _generate_invoices(self):
# Exclude gifts from regular generation
res = super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
self.env.ref("sponsorship_compassion.gift_type_christmas")
)
return res

return invoicer
return result

def build_inv_line_data(
self, invoicing_date=False, gift_wizard=False, contract_line=False
Expand Down
28 changes: 10 additions & 18 deletions sponsorship_compassion/models/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,9 @@ def _link_unlink_child_to_sponsor(self, vals):
vals.get("correspondent_id") or contract.correspondent_id.id
)

def _generate_gifts(self, invoicer, gift_type):
def _generate_gifts(self, gift_type):
"""Creates the annual gifts for sponsorships that
have set the option for automatic birthday or Christmas gifts creation.
:param invoicer: record of the recurring.invoicer that will create the
invoices
:param gift_type: sponsorship.gift.type record
"""
logger.debug(f"Automatic {gift_type.name} Generation Started.")
Expand Down Expand Up @@ -1153,22 +1151,18 @@ def _generate_gifts(self, invoicer, gift_type):
total = str(len(contracts))
logger.debug(f"Found {total} {gift_type.name} to generate.")
base_description = f"Automatic {gift_type.name}"
gift_wizard = (
self.env["generate.gift.wizard"]
.with_context(invoicer=invoicer)
.create(
{
"product_id": product_id,
"amount": 0.0,
"contract_ids": [(6, 0, contracts.ids)],
}
)
gift_wizard = self.env["generate.gift.wizard"].create(
{
"product_id": product_id,
"amount": 0.0,
"contract_ids": [(6, 0, contracts.ids)],
}
)

# Generate invoices
count = 1
for contract in contracts:
logger.debug(f"{gift_type} Gift Generation: {count}/{total} ")
logger.debug(f"{gift_type.name} Gift Generation: {count}/{total} ")
description = base_description
if gift_type == self.env.ref(
"sponsorship_compassion.gift_type_birthday"
Expand All @@ -1183,12 +1177,10 @@ def _generate_gifts(self, invoicer, gift_type):
"description": description,
}
)
gift_wizard.with_context(invoicer=invoicer).generate_invoice(
due_date=due_dates[contract]
)
gift_wizard.generate_invoice(due_date=due_dates[contract])
count += 1

logger.debug(f"Automatic {gift_type} Generation Finished !!")
logger.debug(f"Automatic {gift_type.name} Generation Finished !!")
return True

def invoice_paid(self, invoice):
Expand Down
1 change: 0 additions & 1 deletion sponsorship_compassion/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ access_recurring_contract,Full access on recurring.contract,recurring_contract.m
access_recurring_contract_line,Full access on recurring.contract.line,recurring_contract.model_recurring_contract_line,child_compassion.group_sponsorship,1,1,1,1
access_recurring_contract_group,Full access on recurring.contract.group,recurring_contract.model_recurring_contract_group,child_compassion.group_sponsorship,1,1,1,1
access_recurring_contract_origin,Full access on recurring.contract.origin,model_recurring_contract_origin,child_compassion.group_sponsorship,1,1,1,1
access_recurring_invoicer,Full access on recurring.invoicer,recurring_contract.model_recurring_invoicer,child_compassion.group_sponsorship,1,1,1,1
access_account_move,Full access on account.move,account.model_account_move,child_compassion.group_sponsorship,1,1,1,1
access_account_move_line,Full access on account.move.line,account.model_account_move_line,child_compassion.group_sponsorship,1,1,1,1
access_account_journal,Read access on account.journal,account.model_account_journal,child_compassion.group_sponsorship,1,0,0,0
Expand Down
7 changes: 0 additions & 7 deletions sponsorship_compassion/views/sponsorship_contract_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,6 @@
sequence="12"
action="recurring_contract.action_invoice_automatic_generation"
/>
<menuitem
id="menu_recurring_invoicer_form"
name="Generated invoices"
parent="account.menu_finance_receivables"
sequence="13"
action="recurring_contract.action_recurring_invoicer_form"
/>

<!-- Move the Sponsorships Menu to the Sponsorship Section -->
<menuitem
Expand Down
2 changes: 0 additions & 2 deletions sponsorship_compassion/wizards/generate_gift_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def generate_invoice(self, due_date=None):
and c.state in ["active", "waiting"]
and c.is_gift_authorized
)
invoicer = self.env.context.get("invoicer", self.env["recurring.invoicer"])
invoice_obj = self.env["account.move"]
for contract in contracts:
# Logs an error if the birthdate is missing and skip iteration
Expand Down Expand Up @@ -78,7 +77,6 @@ def generate_invoice(self, due_date=None):
continue
inv_data = contract.group_id._build_invoice_gen_data(
invoicing_date=invoice_date,
invoicer=invoicer,
gift_wizard=self,
)
# This makes sure all move lines have the correct contract
Expand Down
Loading