Skip to content

Commit

Permalink
Merge pull request #113 from RamakrishnaVellala/15.0-develop-pilot001
Browse files Browse the repository at this point in the history
G2P-904 Generate GL button should be placed away from approve such th…
  • Loading branch information
shibu-narayanan authored Oct 16, 2023
2 parents 9768ac2 + affc0f4 commit eb42da7
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
32 changes: 17 additions & 15 deletions g2p_entitlement_voucher/views/entitlement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@
<field name="model">g2p.entitlement</field>
<field name="inherit_id" ref="g2p_programs.view_entitlement_form" />
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<xpath expr="//sheet/div[@name='button_box']" position="inside">
<div class="container oe_left">
<field name="show_generate_voucher_button" invisible="1" />
<field name="show_print_voucher_button" invisible="1" />
<button
type="object"
class="btn-primary"
icon="fa-thumbs-o-up"
name="generate_vouchers_action"
string="Generate Voucher"
attrs="{'invisible': [('show_generate_voucher_button','!=',True)]}"
/>
type="object"
class="btn-primary mt-2 mb-1"
icon="fa-thumbs-o-up"
name="generate_vouchers_action"
string="Generate Voucher"
attrs="{'invisible': [('show_generate_voucher_button','!=',True)]}"
/>
<button
type="object"
class="btn-primary"
icon="fa-print"
name="print_voucher_action"
string="Print Voucher"
attrs="{'invisible': [('show_print_voucher_button','!=',True)]}"
/>
type="object"
class="btn-primary mt-2 mb-1"
icon="fa-print"
name="print_voucher_action"
string="Print Voucher"
attrs="{'invisible': [('show_print_voucher_button','!=',True)]}"
/>
</div>
</xpath>
</field>
</record>
Expand Down
14 changes: 14 additions & 0 deletions g2p_programs/models/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def fields_view_get(
locked = fields.Boolean(default=False)
locked_reason = fields.Char()

show_approve_entitlements_button = fields.Boolean(
compute="_compute_show_approve_entitlement"
)

def _compute_members_count(self):
for rec in self:
domain = rec._get_beneficiaries_domain(["enrolled"])
Expand All @@ -120,6 +124,16 @@ def _compute_payments_count(self):
)
rec.update({"payments_count": payments_count})

@api.onchange("entitlement_ids.state")
def _compute_show_approve_entitlement(self):
for rec in self:
show_button = True
for entitlement in rec.entitlement_ids:
if entitlement.state != "approved":
show_button = False
break
rec.show_approve_entitlements_button = show_button

@api.onchange("start_date")
def on_start_date_change(self):
self.program_id.get_manager(constants.MANAGER_CYCLE).on_start_date_change(self)
Expand Down
2 changes: 1 addition & 1 deletion g2p_programs/models/entitlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _generate_code(self):
state = fields.Selection(
[
("draft", "Draft"),
("pending_validation", "Pending Validation"),
("pending_validation", "Pending Approval"),
("approved", "Approved"),
("trans2FSP", "Transferred to FSP"),
("rdpd2ben", "Redeemed/Paid to Beneficiary"),
Expand Down
14 changes: 13 additions & 1 deletion g2p_programs/models/managers/entitlement_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,24 @@ def validate_entitlements(self, cycle):
}
else:
kind = "success"
approved_entitlements_count = (
len(entitlements) - err
) # Calculate the approved count
if err != 0:
message = _(
"{} Entitlements are successfully approved and {} are not approved."
).format(approved_entitlements_count, err)
else:
message = _("{} Entitlements are successfully approved.").format(
approved_entitlements_count
)

return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Entitlement"),
"message": _("Entitlements are validated and approved."),
"message": message,
"sticky": True,
"type": kind,
"next": {
Expand Down
5 changes: 3 additions & 2 deletions g2p_programs/views/cycle_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
states="draft"
string="Prepare Entitlement"
/>
<field name="show_approve_entitlements_button" invisible='1' />
<button
type="object"
class="btn-primary"
icon="fa-file-text-o"
name="validate_entitlement"
attrs="{'invisible':['|',('state','!=','approved'),('auto_approve_entitlements','=',True)]}"
string="Validate Entitlements"
attrs="{'invisible':['|',('state','!=','approved'),'|',('auto_approve_entitlements','=',True),('show_approve_entitlements_button','=',True)]}"
string="Approve Entitlement"
/>
<button
type="object"
Expand Down
11 changes: 10 additions & 1 deletion g2p_programs/views/entitlement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
states="draft,pending_validation"
string="Approve Entitlement"
/>
<button
type="object"
class="btn btn-dark"
icon="fa-thumbs-o-up"
name="approve_entitlement"
attrs="{'invisible': [('state', '!=', 'approved')]}"
disabled="1"
string="Entitlement Approved"
/>
<field
name="state"
widget="statusbar"
Expand Down Expand Up @@ -154,7 +163,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
<filter name="draft_state" string="Draft" domain="[('state','=','draft')]" />
<filter
name="pending_validation_state"
string="Pending Validation"
string="Pending Approval"
domain="[('state','=','pending_validation')]"
/>
<filter name="approved_state" string="Approved" domain="[('state','=','approved')]" />
Expand Down

0 comments on commit eb42da7

Please sign in to comment.