OpenERP对象定义详解(连载中...)
-
关于field.function我有其他问题,例如
sale这个模块里面的<br />'amount_untaxed': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Untaxed Amount',<br /> store = {<br /> 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),<br /> 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),<br /> },<br /> multi='sums'),<br />
_get_order<br /> def _get_order(self, cr, uid, ids, context={}):<br /> result = {}<br /> for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):<br /> result[line.order_id.id] = True<br /> return result.keys()<br />
问题来了上面的代码是在sale.order里面的,他是根据sale.order.line的变化。而触发调不调用 _amount_all。但是_get_oeder里面的ids究竟是从何而来呢?是自动对应这个sale.order的sale.order.line吗?这里的_amount_all是任意一个sale.order.line变化就会触发,还是某个sale.order的sale.order.line变化才促发呢? -
> 问题来了上面的代码是在sale.order里面的,他是根据sale.order.line的变化。而触发调不调用 _amount_all。但是_get_oeder里面的ids究竟是从何而来呢?是自动对应这个sale.order的sale.order.line 吗?这里的_amount_all是任意一个sale.order.line变化就会触发,还是某个sale.order的 sale.order.line变化才促发呢?
这个问题太深入了,俺没深入调查源代码,只是凭经验回答。_get_order里面的ids从界面上来,是界面上当前Order的order.line的ids。因此,当前界面上的sale.order的任意一个 sale.order.line的变化,将会触发_amount_all的调用。 -
mark
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login