345 lines
17 KiB
XML
345 lines
17 KiB
XML
<?xml version="1.0"?>
|
|
<odoo>
|
|
|
|
<template id="report_assets_common" inherit_id="web.report_assets_common">
|
|
<xpath expr="." position="inside">
|
|
<link rel="stylesheet" type="text/scss" href="/odex_takaful/static/src/scss/receipt_document.scss"/>
|
|
</xpath>
|
|
</template>
|
|
|
|
<template id="assets_backend" name="product_catalogue_assets" inherit_id="web.assets_backend">
|
|
<xpath expr="." position="inside">
|
|
<link rel="stylesheet" type="text/scss" href="/odex_takaful/static/src/scss/donation_item_views.scss"/>
|
|
<link rel="stylesheet" type="text/scss" href="/odex_takaful/static/src/scss/fix_table_overflow.scss"/>
|
|
<link rel="stylesheet" type="text/scss" href="/odex_takaful/static/src/scss/orphan-fonts.scss"/>
|
|
<link rel="stylesheet" type="text/scss" href="/odex_takaful/static/src/scss/takaful_dashboard.scss"/>
|
|
<script type="text/javascript" src="/odex_takaful/static/src/js/product_product_views.js"/>
|
|
<script type="text/javascript" src="/odex_takaful/static/src/js/donation_catalog_button.js"/>
|
|
<script type="text/javascript" src="/odex_takaful/static/src/js/donation_catalog_controls.js"/>
|
|
<script type="text/javascript" src="/odex_takaful/static/src/js/hide_close_button.js"/>
|
|
<!-- <script type="text/javascript" src="/odex_takaful/static/src/js/catalog_kanban_dynamic_button.js"/>-->
|
|
<script type="text/javascript" src="/odex_takaful/static/src/js/takaful_dashboard.js"/>
|
|
</xpath>
|
|
</template>
|
|
|
|
|
|
<!-- تحسينات بسيطة للتكافل -->
|
|
<template id="takaful_simple_enhancements" inherit_id="web.assets_backend">
|
|
<xpath expr="." position="inside">
|
|
<style>
|
|
/* Simple enhancements only */
|
|
.o_form_label {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.o_field_widget.o_field_monetary input {
|
|
font-weight: 600;
|
|
}
|
|
|
|
.o_field_widget.o_field_phone input {
|
|
direction: ltr;
|
|
}
|
|
|
|
/* Fix top spacing caused by h1 */
|
|
h1 {
|
|
margin-bottom: 5px !important;
|
|
margin-top: 5px !important;
|
|
}
|
|
|
|
/* Record Type Simple & Clean Design */
|
|
.o_record_type_simple {
|
|
background: #f8f9fa;
|
|
padding: 8px 15px;
|
|
border-radius: 8px;
|
|
margin: 0;
|
|
text-align: center;
|
|
}
|
|
|
|
.record_type_options {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 20px;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.record_option {
|
|
background: white;
|
|
border: 2px solid #e9ecef;
|
|
border-radius: 8px;
|
|
padding: 15px 25px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
min-width: 120px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.record_option:hover {
|
|
border-color: #007bff;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 8px rgba(0,123,255,0.15);
|
|
}
|
|
|
|
.record_option.selected {
|
|
border-color: #28a745;
|
|
background: #f8fff9;
|
|
box-shadow: 0 2px 8px rgba(40,167,69,0.15);
|
|
}
|
|
|
|
.record_option i {
|
|
font-size: 24px;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.donation_option.selected i {
|
|
color: #28a745;
|
|
}
|
|
|
|
.sponsorship_option.selected i {
|
|
color: #007bff;
|
|
}
|
|
|
|
/* Donation Mechanism Simple Design */
|
|
.o_donation_mechanism_simple {
|
|
margin: 8px 0;
|
|
padding: 8px 15px;
|
|
background: #fff8e1;
|
|
border-radius: 6px;
|
|
border-left: 4px solid #ffc107;
|
|
text-align: center;
|
|
}
|
|
|
|
.mechanism_options {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 15px;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.mechanism_option {
|
|
background: white;
|
|
border: 2px solid #e9ecef;
|
|
border-radius: 6px;
|
|
padding: 10px 20px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
min-width: 120px;
|
|
justify-content: center;
|
|
}
|
|
|
|
.mechanism_option i {
|
|
width: 20px;
|
|
text-align: center;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.mechanism_option span {
|
|
min-width: 90px;
|
|
display: inline-block;
|
|
text-align: center;
|
|
}
|
|
|
|
.mechanism_option:hover {
|
|
border-color: #ffc107;
|
|
background: #fffbf0;
|
|
}
|
|
|
|
.mechanism_option.selected {
|
|
border-color: #ff9800;
|
|
background: #fff3e0;
|
|
color: #e65100;
|
|
}
|
|
|
|
/* Help Messages Styling */
|
|
.alert {
|
|
margin: 8px 0;
|
|
padding: 8px 15px;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.alert-info {
|
|
background-color: #e8f4fd;
|
|
border: 1px solid #bee5eb;
|
|
color: #0c5460;
|
|
}
|
|
|
|
.alert-primary {
|
|
background-color: #cce7ff;
|
|
border: 1px solid #b3d7ff;
|
|
color: #004085;
|
|
}
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
odoo.define('takaful.simple_ui_enhancement', function (require) {
|
|
'use strict';
|
|
|
|
var FormController = require('web.FormController');
|
|
|
|
FormController.include({
|
|
start: function () {
|
|
var self = this;
|
|
return this._super.apply(this, arguments).then(function () {
|
|
if (self.modelName === 'takaful.sponsorship') {
|
|
self._setupSimpleUI();
|
|
}
|
|
});
|
|
},
|
|
|
|
_update: function () {
|
|
var result = this._super.apply(this, arguments);
|
|
if (this.modelName === 'takaful.sponsorship') {
|
|
var self = this;
|
|
setTimeout(function() {
|
|
self._setupSimpleUI();
|
|
}, 50);
|
|
}
|
|
return result;
|
|
},
|
|
|
|
_onSave: function () {
|
|
var result = this._super.apply(this, arguments);
|
|
if (this.modelName === 'takaful.sponsorship') {
|
|
var self = this;
|
|
setTimeout(function() {
|
|
self._setupSimpleUI();
|
|
}, 100);
|
|
}
|
|
return result;
|
|
},
|
|
|
|
_setupSimpleUI: function () {
|
|
var self = this;
|
|
var currentData = self.model.localData[self.handle].data;
|
|
|
|
var isNewRecord = !currentData.id;
|
|
var isDraftState = currentData.state === 'draft';
|
|
var isEditMode = self.mode === 'edit';
|
|
var isEditable = isNewRecord || (isDraftState && isEditMode);
|
|
|
|
// Remove old event handlers to prevent duplicates
|
|
this.$('.record_option').off('click');
|
|
this.$('.mechanism_option').off('click');
|
|
|
|
// Maintain visual selection (selected class) but disable interaction
|
|
// Update selected state based on current values
|
|
var recordType = currentData.record_type;
|
|
var donationMechanism = currentData.donation_mechanism;
|
|
|
|
// Update visual selection for record_type
|
|
this.$('.record_option').each(function() {
|
|
var $opt = $(this);
|
|
if ($opt.data('value') === recordType) {
|
|
$opt.addClass('selected');
|
|
} else {
|
|
$opt.removeClass('selected');
|
|
}
|
|
});
|
|
|
|
// Update visual selection for donation_mechanism
|
|
this.$('.mechanism_option').each(function() {
|
|
var $opt = $(this);
|
|
if ($opt.data('value') === donationMechanism) {
|
|
$opt.addClass('selected');
|
|
} else {
|
|
$opt.removeClass('selected');
|
|
}
|
|
});
|
|
|
|
if (!isEditable) {
|
|
this.$('.record_option').css({
|
|
'pointer-events': 'none',
|
|
'cursor': 'not-allowed'
|
|
});
|
|
this.$('.mechanism_option').css({
|
|
'pointer-events': 'none',
|
|
'cursor': 'not-allowed'
|
|
});
|
|
return;
|
|
} else {
|
|
this.$('.record_option').css({
|
|
'pointer-events': 'auto',
|
|
'cursor': 'pointer'
|
|
});
|
|
this.$('.mechanism_option').css({
|
|
'pointer-events': 'auto',
|
|
'cursor': 'pointer'
|
|
});
|
|
}
|
|
|
|
// Record Type Options - Odoo 14 Compatible Method
|
|
this.$('.record_option').on('click', function () {
|
|
var $option = $(this);
|
|
var recordType = $option.data('value');
|
|
var currentData = self.model.localData[self.handle].data;
|
|
|
|
// Clear sponsor_id when changing type if not registered
|
|
var sponsorOrDonorType = currentData.sponsor_or_donor_type;
|
|
var sponsorDonorType = currentData.sponsor_donor_type;
|
|
var changes = {record_type: recordType};
|
|
|
|
// Clear sponsor_id if switching types and not 'registered'
|
|
if (sponsorOrDonorType !== 'registered' && sponsorDonorType !== 'registered') {
|
|
changes.sponsor_id = false;
|
|
}
|
|
|
|
// Update field value using Odoo 14 method
|
|
self.trigger_up('field_changed', {
|
|
dataPointID: self.handle,
|
|
changes: changes
|
|
});
|
|
|
|
// Update visual selection
|
|
self.$('.record_option').removeClass('selected');
|
|
$option.addClass('selected');
|
|
});
|
|
|
|
// Donation Mechanism Options - Odoo 14 Compatible Method
|
|
this.$('.mechanism_option').on('click', function () {
|
|
var $option = $(this);
|
|
var mechanism = $option.data('value');
|
|
|
|
// Update field value using Odoo 14 method
|
|
self.trigger_up('field_changed', {
|
|
dataPointID: self.handle,
|
|
changes: {donation_mechanism: mechanism}
|
|
});
|
|
|
|
// Update visual selection
|
|
self.$('.mechanism_option').removeClass('selected');
|
|
$option.addClass('selected');
|
|
});
|
|
|
|
// Set default selection on load
|
|
setTimeout(function() {
|
|
var currentRecordType = self.model.localData[self.handle].data.record_type;
|
|
if (currentRecordType) {
|
|
self.$('.record_option[data-value="' + currentRecordType + '"]').addClass('selected');
|
|
} else {
|
|
// Default to donation as requested
|
|
self.$('.record_option[data-value="donation"]').addClass('selected');
|
|
}
|
|
|
|
var currentMechanism = self.model.localData[self.handle].data.donation_mechanism;
|
|
if (currentMechanism) {
|
|
self.$('.mechanism_option[data-value="' + currentMechanism + '"]').addClass('selected');
|
|
} else {
|
|
// Default to without_conditions (Unconditional) as requested
|
|
self.$('.mechanism_option[data-value="without_conditions"]').addClass('selected');
|
|
}
|
|
}, 100);
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</xpath>
|
|
</template>
|
|
|
|
</odoo>
|