Skip to Content
Menu
This question has been flagged

Hi Need a help..


class AccountInvoice(models.Model):

_inherit = 'account.invoice'

@api.multi
def action_invoice_open(self):
inv_ids = super(AccountInvoice,self).action_invoice_open()
invoice_obj_wish=self.env['wishlist.invoice.line']
order_line_obj=self.env['sale.order.line']
sale_order_id = self.env['sale.order'].search([('name', '=', self.name)], limit=1).id
# env_val=

for order_details_id in self.browse(sale_order_id):
vals = {

'invoice_status':str(self.state),
'wishlist_invoice_id': sale_order_id,
'wishinv_number':str(self.number),
'invoice_date':self.date_invoice,
'invoice_id':self.id

}

for order_val in self.env['sale.order'].browse(sale_order_id):

orderline_write = order_line_obj.search(
[('id', '=', self.invoice_line_ids.wish_ref.id)]) #Here I am getting Error(ValueError: Expected singleton: account.invoice.line(31, 32)) If i validate with Multiple lines


#If i validate with single line its working ...

for line in order_val.order_line:
orderline_write.write({'status_wish':'invoiced_open'})

update_val=invoice_obj_wish.search(['&', ('wishlist_invoice_id', '=', sale_order_id),('invoice_id','=',self.id)])
update_val.write(vals)

return inv_ids
class AccountInvoiceLine(models.Model):

_inherit = 'account.invoice.line'

wish_ref=fields.Many2one('sale.order.line')

Avatar
Discard
Best Answer

Expected Singleton:

Class methods required single invoking object (Single Browsable Record) to invoke the method and suppose it will call by multiple invoking objects (Browsable Recordsets) then method is not able to identify for which object it should process, therefore it will raise an error Expected Singleton .

Avatar
Discard
Author

Hi Thanks for reply,.. How Can i Change my current code?

for line in invoice_line_ids:

orderline_write = order_line_obj.search(

[('id', '=', line.wish_ref.id)])

Above comment i cannot reomove. please use this code.

Author

Thanks....working....

Related Posts Replies Views Activity
0
Apr 24
77
4
Apr 17
3099
0
Sep 24
390
0
Apr 24
361
0
Apr 24
93