Problem with unfetched attribute with inherited screens

I have this model structure.

  • CommercialDocument
    • CommercialDocumentSales
      • CommercialDocumentSalesQuote
      • CommercialDocumentSalesBill
    • CommercialDocumentPurchases
      • … and so on…

Under CommecialDocument I have an attribute called “Third” (not sure if this is a good translation)
Third works this way.

  • Third
    • Customer
    • Provider

All seems to work fine, but…
Because I only want to show Customers on Sales Third lookup, and only want to show Providers on Purchases Third lookup I modified controller to change the datasource.

If you go to CommercialDocumentSalesBill and create a new bill, only customers are shown, and this is ok, and when save, it come back to Browse from where the record is shown correctly (on “third” column).
Problem comes If I close browse screen, and open CommercialDocumentSalesBill browse screen again. I get an error like:
IllegalStateException: Cannot get unfetched attribute [customerCode] from detached object

I understand this is related to the attribute not existing in some view, probably, in Browse screen View, but, I don’t want it there, in Browse I use “Third”, and only inside the Edit screen I change the datasource just to show only Customers or providers based on the screen I am.

Right now I solved it using 2 different fields in each subclass of second level, but I don’t see it elegant.