[ADD] account: add a popover with payment details and action on invoice

This commit is contained in:
Cedric Snauwaert
2015-08-21 14:06:15 +02:00
parent 2ea5c3aeef
commit cb1ce61c84
4 changed files with 96 additions and 7 deletions
+5 -2
View File
@@ -127,7 +127,7 @@ class AccountInvoice(models.Model):
else:
amount_to_show = line.company_id.currency_id.compute(abs(line.amount_residual), self.currency_id)
info['content'].append({
'ref': line.ref or line.move_id.name,
'journal_name': line.ref or line.move_id.name,
'amount': amount_to_show,
'currency': self.currency_id.symbol,
'id': line.id,
@@ -161,12 +161,15 @@ class AccountInvoice(models.Model):
amount_to_show = payment.company_id.currency_id.compute(-amount, self.currency_id)
info['content'].append({
'name': payment.name,
'ref': payment.journal_id.name,
'journal_name': payment.journal_id.name,
'amount': amount_to_show,
'currency': self.currency_id.symbol,
'digits': [69, self.currency_id.decimal_places],
'position': self.currency_id.position,
'date': payment.date,
'payment_id': payment.id,
'move_id': payment.move_id.id,
'ref': payment.move_id.ref,
})
self.payments_widget = json.dumps(info)
@@ -15,6 +15,7 @@ var ShowPaymentLineWidget = form_common.AbstractField.extend({
var invoice_id = info.invoice_id;
if (info !== false) {
_.each(info.content, function(k,v){
k.index = v;
k.amount = formats.format_value(k.amount, {type: "float", digits: k.digits});
if (k.date){
k.date = formats.format_value(k.date, {type: "date"});
@@ -33,6 +34,51 @@ var ShowPaymentLineWidget = form_common.AbstractField.extend({
self.view.reload();
});
});
_.each(this.$('.js_payment_info'), function(k, v){
var options = {
'content': QWeb.render('PaymentPopOver', {
'name': info.content[v].name,
'journal_name': info.content[v].journal_name,
'date': info.content[v].date,
'amount': info.content[v].amount,
'currency': info.content[v].currency,
'position': info.content[v].position,
'payment_id': info.content[v].payment_id,
'move_id': info.content[v].move_id,
'ref': info.content[v].ref,
}),
'html': true,
'placement': 'left',
'title': 'Payment Information',
'trigger': 'focus',
};
$(k).popover(options);
$(k).on('shown.bs.popover', function(event){
$(this).parent().find('.js_unreconcile_payment').click(function(){
var payment_id = parseInt($(this).attr('payment-id'))
if (payment_id !== undefined && payment_id !== NaN){
new Model("account.move.line")
.call("remove_move_reconcile", [payment_id])
.then(function (result) {
self.view.reload();
});
}
});
$(this).parent().find('.js_open_payment').click(function(){
var move_id = parseInt($(this).attr('move-id'))
if (move_id !== undefined && move_id !== NaN){
//Open form view of account.move with id = move_id
self.do_action({
type: 'ir.actions.act_window',
res_model: 'account.move',
res_id: move_id,
views: [[false, 'form']],
target: 'current'
});
}
});
});
});
}
else {
this.$el.html('');
@@ -14,15 +14,18 @@
<tr>
<t t-if="outstanding">
<td>
<a title="assign to invoice" class="oe_form_field outstanding_credit_assign" t-att-data-id="line.id" style="margin-right: 10px;">Add</a>
<a title="assign to invoice" role="button" class="oe_form_field outstanding_credit_assign" t-att-data-id="line.id" style="margin-right: 10px;">Add</a>
</td>
<td>
<span class="oe_form_field" style="margin-right: 30px;"><t t-esc="line.ref"></t></span>
<span class="oe_form_field" style="margin-right: 30px;"><t t-esc="line.journal_name"></t></span>
</td>
</t>
<t t-if="!outstanding">
<td>
<i class="oe_form_field text-right oe_payment_label" t-att-title="line.name + '\n'+ line.ref">Paid on <t t-esc="line.date"></t></i>
<a role="button" tabindex="0" class="js_payment_info fa fa-info-circle" t-att-index="line.index" style="margin-right:5px;"></a>
</td>
<td>
<i class="oe_form_field text-right oe_payment_label">Paid on <t t-esc="line.date"></t></i>
</td>
</t>
<td style="text-align:right;">
@@ -42,4 +45,41 @@
</div>
</t>
<t t-name="PaymentPopOver">
<div>
<table>
<tr>
<td><strong>Name: </strong></td>
<td style="text-align:right;"><t t-esc="name"/></td>
</tr>
<tr>
<td><strong>Date: </strong></td>
<td style="text-align:right;"><t t-esc="date"/></td>
</tr>
<tr>
<td><strong>Payment Method: </strong></td>
<td style="text-align:right;"><t t-esc="journal_name"/></td>
</tr>
<tr>
<td><strong>Ref: </strong></td>
<td style="text-align:right;"><t t-esc="ref"/></td>
</tr>
<tr>
<td><strong>Amount: </strong></td>
<td style="text-align:right;">
<t t-if="position === 'before'">
<t t-esc="currency"/>
</t>
<t t-esc="amount"></t>
<t t-if="position === 'after'">
<t t-esc="currency"/>
</t>
</td>
</tr>
</table>
</div>
<button class="btn btn-xs btn-primary js_unreconcile_payment pull-left" t-att-payment-id="payment_id" style="margin-top:5px; margin-bottom:5px;">Unreconcile</button>
<button class="btn btn-xs btn-default js_open_payment pull-right" t-att-move-id="move_id" style="margin-top:5px; margin-bottom:5px;">Open Payment</button>
</t>
</templates>
@@ -219,7 +219,7 @@
<field name="state" widget="statusbar" statusbar_visible="draft,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
</header>
<div class="alert alert-info" role="alert" style="margin-bottom:0px;" attrs="{'invisible': [('has_outstanding','=',False)]}">
You have <bold><a class="alert-link" href="#outstanding">outstanding debits</a></bold> for this supplier. You can allocate them to mark this bill as paid.
You have <bold><a class="alert-link" href="#outstanding" role="button">outstanding debits</a></bold> for this supplier. You can allocate them to mark this bill as paid.
</div>
<field name="has_outstanding" invisible="1"/>
<sheet string="Vendor Bill">
@@ -356,7 +356,7 @@
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
</header>
<div class="alert alert-info" role="alert" style="margin-bottom:0px;" attrs="{'invisible': [('has_outstanding','=',False)]}">
You have <bold><a class="alert-link" href="#outstanding">outstanding payments</a></bold> for this customer. You can allocate them to mark this invoice as paid.
You have <bold><a class="alert-link" href="#outstanding" role="button">outstanding payments</a></bold> for this customer. You can allocate them to mark this invoice as paid.
</div>
<field name="has_outstanding" invisible="1"/>
<sheet string="Invoice">