Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

Right now I'm trying to call programmatically, from another model, the action 'action_register_payment' that exists in the invoice details page as a button called 'Register & Payment' (I'm not able to post images).

I want to call that method, to pass the information to the action_create_payments method of the account.payment.register model

Avatar
Buang
Penulis Jawaban Terbai

Resolved. Create a method in the model account.move, inheriting the class

def payments_create(self):
invoice_object = self
cliente = self.env['res.partner'].search([('id','=', self.partner_id.id)])
ctx = dict(
active_ids=invoice_object.ids, # Use ids and not id (it has to be a list)
active_model='account.move',
)
values = {
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': self.partner_id.id,
'payment_method_id': 1,
'amount': self.amount_total,
'payment_date': self.date,
'currency_id': 1,
'journal_id': 14,
'communication': self.name,
}
wizard = self.env['account.payment.register'].with_context(ctx).create(values)
wizard._create_payments()

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Sep 21
4083
1
Apr 24
1814
3
Okt 23
8073
1
Sep 21
3256
1
Jun 25
2338