Odoo18-Base/addons/loyalty/views/loyalty_reward_views.xml
2025-03-10 11:12:23 +07:00

168 lines
11 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="loyalty_reward_view_form" model="ir.ui.view">
<field name="name">loyalty.reward.view.form</field>
<field name="model">loyalty.reward</field>
<field name="arch" type="xml">
<form>
<field name="program_type" invisible="1"/>
<field name="user_has_debug" invisible="1"/>
<field name="multi_product" invisible="1"/>
<field name="reward_product_uom_id" invisible="1"/>
<field name="reward_product_ids" invisible="1"/>
<field name="all_discount_product_ids" invisible="1"/>
<sheet>
<group>
<group string="Reward" id="reward_type_group" attrs="{'invisible': [('program_type', 'in', ('gift_card', 'ewallet'))]}">
<field name="reward_type" widget="selection" force_save="1" attrs="{'readonly' : [('program_type', '=', 'buy_x_get_y')]}"/>
<label for="discount" attrs="{'invisible': [('reward_type', '!=', 'discount')]}"/>
<div class="d-flex flex-row" attrs="{'invisible': [('reward_type', '!=', 'discount')]}">
<field name="discount" class="oe_inline me-1"/>
<field name="discount_mode" no_label="1" class="w-auto me-1"/>
<span>on</span>
</div>
<label for="discount_applicability" string="" attrs="{'invisible': [('reward_type', '!=', 'discount')]}"/>
<field name="discount_applicability" nolabel="1" widget="radio" attrs="{'invisible': [('reward_type', '!=', 'discount')]}"/>
</group>
<group string="Among" attrs="{'invisible': [('reward_type', '!=', 'product')]}">
<field name="reward_product_qty" string="Quantity rewarded"/>
<field name="reward_product_id" attrs="{'required': [('reward_type', '=', 'product'), ('reward_product_ids', '=', [])]}"/>
<field name="reward_product_tag_id" attrs="{'required': [('reward_type', '=', 'product'), ('reward_product_ids', '=', [])]}"/>
</group>
<group string="Discount" attrs="{'invisible': ['|', ('reward_type', '!=', 'discount'), ('program_type', 'in', ('gift_card', 'ewallet'))], }">
<field name="discount_max_amount"/>
<field name="discount_product_domain" groups="base.group_no_one" widget="domain" options="{'model': 'product.product', 'in_dialog': true}" attrs="{'invisible': [('discount_applicability', '!=', 'specific')]}"/>
<field name="discount_product_ids" widget="many2many_tags" attrs="{'invisible': [('discount_applicability', '!=', 'specific')]}"/>
<field name="discount_product_category_id" attrs="{'invisible': [('discount_applicability', '!=', 'specific')]}"/>
<field name="discount_product_tag_id" attrs="{'invisible': [('discount_applicability', '!=', 'specific')]}"/>
</group>
</group>
<group string="Points" attrs="{'invisible': [('user_has_debug', '=', False), ('program_type', 'not in', ('loyalty', 'buy_x_get_y'))]}">
<group>
<label for="required_points" string="In exchange of"/>
<div class="o_row">
<field name="required_points" class="oe_edit_only col-2 oe_inline text-center pe-2"/>
<field name="point_name" no_label="1"/>
<span attrs="{'invisible': [('clear_wallet', '!=', True)]}"> (or more)</span>
</div>
<label for="clear_wallet" string="Clear all promo point(s)" attrs="{'invisible': ['|','&amp;',('user_has_debug', '=', False), ('program_type', 'in', ('loyalty', 'buy_x_get_y')), ('program_type', 'in', ('ewallet','gift_card'))]}"/>
<div class="o_row" attrs="{'invisible': ['|','&amp;',('user_has_debug', '=', False), ('program_type', 'in', ('loyalty', 'buy_x_get_y')), ('program_type', 'in', ('ewallet','gift_card'))]}">
<field name="clear_wallet"/>
</div>
</group>
</group>
<group attrs="{'invisible': [('program_type', 'in', ('gift_card', 'ewallet'))]}">
<field name="description" string="Description on order"/>
<field name="discount_line_product_id" string="Discount product" groups="base.group_no_one"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="loyalty_reward_view_kanban" model="ir.ui.view">
<field name="name">loyalty.reward.view.kanban</field>
<field name="model">loyalty.reward</field>
<field name="arch" type="xml">
<kanban>
<field name="program_id"/>
<field name="company_id"/>
<field name="currency_id"/>
<field name="description"/>
<field name="reward_type"/>
<field name="discount"/>
<field name="discount_mode"/>
<field name="discount_applicability"/>
<field name="discount_product_domain"/>
<field name="discount_product_category_id"/>
<field name="discount_product_tag_id"/>
<field name="discount_max_amount"/>
<field name="discount_line_product_id"/>
<field name="reward_product_id"/>
<field name="reward_product_ids"/>
<field name="all_discount_product_ids"/>
<field name="reward_product_tag_id"/>
<field name="multi_product"/>
<field name="reward_product_qty"/>
<field name="reward_product_uom_id"/>
<field name="required_points"/>
<field name="point_name"/>
<field name="clear_wallet"/>
<field name="program_type"/>
<field name="user_has_debug"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click_edit mx-0 d-flex flex-row">
<div class="o_loyalty_kanban_card_left mw-75 flex-grow-1" id="reward_info">
<t t-if="record.reward_type.raw_value === 'discount'">
<t t-if="record.discount">
<a><field name="discount"/><field name="discount_mode"/> discount <t t-if="record.discount_max_amount.raw_value > 0">( Max <field name="discount_max_amount"/> )</t></a>
</t>
<t t-if="record.discount_applicability.raw_value === 'specific'">
<br/>
<br/>
<span class="fw-bold text-decoration-underline">Applied to:</span>
<t t-if="record.discount_product_ids.raw_value.length > 0">
<div class="d-flex"><i class="fa fa-cube fa-fw" title="Products"/> <field name="discount_product_ids" widget="many2many_tags" class="d-inline"/></div>
</t>
<t t-if="record.discount_product_category_id.raw_value">
<div class="d-flex"><i class="fa fa-cubes fa-fw" title="Product Categories"/> <field name="discount_product_category_id" class="d-inline"/></div>
</t>
<t t-if="record.discount_product_tag_id.raw_value">
<div class="d-flex"><i class="fa fa-tags fa-fw" title="Product Tags"/> <field name="discount_product_tag_id" class="d-inline"/></div>
</t>
<t t-if="record.discount_product_domain.raw_value &amp;&amp; record.discount_product_domain.raw_value !== '[]'" groups="base.group_no_one">
<div class="d-flex"><i class="fa fa-search fa-fw" title="Product Domain"/> <field name="discount_product_domain" class="d-inline"/></div>
</t>
</t>
<t t-elif="record.discount_applicability.raw_value === 'cheapest'">
on the cheapest product
<br/>
</t>
<t t-elif="record.discount_applicability.raw_value === 'order'">
on your order
<br/>
</t>
</t>
<t t-if="record.reward_type.raw_value === 'product'">
<a>Free product</a>
<br/>
<br/>
<t t-if="record.reward_product_id.raw_value">
<div class="d-flex"><i class="fa fa-cube fa-fw" title="Product Domain"/><field name="reward_product_id"/> <t t-if="record.reward_product_qty.raw_value > 1"><span> x </span><field name="reward_product_qty"/></t></div>
</t>
<t t-if="record.reward_product_tag_id.raw_value">
<div class="d-flex"><i class="fa fa-tags fa-fw" title="Product Tags"/> <field name="reward_product_tag_id" class="d-inline"/></div>
</t>
</t>
</div>
<div class="o_loyalty_kanban_card_right" attrs="{'invisible': [('user_has_debug', '=', False), ('program_type', 'not in', ('loyalty', 'buy_x_get_y'))]}">
<p class="text-muted">
<span class="fw-bold text-decoration-underline">In exchange of</span>
<br/>
<t t-if="record.clear_wallet.raw_value">
all <field name="point_name"/> (if at least <field name="required_points"/> <field name="point_name"/>)
</t>
<t t-else="">
<field name="required_points"/> <field name="point_name"/>
</t>
</p>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
</odoo>