Without onchange and default,how to get the invoice_number in register payment wizard in saleorder in odoo12
In saleorder I have created a wizard Register payment..While clicking on register payment I want to get the invoice numbers based on active_ids and check if partner invoices address are different in selected active_ids otherwise raise warning...
Here is my code with onchange...
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import UserError
from datetime import date
#Model of Register Payment in Sale order
class RegisterPayment(models.TransientModel):
_name = 'register.payments.wizard'
invoice_number = fields.Many2many('account.invoice', string = "Invoices")
@api.multi
@api.onchange('invoice_number')
def _default_invoices(self):
sale_orders = self.env['sale.order'].browse(self._context.get('active_ids'))
check_invoice_address = len(set(sale_orders.mapped(lambda rec:rec.partner_invoice_id.id)))
if check_invoice_address != 1:
raise UserError("Can to Initiate payment for different Invoice Address.")
invoices = []
for sale_order in sale_orders:
invoices.append(sale_order.invoice_ids.ids)
self.invoice_number = sum(invoices,[])
How to implement it without using onchange and default in odoo12 community version
Please help.
Thanks
Check Odoo Customization Tips, hope this will helps: https://learnopenerp.tumblr.com/