Skip to content

Commit

Permalink
Merge pull request #60 from rubencabrera/new-season
Browse files Browse the repository at this point in the history
New season
  • Loading branch information
rubencabrera authored Mar 7, 2024
2 parents d9fb98c + 435a5fc commit ec1365d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
7 changes: 4 additions & 3 deletions partner_portal_extra_details/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
"l10n_es",
],
"data": [
#datas
# datas
"data/product_template_data.xml",
"data/mail_template_data.xml",
"data/ir_cron_data.xml",
"data/season_start_cron.xml",
#views
"data/restore_season_confirmation_cron.xml",
# views
"views/portal_templates.xml",
"views/res_partner.xml",
"views/res_company_views.xml",
#wizard
# wizard
"wizard/automatic_partner_invoice.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- En fase de desarrollo aún, dejamos que se actualice -->
<!-- <data noupdate="1"> -->
<record id="ir_cron_season_start" model="ir.cron">
<field name="name">Restaura participación en temporada</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="state">code</field>
<field name="code">model.restore_current_year_confirmation()</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">12</field>
<field name="interval_type">months</field>
<field name="numbercall">-1</field>
<field eval="True" name="doall"/>
<field name="priority">10</field>
<field name="nextcall">2025-02-01 10:10:10</field>
</record>
</data>
</odoo>
31 changes: 23 additions & 8 deletions partner_portal_extra_details/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ def restore_current_year_confirmation(self):
"""
Restaurar la confirmación de participación del presente año.
"""
pass
players = self._filter_players()
_logger.debug("Restaurando temporada para todos los jugadores")
players.write(
{
"attach_receipt": False,
"current_year_confirmed": False,
"valid_receipt": False,
}
)

def has_invoice_this_year(self, partner_id):
account_invoice = invoices = self.env['account.invoice']
Expand All @@ -108,11 +116,13 @@ def has_invoice_this_year(self, partner_id):
)
return False if not invoices else True


@api.multi
def write(self, values):
for partner in self:
if values.get("current_year_confirmed") and not self.has_invoice_this_year(partner.id):
if (
values.get("current_year_confirmed") and
not self.has_invoice_this_year(partner.id)
):
if partner.validate_portal_user:
partner._send_mail_to_new_validate_user()
elif values.get("validate_portal_user"):
Expand All @@ -122,7 +132,10 @@ def write(self, values):
partner._send_mail_to_new_validate_user()
partner._grant_portal_access()

elif values.get('validate_portal_user') and not self.has_invoice_this_year(partner.id):
elif (
values.get('validate_portal_user') and
not self.has_invoice_this_year(partner.id)
):
# Usuario nuevo, al que hemos validado manualmente desde
# administración y al que vamos a mandar el email.
partner.is_player = True
Expand All @@ -146,7 +159,6 @@ def _send_mail_to_new_validate_user(self):
enviarse una vez, no cada año, pero lo usamos en 2022 como correo
de inicio de temporada.
"""
# self.ensure_one()
for partner in self:
if not self.has_invoice_this_year(partner.id):
invoice = partner._create_partner_invoice()
Expand All @@ -160,7 +172,9 @@ def _filter_players(self):
"""
return self.search(
[
'&',
('is_player', '=', True),
('active', '=', True),
]
)

Expand Down Expand Up @@ -252,9 +266,10 @@ def _grant_portal_access(self):

def _send_validate_mail(self):
"""
Envía un correo de validación. Es el correo de bienvenida de cada temporada.
Inicialmente se invoca desde la función write() cuando se ha validado el recibo.
Envía un correo de validación. Es el correo de bienvenida de
cada temporada.
Inicialmente se invoca desde la función write() cuando se ha
validado el recibo.
"""
self.ensure_one()
partner = self
Expand Down

0 comments on commit ec1365d

Please sign in to comment.