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 spp_programs/models/entitlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def _generate_code(self):
)

# Product Fields
product_id = fields.Many2one("product.product", "Product", domain=[("type", "=", "product")])
product_id = fields.Many2one("product.product", "Product", domain=[("type", "=", "consu")])
quantity = fields.Integer("Quantity", default=1)
unit_price = fields.Monetary(string="Value/Unit", currency_field="currency_id")
uom_id = fields.Many2one("uom.uom", "Unit of Measure")
Expand Down
2 changes: 1 addition & 1 deletion spp_programs/models/managers/entitlement_manager_inkind.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class SPPInKindEntitlementItem(models.Model):
sequence = fields.Integer(default=1000)
entitlement_id = fields.Many2one("spp.program.entitlement.manager.inkind", "In-kind Entitlement", required=True)

product_id = fields.Many2one("product.product", "Product", domain=[("type", "=", "product")], required=True)
product_id = fields.Many2one("product.product", "Product", domain=[("type", "=", "consu")], required=True)

# non-mandatory field to store a domain that is used to verify if this item is valid for a beneficiary
# For example, it could be: [('is_woman_headed_household, '=', True)]
Expand Down
121 changes: 88 additions & 33 deletions spp_programs/views/cel/entitlement_inkind_cel_views.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Extend In-Kind Entitlement Item Form (inline form within manager) -->
<record id="view_inkind_entitlement_item_cel_form" model="ir.ui.view">
<field name="name">spp.program.entitlement.manager.inkind.item.cel.form</field>
<field name="model">spp.program.entitlement.manager.inkind</field>
<field name="inherit_id" ref="spp_programs.view_entitlement_manager_inkind_form"/>
<field
name="inherit_id"
ref="spp_programs.view_entitlement_manager_inkind_form"
/>
<field name="arch" type="xml">
<!-- Add quantity mode selection to inline form -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']" position="before">
<field name="quantity_mode" widget="radio" options="{'horizontal': true}"/>
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']"
position="before"
>
<field
name="quantity_mode"
widget="radio"
options="{'horizontal': true}"
/>
</xpath>

<!-- Make quantity field conditional -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']" position="attributes">
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']"
position="attributes"
>
<attribute name="invisible">quantity_mode == 'cel'</attribute>
</xpath>

<!-- Add CEL quantity formula after quantity -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']" position="after">
<field name="quantity_cel_expression"
widget="cel_expression"
cel_profile="registry_groups"
show_symbol_browser="true"
show_validation_count="false"
invisible="quantity_mode != 'cel'"
placeholder="e.g., hh_size * 2"/>
<div invisible="quantity_mode != 'cel' or not quantity_cel_expression" class="small">
<field name="quantity_cel_preview" invisible="not quantity_cel_preview" class="text-success"/>
<field name="quantity_cel_error" invisible="not quantity_cel_error" class="text-danger"/>
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='quantity']"
position="after"
>
<field
name="quantity_cel_expression"
widget="cel_expression"
cel_profile="registry_groups"
show_symbol_browser="true"
show_validation_count="false"
invisible="quantity_mode != 'cel'"
placeholder="e.g., hh_size * 2"
/>
<div
invisible="quantity_mode != 'cel' or not quantity_cel_expression"
class="small"
>
<field
name="quantity_cel_preview"
invisible="not quantity_cel_preview"
class="text-success"
/>
<field
name="quantity_cel_error"
invisible="not quantity_cel_error"
class="text-danger"
/>
</div>
<field name="quantity_cel_is_valid" invisible="1"/>
<field name="quantity_cel_is_valid" invisible="1" />
</xpath>

<!-- Add condition mode selection -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']" position="before">
<field name="condition_mode" widget="radio" options="{'horizontal': true}"/>
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']"
position="before"
>
<field
name="condition_mode"
nolabel="1"
widget="radio"
options="{'horizontal': true}"
/>
</xpath>

<!-- Make condition field conditional -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']" position="attributes">
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']"
position="attributes"
>
<attribute name="invisible">condition_mode == 'cel'</attribute>
</xpath>

