콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3020 화면

I'd like to extend the function when registering a payment for a vendor invoice. Normally, the Vendor Reference (account_invoice.reference) is given to account_payment.communication. I want to write a module where I inherit from account_payment the moment the Vendor Reference is acquired from the invoice and add the invoice number to it.

Whichevery way I try to inherit from account.payment and the classes and functions from Odoo, I get a traceback the moment I click on "Validate" in the pop up after clicking on "Register Payment".

My code so far (since I think this is not that much):

# -*- coding: utf-8 -*-

from openerp import api, fields, models

class enhance_memo(models.Model):
    _inherit = 'account.payment'

    @api.model
    def default_get(self, values):
        record = super(enhance_memo,self).default_get(values)
        record['communication'] = [invoice['reference'], invoice['number']]
        return record

I already created another module, which extens the refund function, so I'm more than confused that I struggle with this one.

Any help, from links to tutorials to code examples would be really nice.


아바타
취소
작성자 베스트 답변

Solved it. I forgot to get the invoice info:

# -*- coding: utf-8 -*-

from openerp import api, fields, models

class enhance_memo(models.Model):
_inherit = 'account.payment'

@api.model
def default_get(self, fields):
rec = super(enhance_memo, self).default_get(fields)
invoice_defaults = self.resolve_2many_commands('invoice_ids', rec.get('invoice_ids'))
if invoice_defaults and len(invoice_defaults) == 1:
invoice = invoice_defaults[0]
rec['communication'] = ['%s, %s' % (invoice['reference'], invoice['number']) ] or invoice['name'] or invoice['number']
return rec
아바타
취소
관련 게시물 답글 화면 활동
1
11월 21
6067
0
7월 24
4555
0
10월 19
3200
0
7월 18
3918
3
1월 18
6188