Browse Source

[CHG] src file changed 'base_accounting_kit'

pull/134/merge
Ajmalcybrosys 6 years ago
parent
commit
2b1bb387c8
  1. 87
      base_accounting_kit/static/src/js/account_asset.js
  2. 9
      base_accounting_kit/static/src/scss/account_asset.scss
  3. 4
      base_accounting_kit/views/account_asset_templates.xml

87
base_accounting_kit/static/src/js/account_asset.js

@ -0,0 +1,87 @@
odoo.define('om_account_asset.widget', function(require) {
"use strict";
/**
* The purpose of this widget is to shows a toggle button on depreciation and
* installment lines for posted/unposted line. When clicked, it calls the method
* create_move on the object account.asset.depreciation.line.
* Note that this widget can only work on the account.asset.depreciation.line
* model as some of its fields are harcoded.
*/
var AbstractField = require('web.AbstractField');
var core = require('web.core');
var registry = require('web.field_registry');
var _t = core._t;
var AccountAssetWidget = AbstractField.extend({
events: _.extend({}, AbstractField.prototype.events, {
'click': '_onClick',
}),
description: "",
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @override
*/
isSet: function () {
return true; // it should always be displayed, whatever its value
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @override
* @private
*/
_render: function () {
var className = '';
var disabled = true;
var title;
if (this.recordData.move_posted_check) {
className = 'o_is_posted';
title = _t('Posted');
} else if (this.recordData.move_check) {
className = 'o_unposted';
title = _t('Accounting entries waiting for manual verification');
} else {
disabled = false;
title = _t('Unposted');
}
var $button = $('<button/>', {
type: 'button',
title: title,
disabled: disabled,
}).addClass('btn btn-link fa fa-circle o_deprec_lines_toggler ' + className);
this.$el.html($button);
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
* @param {MouseEvent} event
*/
_onClick: function (event) {
event.stopPropagation();
this.trigger_up('button_clicked', {
attrs: {
name: 'create_move',
type: 'object',
},
record: this.record,
});
},
});
registry.add("deprec_lines_toggler", AccountAssetWidget);
});

9
base_accounting_kit/static/src/scss/account_asset.scss

@ -0,0 +1,9 @@
.o_web_client .o_deprec_lines_toggler {
color: theme-color('danger');
&.o_is_posted {
color: theme-color('success');
}
&.o_unposted {
color: theme-color('warning');
}
}

4
base_accounting_kit/views/account_asset_templates.xml

@ -2,8 +2,8 @@
<odoo>
<template id="assets_backend" name="account assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/om_account_asset/static/src/scss/account_asset.scss"/>
<script type="text/javascript" src="/om_account_asset/static/src/js/account_asset.js"/>
<link rel="stylesheet" type="text/scss" href="/base_accounting_kit/static/src/scss/account_asset.scss"/>
<script type="text/javascript" src="/base_accounting_kit/static/src/js/account_asset.js"/>
</xpath>
</template>
</odoo>

Loading…
Cancel
Save