Initial commit: Sale packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:49 +02:00
commit 14e3d26998
6469 changed files with 2479670 additions and 0 deletions

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="loyalty_card_view_tree_inherit_website_sale_loyalty" model="ir.ui.view">
<field name="name">loyalty.card.view.tree.inherit.website.sale.loyalty</field>
<field name="model">loyalty.card</field>
<field name="inherit_id" ref="loyalty.loyalty_card_view_tree"/>
<field name="arch" type="xml">
<button name="action_coupon_send" position="after">
<button name="action_coupon_share" string="Share" type="object" icon="fa-share-alt"/>
</button>
</field>
</record>
</odoo>

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="menu_loyalty" name="Loyalty"
parent="website_sale.menu_ecommerce" sequence="4"
groups="sales_team.group_sale_manager"/>
<menuitem
id="menu_discount_loyalty_type_config"
action="loyalty.loyalty_program_discount_loyalty_action"
name="Discount &amp; Loyalty"
parent="website_sale_loyalty.menu_loyalty"
groups="sales_team.group_sale_manager"
sequence="50"
/>
<menuitem
id="menu_gift_ewallet_type_config"
action="loyalty.loyalty_program_gift_ewallet_action"
name="Gift cards &amp; eWallet"
parent="website_sale_loyalty.menu_loyalty"
groups="sales_team.group_sale_manager"
sequence="51"
/>
<record id="loyalty_program_view_form_inherit_website_sale_loyalty" model="ir.ui.view">
<field name="name">loyalty.program.view.form.inherit.website.sale.loyalty</field>
<field name="model">loyalty.program</field>
<field name="inherit_id" ref="sale_loyalty.loyalty_program_view_form_inherit_sale_loyalty"/>
<field name="arch" type="xml">
<xpath expr="//label[@for='available_on']" position="attributes">
<attribute name="invisible">0</attribute>
</xpath>
<xpath expr="//div[@id='o_loyalty_program_availabilities']" position="attributes">
<attribute name="invisible">0</attribute>
</xpath>
<xpath expr="//div[@id='o_loyalty_program_availabilities']" position="inside">
<span class="d-inline-block">
<field name="ecommerce_ok" class="w-auto me-0"/>
<label for="ecommerce_ok" string="Website" class="me-3"/>
</span>
</xpath>
<xpath expr="//div[@id='o_loyalty_program_availabilities']" position="after">
<field name="website_id" attrs="{'invisible': [('ecommerce_ok', '=', False)]}" options="{'no_create': True}" groups="website.group_multi_website" placeholder="All websites"/>
</xpath>
</field>
</record>
<record id="loyalty_program_view_tree_inherit_website_sale_loyalty" model="ir.ui.view">
<field name="name">loyalty.program.view.tree.inherit.website.sale.loyalty</field>
<field name="model">loyalty.program</field>
<field name="inherit_id" ref="loyalty.loyalty_program_view_tree"/>
<field name="arch" type="xml">
<field name="coupon_count_display" position="after">
<field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/>
</field>
<field name="company_id" position="after">
<button name="action_program_share" string="Share" type="object" icon="fa-share-alt" attrs="{ 'invisible' : [('program_type', '!=', 'promo_code')]}"/>
</field>
</field>
</record>
</odoo>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_inherit_website_sale_loyalty" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.website.sale.loyalty</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='website_sale_loyalty']" position="after">
<div class="content-group">
<div class="mt8" attrs="{'invisible': [('module_loyalty', '=', False)]}">
<button name="%(loyalty.loyalty_program_discount_loyalty_action)d" icon="fa-arrow-right" type="action" string="Loyalty Programs" class="btn-link"/>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="snippet_options" inherit_id="website.snippet_options" name="Coupon Snippet Options">
<xpath expr="." position="inside">
<div data-selector="main:has(.oe_website_sale .wizard)" data-page-options="true" groups="website.group_website_designer" data-no-check="true">
<we-checkbox string="Show Discount in Subtotal"
data-customize-website-views="website_sale_loyalty.cart_discount"
data-no-preview="true"
data-reload="/"/>
</div>
</xpath>
</template>
</odoo>