<!-- Add CEL condition expression after condition -->
<xpath expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']" position="after">
<field name="condition_cel_expression"
widget="cel_expression"
cel_profile="registry_groups"
show_symbol_browser="true"
show_validation_count="true"
invisible="condition_mode != 'cel'"
placeholder="e.g., hh_size >= 4 and child_count > 0"/>
<xpath
expr="//field[@name='entitlement_item_ids']/form//field[@name='condition']"
position="after"
>
<field
name="condition_cel_expression"
nolabel="1"
widget="cel_expression"
cel_profile="registry_groups"
show_symbol_browser="true"
show_validation_count="true"
invisible="condition_mode != 'cel'"
placeholder="e.g., hh_size >= 4 and child_count > 0"
/>
</xpath>
</field>
</record>
Expand All @@ -59,14 +105,23 @@
<record id="view_inkind_entitlement_manager_cel_form" model="ir.ui.view">
<field name="name">spp.program.entitlement.manager.inkind.cel.form</field>
<field name="model">spp.program.entitlement.manager.inkind</field>
<field name="inherit_id" ref="spp_programs.view_entitlement_manager_inkind_form"/>
<field
name="inherit_id"
ref="spp_programs.view_entitlement_manager_inkind_form"
/>
<field name="arch" type="xml">
<!-- Update the tree view inside the form to show quantity and condition modes -->
<xpath expr="//field[@name='entitlement_item_ids']/list/field[@name='quantity']" position="before">
<field name="quantity_mode" optional="show"/>
<xpath
expr="//field[@name='entitlement_item_ids']/list/field[@name='quantity']"
position="before"
>
<field name="quantity_mode" optional="show" />
</xpath>
<xpath expr="//field[@name='entitlement_item_ids']/list/field[@name='multiplier_field']" position="before">
<field name="condition_mode" optional="hide"/>
<xpath
expr="//field[@name='entitlement_item_ids']/list/field[@name='multiplier_field']"
position="before"
>
<field name="condition_mode" optional="hide" />
</xpath>
</field>
</record>
Expand Down
93 changes: 71 additions & 22 deletions spp_programs/views/managers/entitlement_manager_inkind_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,35 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
<div class="oe_title mb24">
<label for="name" string="Name:" />
<h1>
<field id="name" name="name" placeholder="Enter the Manager Name..." />
<field
id="name"
name="name"
placeholder="Enter the Manager Name..."
/>
</h1>
</div>
<div colspan="2">
<field name="manage_inventory" />
<label for="manage_inventory" string="Manage stock movements (inventory)" />
<label
for="manage_inventory"
string="Manage stock movements (inventory)"
/>
</div>
<div colspan="2">
<field name="is_evaluate_single_item" />
<label for="is_evaluate_single_item" string="Evaluate one item" />
<label
for="is_evaluate_single_item"
string="Evaluate one item"
/>
</div>
<notebook>
<page string="Items">
<group colspan="4" col="4">
<field name="entitlement_item_ids" nolabel="1" colspan="4">
<field
name="entitlement_item_ids"
nolabel="1"
colspan="4"
>
<list>
<field name='sequence' widget='handle' />
<field name="product_id" />
Expand All @@ -60,22 +74,40 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
colspan="4"
/>
<field name="quantity" />
<field
name="uom_id"
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
/>
</group>
<group colspan="4" col="4">
<group colspan="2">
<field name="quantity" />
</group>
<group colspan="2">
<field
name="uom_id"
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
/>
</group>
</group>
<separator
string="Condition (Optional)"
class="mt-3"
/>
<group name="condition_section" col="1">
<field
name="condition"
colspan="4"
nolabel="1"
widget="domain"
options="{'model': 'res.partner'}"
/>
<field
name="multiplier_field"
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
/>
<field name="max_multiplier" />
</group>
<group colspan="4" col="4">
<group colspan="2">
<field
name="multiplier_field"
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
/>
</group>
<group colspan="2">
<field name="max_multiplier" />
</group>
</group>
</form>
</field>
Expand All @@ -96,13 +128,20 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
/>
</group>
</page>
<page string="Inventory Settings" invisible="not manage_inventory">
<page
string="Inventory Settings"
invisible="not manage_inventory"
>
<group colspan="4" col="4">
<field
name="warehouse_id"
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
/>
<field name="company_id" invisible="1" options="{'no_open':True}" />
<field
name="company_id"
invisible="1"
options="{'no_open':True}"
/>
</group>
</page>
</notebook>
Expand All @@ -120,7 +159,11 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
<field name="name" />
<field name="program_id" />
<group>
<filter string="Program" name="grp_program_id" context="{'group_by': 'program_id'}" />
<filter
string="Program"
name="grp_program_id"
context="{'group_by': 'program_id'}"
/>
</group>
<!--<searchpanel>
<field name="group" icon="fa-users"/>
Expand All @@ -140,24 +183,30 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add an Entitlement Manager!
</p><p>
</p>
<p>
Click the create button to enter a new in-kind entitlement manager.
</p>
</field>
</record>

<record id="action_entitlement_manager_inkind_tree_view" model="ir.actions.act_window.view">
<record
id="action_entitlement_manager_inkind_tree_view"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="1" />
<field name="view_mode">list</field>
<field name="view_id" ref="view_entitlement_manager_inkind_tree" />
<field name="act_window_id" ref="action_entitlement_manager_inkind" />
</record>

<record id="action_entitlement_manager_inkind_form_view" model="ir.actions.act_window.view">
<record
id="action_entitlement_manager_inkind_form_view"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="1" />
<field name="view_mode">form</field>
<field name="view_id" ref="view_entitlement_manager_inkind_form" />
<field name="act_window_id" ref="action_entitlement_manager_inkind" />
</record>

</odoo>
Loading