跳至內容
選單
此問題已被標幟

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

頭像
捨棄
作者 最佳答案

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()

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
9月 21
4090
1
4月 24
1823
3
10月 23
8076
1
9月 21
3260
1
6月 25
2340