大家好,帮我解决这个问题。
检查字段没有增加。它保持空白
from odoo import api, fields, models, _
class check_print(models.Model):
_inherit = 'account.payment'
check = fields.Char("Check Number",readonly=True)
@api.model
def create(self,vals):
if vals.get('payment_method_code') == ('check_printing'):
vals['check'] = self.env['ir.sequence'].next_by_code('seq.ch.code')
res = super(check_print, self).create(vals)
return res
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="seq_check_id" model="ir.sequence">
<field name="name">check</field>
<field name="code">seq.ch.code</field>
<field name="prefix">CH</field>
<field name="padding">10</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>
每次保存记录时,检查字段为空
答案 0 :(得分:0)
似乎该行没有被评估为True:
if vals.get('payment_method_code') == ('check_printing'):
还要检查您是否需要在if
块之外的这些行的缩进
res = super(check_print, self).create(vals)
return res