def upgrade(tool): # Hack prevent out-of-date upgrading # Related: PR #1484 # https://github.com/bikalabs/Bika-LIMS/pull/1484 from lims.upgrade import skip_pre315 if skip_pre315(aq_parent(aq_inner(tool))): return True portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') stub('bika.lims.content.invoicelineitem', 'InvoiceLineItem', BaseContent) for inv in portal['invoices'].objectValues(): inv.invoice_lineitems = [] for invl in inv.objectValues(): item = dict( ItemDate=invl.ItemDate, ItemDescription=invl.ItemDescription, ClientOrderNumber=invl.ClientOrderNumber, Subtotal=invl.Subtotal, VATAmount=invl.VATAmount, Total=invl.Total, ) inv.invoice_lineitems.append(item) return True
def upgrade(tool): # Hack prevent out-of-date upgrading # Related: PR #1484 # https://github.com/bikalabs/Bika-LIMS/pull/1484 from lims.upgrade import skip_pre315 if skip_pre315(aq_parent(aq_inner(tool))): return True portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') stub('bika.lims.content.pricelistlineitem', 'PricelistLineItem', BaseContent) for pl in portal['pricelists'].objectValues(): pl.pricelist_lineitems = [] for pli in pl.objectValues(): item = dict( title=pli.title, ItemDescription=pli.ItemDescription, Accredited=pli.Accredited, Subtotal="%d.%d" % (pli.Subtotal[0], pli.Subtotal[1]), VATAmount="%d.%d" % (pli.VATAmount[0], pli.VATAmount[1]), Total="%d.%d" % (pli.Total[0], pli.Total[1]), CategoryTitle=pli.CategoryTitle, ) pl.pricelist_lineitems.append(item) return True
def LIMS1519(portal): """Migrate Archetypes SupplyOrderItem into a list of dictionaries. """ stub('bika.lims.content.supplyorderitem', 'SupplyOrderItem', BaseContent) for order in portal['supplyorders'].objectValues(): order.supplyorder_lineitems = [] for soli in order.objectValues(): item = dict( Product=soli.Product, Quantity=soli.Quantity, Price=soli.Price, VAT=soli.VAT, ) order.supplyorder_lineitems.append(item)