View file

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="sale_coupon_result" inherit_id="website_sale.coupon_form">
<xpath expr="//form[@name='coupon_code']//input[@name='promo']" position="attributes">
<attribute name="placeholder">Gift card or discount code...</attribute>
</xpath>
<xpath expr="//t[@name='code_not_available']" position="replace"/>
</template>
<template id="modify_code_form" inherit_id="website_sale.total" name="Loyalty, coupon, gift card">
<xpath expr="//div[@id='cart_total']//table/tr[last()]" position="after">
<tr t-if="not hide_promotions" class="oe_website_sale_gift_card">
<td colspan="3" class="text-center text-xl-end border-0">
<span class=''>
<t t-if="request.params.get('code_not_available')">
<div class="alert alert-danger text-start mt16" role="alert">
Invalid or expired promo code.
</div>
</t>
<t t-if="promo_code_error">
<div class="alert alert-danger text-start mt16" role="alert">
<t t-esc="promo_code_error"/>
</div>
</t>
<t t-if="website_sale_order and promo_code_success">
<div class="alert alert-success text-start mt16" role="alert">
You have successfully applied the following code: <strong t-esc="promo_code_success"/>
</div>
</t>
<t t-if="website_sale_order">
<t t-foreach="website_sale_order._get_claimable_rewards().items()" t-as="coupon_reward">
<t t-foreach="coupon_reward[1]" t-as="reward">
<form t-att-action="'/shop/claimreward%s' % (redirect and '?r=' + redirect or '')"
method="post" name="claim_reward">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<input type="hidden" name="reward" t-att-value="reward.id"/>
<div class="alert alert-success text-start mt16" role="alert">
<div class="d-flex flex-row">
<div class="flex-grow-1 text-break">
<strong t-esc="reward.description"/>
<div t-if="reward.reward_type == 'product'"
class="mt-1 pe-3"
>
<select
t-if="reward.multi_product"
class="o_select w-100 form-select form-select-sm css_attribute_select"
name="product_id"
>
<option
t-foreach="reward.reward_product_ids"
t-as="product"
t-att-value="product.id"
>
<t t-out="product.display_name"/>
</option>
</select>
<t t-else="">
<t t-esc="reward.reward_product_ids.display_name"/>
</t>
</div>
<div t-if="reward.program_id.portal_visible">
<t t-set="coupon" t-value="coupon_reward[0]"/>
<t t-if="not reward.program_id.is_nominative">
<span t-out="coupon._format_points(website_sale_order._get_real_points_for_coupon(coupon))"/>
</t>
<t t-else="">
<span>You have <t t-out="coupon._format_points(website_sale_order._get_real_points_for_coupon(coupon))"/></span>
<span t-if="reward.program_id.program_type == 'ewallet'"> in your ewallet</span>
<t t-if="reward.program_id.program_type != 'ewallet'">
<br/>
<span>Costs <t t-out="coupon._format_points(reward.required_points)"/></span>
</t>
</t>
</div>
</div>
<div class="justify-content-end">
<a class="btn btn-primary a-submit" href="#" role="button">
<t t-if="reward.program_id.program_type == 'ewallet'">Pay with eWallet</t>
<t t-else="">Claim</t>
</a>
</div>
</div>
</div>
</form>
</t>
</t>
</t>
</span>
</td>
</tr>
</xpath>
</template>
<template id="website_sale_coupon_cart_hide_qty" inherit_id="website_sale.cart_lines">
<xpath expr="//del" position="attributes">
<attribute name="t-if">not line.is_reward_line</attribute>
</xpath>
</template>
<template id="layout" inherit_id="website.layout">
<body position="inside">
<t t-set="coupon_error" t-value="request.params.get('coupon_error')"/>
<t t-set="pending_coupon_code" t-value="request.session.get('pending_coupon_code')"/>
<t t-if="coupon_error and pending_coupon_code">
<div t-attf-class="d-none coupon-message coupon-{{ request.params.get('coupon_error_type', 'error') }}-message">
<span class="coupon-message-title">Could not apply the promo code: <t t-out="pending_coupon_code"/></span>
<span class="coupon-message-content" t-out="coupon_error"/>
</div>
</t>
<t t-set="notify_coupon" t-value="request.params.get('notify_coupon')"/>
<div t-if="notify_coupon" class="d-none coupon-message coupon-info-message">
<span class="coupon-message-content">The following promo code was applied on your order: <t t-out="notify_coupon"/></span>
</div>
</body>
</template>
<template id="cart_discount" name="Show Discount in Subtotal" active="False" inherit_id="website_sale.total">
<xpath expr="//tr[@id='order_total_untaxed']" position="before">
<tr t-if="website_sale_order and website_sale_order.reward_amount">
<td class="text-end border-0 text-muted" title="Discounted amount">Discount:</td>
<td class="text-xl-end border-0 text-muted">
<span t-field="website_sale_order.reward_amount" style="white-space: nowrap;"
class="monetary_field"
t-options='{
"widget": "monetary",
"display_currency": website_sale_order.currency_id,
}'/>
</td>
</tr>
</xpath>
</template>
<template id="reduction_coupon_code" inherit_id="website_sale.reduction_code">
<xpath expr="//t[@t-set='force_coupon']" position="replace">
<t t-set='force_coupon' t-value="website_sale_order.pricelist_id.code or request.params.get('code_not_available') or website_sale_order.get_promo_code_error(delete=False)"/>
</xpath>
<xpath expr="//a" position="replace">
<a href="#" class="show_coupon">Discount code or gift card</a>
</xpath>
</template>
<template id="cart_summary" name="Payment" inherit_id="website_sale.cart_summary">
<!-- `tax_excluded` line price -->
<xpath expr="//table[@id='cart_products']/tbody/tr/td[hasclass('td-price')]/child::*" position="attributes">
<attribute name="t-att-data-reward-type">line.reward_id.reward_type</attribute>
</xpath>
<!-- `tax_included` line price -->
<xpath expr="//table[@id='cart_products']/tbody/tr/td[hasclass('td-price')]/*[2]" position="attributes">
<attribute name="t-att-data-reward-type">line.reward_id.reward_type</attribute>
</xpath>
</template>
<template id="cart_line_product_no_link" inherit_id="website_sale.cart_line_product_link">
<xpath expr="//a" position="replace">
<t t-if="line.is_reward_line">
<strong t-field="line.name"/>
<t t-call="sale_loyalty.used_gift_card"/>
</t>
<t t-else="">$0</t>
</xpath>
</template>
<template id="cart_summary_inherit_website_gift_card_sale" inherit_id="website_sale.cart_summary">
<xpath expr="//td[hasclass('td-product_name')]/div/strong" position="after">
<t t-call="sale_loyalty.used_gift_card"/>
</xpath>
</template>
<template id="website_sale_purchased_gift_card" inherit_id="website_sale.confirmation" >
<xpath expr="//div[@id='oe_structure_website_sale_confirmation_2']" position="after">
<t t-call="sale_loyalty.sale_purchased_gift_card"/>
</xpath>
</template>
</odoo>