跳至内容
菜单
此问题已终结

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
1830
3
10月 23
8079
1
9月 21
3266
1
6月 25
2344