콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
9 답글
8581 화면
class AccountInvoice(models.Model):

_inherit = 'account.invoice'

@api.multi
def action_invoice_open(self):
invoice_obj_wish=self.env['wishlist.invoice.line']
invoice_order_id = self.env['sale.order'].search([('name', '=', self.name)], limit=1).id

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

'invoice_status':'open',
'wishlist_invoice_id': invoice_order_id,
'wish_inv_number':self.number,
'invoice_date':self.date_invoice

}

 
       # invoice_obj_wish.write(vals) @@@@@@@NOT WORKING
return super(AccountInvoice,self).action_invoice_open()
class WishlistInvoiceOderLine(models.Model):

_name='wishlist.invoice.line'

invoice_id=fields.Many2one('account.invoice','Invoice Reference')
wishlist_invoice_id = fields.Many2one('sale.order')
partner_id = fields.Many2one('res.partner', 'Customer')
invoice_date = fields.Datetime('Invoice Date')
wishinv_number = fields.Char('Number')
sales_person_id = fields.Many2one('res.partner', 'Sales Person')
wish_due_date=fields.Datetime('Due Date')
wish_source = fields.Char('Source Document')
commit_date=fields.Datetime('Coomittment Date')
total=fields.Float('Total')
wish_amount_due = fields.Float('Amount Due')
invoice_status=fields.Char('Status')
아바타
취소

Once try with,

invoice_id = invoice_obj_wish.create(vals)

invoice_obj = invoice_obj_wish.browse(invoice_id)

invoice_obj.write(vals)

For that only i have provided syntax above,

invoice_obj_wish.write(vals) ## Its not correct write statement,you need to have object where you can write.

베스트 답변

Hello,

write method is not working because "invoice_obj_wish=self.env['wishlist.invoice.line']" it is just an object. in to this you will not able to write. for that you need to browse record set into this object than you can perform operation over it.

invoice_obj_wish=self.env['wishlist.invoice.line'].browse("YOUR_ID_WHICH_IS_CREATED_FROM_OTHER_METHOD")

than use "invoice_obj_wish.write(vals)" to update values in your existing record.


Thanks & Regards,

Siddharth Gajjar

아바타
취소