feat(fusion_accounting_assets): disposal_dialog component
Made-with: Cursor
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
'name': 'Fusion Accounting Assets',
|
'name': 'Fusion Accounting Assets',
|
||||||
'version': '19.0.1.0.24',
|
'version': '19.0.1.0.25',
|
||||||
'category': 'Accounting/Accounting',
|
'category': 'Accounting/Accounting',
|
||||||
'summary': 'AI-augmented asset management with depreciation schedules.',
|
'summary': 'AI-augmented asset management with depreciation schedules.',
|
||||||
'description': """
|
'description': """
|
||||||
@@ -50,6 +50,8 @@ menu hides; the engine + AI tools remain available for the chat.
|
|||||||
'fusion_accounting_assets/static/src/components/asset_detail_panel/asset_detail_panel.xml',
|
'fusion_accounting_assets/static/src/components/asset_detail_panel/asset_detail_panel.xml',
|
||||||
'fusion_accounting_assets/static/src/components/depreciation_board/depreciation_board.js',
|
'fusion_accounting_assets/static/src/components/depreciation_board/depreciation_board.js',
|
||||||
'fusion_accounting_assets/static/src/components/depreciation_board/depreciation_board.xml',
|
'fusion_accounting_assets/static/src/components/depreciation_board/depreciation_board.xml',
|
||||||
|
'fusion_accounting_assets/static/src/components/disposal_dialog/disposal_dialog.js',
|
||||||
|
'fusion_accounting_assets/static/src/components/disposal_dialog/disposal_dialog.xml',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import { Component, useState } from "@odoo/owl";
|
||||||
|
import { useService } from "@web/core/utils/hooks";
|
||||||
|
|
||||||
|
export class DisposalDialog extends Component {
|
||||||
|
static template = "fusion_accounting_assets.DisposalDialog";
|
||||||
|
static props = {
|
||||||
|
assetId: { type: Number },
|
||||||
|
onClose: { type: Function },
|
||||||
|
};
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
this.assets = useService("fusion_assets");
|
||||||
|
this.state = useState({
|
||||||
|
disposalType: 'sale',
|
||||||
|
saleAmount: 0,
|
||||||
|
saleDate: new Date().toISOString().slice(0, 10),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async onConfirm() {
|
||||||
|
try {
|
||||||
|
await this.assets.disposeAsset(this.props.assetId, {
|
||||||
|
disposalType: this.state.disposalType,
|
||||||
|
saleAmount: parseFloat(this.state.saleAmount) || 0,
|
||||||
|
saleDate: this.state.saleDate,
|
||||||
|
});
|
||||||
|
this.props.onClose();
|
||||||
|
} catch (e) {
|
||||||
|
// Error already shown by service
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates xml:space="preserve">
|
||||||
|
|
||||||
|
<t t-name="fusion_accounting_assets.DisposalDialog">
|
||||||
|
<div class="modal" style="display: block; background: rgba(0,0,0,0.5); position: fixed; top:0; left:0; right:0; bottom:0; z-index: 1050;">
|
||||||
|
<div class="modal-dialog" style="margin: 5vh auto; max-width: 500px;">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5>Dispose Asset</h5>
|
||||||
|
<button class="btn-close" t-on-click="props.onClose">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Disposal Type</label>
|
||||||
|
<select class="form-select"
|
||||||
|
t-on-change="(ev) => state.disposalType = ev.target.value">
|
||||||
|
<option value="sale" selected="state.disposalType === 'sale'">Sale</option>
|
||||||
|
<option value="scrap" selected="state.disposalType === 'scrap'">Scrap</option>
|
||||||
|
<option value="donation" selected="state.disposalType === 'donation'">Donation</option>
|
||||||
|
<option value="lost" selected="state.disposalType === 'lost'">Lost</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3" t-if="state.disposalType === 'sale'">
|
||||||
|
<label>Sale Amount ($)</label>
|
||||||
|
<input type="number" class="form-control"
|
||||||
|
t-att-value="state.saleAmount"
|
||||||
|
t-on-change="(ev) => state.saleAmount = ev.target.value"/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Date</label>
|
||||||
|
<input type="date" class="form-control"
|
||||||
|
t-att-value="state.saleDate"
|
||||||
|
t-on-change="(ev) => state.saleDate = ev.target.value"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn_asset" t-on-click="props.onClose">Cancel</button>
|
||||||
|
<button class="btn_asset primary" t-on-click="onConfirm">Confirm Disposal</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
||||||
Reference in New Issue
Block a user