Bha*_*ran 6 openerp python-2.7 openerp-7 odoo-8
我正在尝试从res_partner检索注释字段(客户内部注释)到帐户发票模块.现在我只想打印它,我将它包含在xml代码中.我试过三种这样的方式,
1)comment2 = fields.Char(string='Comment',related='res_partner.comment',compute='_compute_com')
@api.multi
def _compute_com(self):
print self.comment2
2)comment = fields.Many2one('res.partner','Comment',compute='_compute_com')
@api.multi
def _compute_com(self):
print self.comment
3)partner_comment = fields.Char(compute='_compute_com')
@api.multi
def _compute_com(self):
Comment = self.env['res.partner'].browse(partner_id).comment
print Comment
Run Code Online (Sandbox Code Playgroud)
Ale*_*olo 15
您应该使用相关字段:
comment = fields.Char(related='partner_id.comment')
Run Code Online (Sandbox Code Playgroud)
如果您需要将它存储在account_invoice记录中,您还需要添加参数store = True 问题是,这样您就不能打印它,但如果您需要显示它,则需要将其放入您的视图中.
如果你真的需要临时打印它,你需要以其他方式做到这一点:
comment = fields.Char(compute='_compute_comment')
def _compute_comment(self):
for record in self:
record.comment = partner_id.comment
print record.comment
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21660 次 |
| 最近记录: |