Re: [dabo-users] Production problem with granchild bizobj

Author: Paul McNett

Posted: 2011-12-06 at 17:08:46

On 12/3/11 7:03 AM, Nate Lowrie wrote:

> I have a problem with a production bizobj set I need help with.

>

> I have the following structure:

> Orders

> Order Line Items

> Order Line Item Options

>

> In order line items, I have a unit price with options as a virtual

> field. The code for the field function is below.

>

> def _getUnitPriceWithOptions(self):

> price = 0.0

> for record in self.orderLineItemOptionsBizobj.getDataSet():

> price += float(record["price"])

> return price + float(self.getFieldVal("unit_price"))

>

> My problem is that I expect the order line item options bizobj to get

> requeried for each line when the order line items are scanned through

> when they are loaded into the grid. This is definitely not happening

> and it was working a bit ago. As a result, the options for the first

> line item are being applied to all line items and options for all the

> other line items are ignored because the bizobj never requeries on the scan.

There are potentially two things going on here. First, you mentioned a grid. Grids

get the values to display by calling biz.getFieldVal(fld, row), IOW they send the row

number to getFieldVal. By default, getFieldVal() won't update the children in this

case, so the grid will show the wrong calculated value if the calculation relies on

the children. To override this, you change your VirtualField definition from this:

class MyBiz(...):

def initProperties(...):

self.VirtualFields["myfield"] = self.getMyField

to:

self.VirtualFields["myfield"] = {"func": self.getMyField, "requery_children": True}

The second thing could be an unintended consequence of recent changes, so if you try

the above and see no improvement, please let us know.

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/4EDE926E.3010208@ulmcnett.com

©2011 Paul McNett