Skip to content

Commit

Permalink
Merge pull request #134 from OpenG2P/15.0-develop
Browse files Browse the repository at this point in the history
PR to update it to latest
  • Loading branch information
shibu-narayanan authored Oct 26, 2023
2 parents d8a3e3e + ba85b80 commit 3ceecbe
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions g2p_program_reimbursement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"views/program_view.xml",
"views/cycle_view.xml",
"views/entitlement_view.xml",
"views/serviceprovider_view.xml",
"wizard/assign_to_program_wizard.xml",
"wizard/create_program_wizard.xml",
"wizard/create_entitlement_wizard.xml",
Expand Down
2 changes: 2 additions & 0 deletions g2p_program_reimbursement/i18n/g2p_program_reimbursement.pot
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ msgstr ""
#. module: g2p_program_reimbursement
#: model:ir.model.fields,field_description:g2p_program_reimbursement.field_g2p_entitlement__service_provider_id
#: model:ir.model.fields,field_description:g2p_program_reimbursement.field_g2p_entitlement_create_wizard__service_provider_id
#: model:ir.ui.menu,name:g2p_program_reimbursement.menu_account_supplier
#: model_terms:ir.ui.view,arch_db:g2p_program_reimbursement.res_partner_view_search_g2p_inherit
#: model_terms:ir.ui.view,arch_db:g2p_program_reimbursement.view_entitlement_reimbursement_form
#: model_terms:ir.ui.view,arch_db:g2p_program_reimbursement.view_entitlement_reimbursement_tree
msgid "Service Provider"
Expand Down
25 changes: 25 additions & 0 deletions g2p_program_reimbursement/views/serviceprovider_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<odoo>
<!-- Action Name -->
<record id="account.res_partner_action_supplier" model="ir.actions.act_window">
<field name="name">Service Provider</field>
</record>
<!-- Menu Item -->
<menuitem
id="menu_account_supplier"
name="Service Provider"
action="account.res_partner_action_supplier"
groups="g2p_registry_base.group_g2p_admin,g2p_programs.g2p_program_manager"
sequence="3"
/>
<!-- Search View -->
<record id="res_partner_view_search_g2p_inherit" model="ir.ui.view">
<field name="name">res.partner.search.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.res_partner_view_search" />
<field name="arch" type="xml">
<filter name="supplier" position="attributes">
<attribute name="string">Service Provider</attribute>
</filter>
</field>
</record>
</odoo>
9 changes: 9 additions & 0 deletions g2p_programs/i18n/g2p_programs.pot
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@ msgstr ""
msgid "Beneficiaries Duplicates"
msgstr ""

#. module: g2p_programs
#: code:addons/g2p_programs/models/cycle_membership.py:0
#: code:addons/g2p_programs/models/cycle_membership.py:0
#, python-format
msgid ""
"Beneficiaries can only be deleted when both the cycle and entitlement are "
"unapproved."
msgstr ""

#. module: g2p_programs
#: model_terms:ir.ui.view,arch_db:g2p_programs.view_program_list_tree
msgid "Beneficiaries list"
Expand Down
33 changes: 32 additions & 1 deletion g2p_programs/models/cycle_membership.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Part of OpenG2P. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
from odoo import _, fields, models
from odoo.exceptions import ValidationError


class G2PCycleMembership(models.Model):
Expand Down Expand Up @@ -83,3 +84,33 @@ def open_registrant_form(self):
"context": {"default_is_group": False},
"flags": {"mode": "readonly"},
}

def unlink(self):
if not self:
return

draft_records = self.filtered(lambda x: x.cycle_id.state == "draft")

if not draft_records:
raise ValidationError(
_(
"Beneficiaries can only be deleted when both the cycle and entitlement are unapproved."
)
)

for record in draft_records:
beneficiary = record.cycle_id.entitlement_ids.filtered(
lambda x: x.partner_id.id == record.partner_id.id
)
if (
record.cycle_id.state == "approved"
or beneficiary
and beneficiary.state == "approved"
):
raise ValidationError(
_(
"Beneficiaries can only be deleted when both the cycle and entitlement are unapproved."
)
)

return super().unlink()

0 comments on commit 3ceecbe

Please sign in to comment.