为什么扩展模块的方法不工作?
- 
大神好! 
 我建了个简单的采购订单扩展模块,代码如下。
 重启odoo后,没有报错,修改视图后在采购订单行中可以看到新增的这几个字段。但是方法没有执行:
 product_qty&price_unit并按代码没有赋值。将下面的代码简单改为对myprice字段赋值或提示告警,方法一样没有反应。''' 
 from datetime import datetime
 from dateutil.relativedelta import relativedeltafrom odoo import api, fields, models, SUPERUSER_ID, _ 
 from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
 from odoo.tools.float_utils import float_compare
 from odoo.exceptions import UserError, AccessError
 from odoo.tools.misc import formatLang
 from odoo.addons import decimal_precision as dp
 from odoo.exceptions import ValidationError
 from itertools import groupbyclass PurchaseOrderLine(models.Model): 
 """ Defines purchase oder """
 _inherit = ['purchase.order.line']x_specification = fields.Char(related='product_id.prd_specification',string=u'规格') x_standard_price = fields.Float(related='product_id.standard_price',string=u'标准单价') myprice = fields.Float(string=u'标准单价1')@api.onchange('product_id') 
 def onchange_product_id(self):
 res = super(PurchaseOrderLine,
 for rec in self:
 rec.product_qty = 10 # will trigger _onchange_quantity() on returnreturn res@api.onchange('product_qty', 'product_uom') 
 def _onchange_quantity(self):
 res = super(PurchaseOrderLine, self)._onchange_quantity()
 for rec in self:
 rec.price_unit = 2.0return res''' 
- 
@floatingdudu 在 为什么扩展模块的方法不工作? 中说: product_qty&price_unit并按代码没有赋值 
 敲错了,应为: product_qty&price_unit没有按代码赋值
- 
@floatingdudu 在 为什么扩展模块的方法不工作? 中说: @floatingdudu 在 为什么扩展模块的方法不工作? 中说: product_qty&price_unit并按代码没有赋值 
 敲错了,应为: product_qty&price_unit没有按代码赋值是否和manifest/security设置有关呢? 
- 
问题已经解决,格式有点问题