Skip to Content
Menu
This question has been flagged
2 Replies
10206 Views

I add some fields in register payment

model:account.payment

When the validate button is pressed then it goes to account.invoice.
there is a text field payment widget.

when clicked the (i) symbolled tab then the information like memo,amount,date,payment method are displayed.

Question

My question is how to add custom fields cheque date,cheque no and bank in information tab?
Notes

when the validate button is clicked the post function is executed




Avatar
Discard
Best Answer

Hello,

That is shown when a field is defined as a payment widget(as widget="payment")

Below I've posted the compute function for the paymets_info field

@api.one
@api.depends('payment_move_line_ids.amount_residual')
def _get_payment_info_JSON(self):
self.payments_widget = json.dumps(False)
if self.payment_move_line_ids:
info = {'title': _('Less Payment'), 'outstanding': False, 'content': []}
currency_id = self.currency_id
for payment in self.payment_move_line_ids:
payment_currency_id = False
if self.type in ('out_invoice', 'in_refund'):
amount = sum([p.amount for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
amount_currency = sum([p.amount_currency for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
if payment.matched_debit_ids:
payment_currency_id = all([p.currency_id == payment.matched_debit_ids[0].currency_id for p in payment.matched_debit_ids]) and payment.matched_debit_ids[0].currency_id or False
elif self.type in ('in_invoice', 'out_refund'):
amount = sum([p.amount for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
amount_currency = sum([p.amount_currency for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
if payment.matched_credit_ids:
payment_currency_id = all([p.currency_id == payment.matched_credit_ids[0].currency_id for p in payment.matched_credit_ids]) and payment.matched_credit_ids[0].currency_id or False
# get the payment value in invoice currency
if payment_currency_id and payment_currency_id == self.currency_id:
amount_to_show = amount_currency
else:
amount_to_show = payment.company_id.currency_id.with_context(date=payment.date).compute(amount, self.currency_id)
if float_is_zero(amount_to_show, precision_rounding=self.currency_id.rounding):
continue
payment_ref = payment.move_id.name
if payment.move_id.ref:
payment_ref += ' (' + payment.move_id.ref + ')'
info['content'].append({
'name': payment.name,
'journal_name': payment.journal_id.name,
'amount': amount_to_show,
'currency': currency_id.symbol,
'digits': [69, currency_id.decimal_places],
'position': currency_id.position,
'date': payment.date,
'payment_id': payment.id,
'move_id': payment.move_id.id,
'ref': payment_ref,
})
self.payments_widget = json.dumps(info)

You can add any field you want to it by changing real code or inheriting it and add value to content

Also you should change account_payment_widget.js and its corresponding qwebview(account_payment.xml)


Avatar
Discard
Author

Thanks amal .Can you explain this?

Author Best Answer

Thanks Amal,

I have some queries.

in my custom module, i added this function add field in contest like this

'chq_no': payment.chq_no,

I also add this field in account.move.line and account.payment but the chqno value not there. I print the contest but there chq_no returns False.What is the problem is that.?

2)I added the xml and js files and from account module and added it to my custom module.

    added changes.can you js file called.?

Avatar
Discard

If you correctly pass values from js to the qweb then it should work.

You can try like adding <span>test</span> in your original qweb code to see the result

Author

'chq_no':info.content[v].chq_no,

i add this line js. but not get the chq_no.

Author

this i added in account_payment.xml.

<tr>

<td><strong>Cheque No: </strong></td>

<td style="text-align:right;"><t t-esc="chq_no"/></td>

</tr>

is anything wrong in my code?

Author

i use ur above the test is in info tab.

i think the problem is in python function.

i print the contest but the chq_no returns False.

Can you explain what is the problem in that?

Author

amal. I added the chq_no field account.payment in xml.

in python i also added that fields in account.payment and account.move.line.

but in _get_payment_info_JSON function we get the ids of account.move.line.

That's why chq_no is False.

What to make to get the value of chq_no in contest??

Add your value to info['content'] in py.

Then pass it through js to your qweb.

If you check account_payment_widget.js you can see how it is passed

Author

thanks amal

Related Posts Replies Views Activity
0
Dec 18
1204
0
Jul 18
3749
0
Dec 21
1212
29
Dec 20
16133
1
Apr 19
1269