On 11/28/2013 10:52 AM, Ricardo Aráoz wrote:
lookupPKWithAdd adds a record to the Bizobj, but in this case it raises "IvaFc.FacturaId may not be NULL". As you can see below this Bizobj is a child Bizobj with FillLinkFromParent set to True, so FacturaId should have been automatically added (as it effectively is when new() is issued).
For some context:
Factura = Invoice
Fc = Inv
Iva = VAT

Parent Bizobj:
    def addChildren(self):
        app = self.Application
        self.ItemFc = ItemFc(app.dbConnection)
        self.addChild(self.ItemFc)
        self.PagoFc = PagoFc(app.dbConnection)
        self.addChild(self.PagoFc)
        self.IvaFc = IvaFc(app.dbConnection)
        self.addChild(self.IvaFc)

Child Bizob:
class IvaFc(Base):
    def initProperties(self):
        super(IvaFc, self).initProperties()
        self.Caption = "IvaFc"
        self.DataSource = "IvaFc"
        self.KeyField = "Id"
        self.LinkField = 'FacturaId'
        self.FillLinkFromParent = True

Code line that provokes the exception:
        bizIvaFc.moveToPK(bizIvaFc.lookupPKWithAdd('IvaId',
self.IvaId.prevKey))

Exception :
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/ui/uiwx/dControlItemMixin.py", line 34, in _onWxHit
    super(dControlItemMixin, self)._onWxHit(evt)
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/ui/uiwx/dDataControlMixin.py", line 13, in _onWxHit
    super(dDataControlMixin, self)._onWxHit(evt, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/ui/uiwx/dControlMixin.py", line 27, in _onWxHit
    self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/ui/uiwx/dPemMixin.py", line 1084, in raiseEvent super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/lib/eventMixin.py", line 81, in raiseEvent
    bindingFunction(event)
File "/home/richie/Python/Contable/contab/ui/PagEditFactura.py", line 224, in actIva
    self.IvaId.prevKey))
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/biz/dBizobj.py", line 2076, in lookupPKWithAdd
    return self._CurrentCursor.lookupPKWithAdd(field, val)
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/db/dCursorMixin.py", line 1137, in lookupPKWithAdd
    aux.execute(sql, (val,))
File "/usr/local/lib/python2.7/dist-packages/Dabo-0.9.13-py2.7.egg/dabo/db/dCursorMixin.py", line 380, in execute
    raise dException.DBQueryException(errMsg)
dabo.dException.DBQueryException: DBQueryException encountered in execute(): IvaFc.FacturaId may not be NULL


Looking at the code, the method "lookupPKWithAdd()" in dCursorMixin, I see a direct SQL insert and NOT a bizobj.new(). Doing a direct insert bypasses the Dabo new routines. The comments suggest that the routine does not effect the current dataset which is another clue. I would have to say the code is intended.

To fix your problem just write a method that does as you would expect.
Johnf

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to