Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

lino.utils.mti

A collection of tools around multi-table inheritance.

See Multi-table inheritance.

See also lino.mixins.polymorphic.

Functions

delete_child(obj, child_model[, ar, using])

Delete the child_model instance related to obj without deleting the parent obj itself.

get_child(obj, child_model)

insert_child(obj, child_model[, full_clean])

Create and save an instance of child_model from existing obj.

mtichild(p, model, **kw)

Create an MTI child, optionally set some attributes, save it to the database and then return the new database object.

Classes

ChildCollector(using[, origin])

A Collector that does not delete the MTI parents.

EnableChild(child_model, **kw)

Rendered as a checkbox that indicates whether an mti child of the given model exists.

class lino.utils.mti.ChildCollector(using, origin=None)

Bases: Collector

A Collector that does not delete the MTI parents.

lino.utils.mti.delete_child(obj, child_model, ar=None, using=None)

Delete the child_model instance related to obj without deleting the parent obj itself.

lino.utils.mti.insert_child(obj, child_model, full_clean=False, **attrs)

Create and save an instance of child_model from existing obj.

If full_clean is True, call full_clean on the newly created object. Default is False because this was the historic behaviour.

lino.utils.mti.mtichild(p, model, **kw)

Create an MTI child, optionally set some attributes, save it to the database and then return the new database object.

class lino.utils.mti.EnableChild(child_model, **kw)

Bases: VirtualField

Rendered as a checkbox that indicates whether an mti child of the given model exists.

Deprecated. Use polymorphic.Polymorphic instead.

is_enabled(lh)

When a FormLayout is inherited by an MTI child, EnableChild fields must be disabled.

has_child(obj, request=None)

Returns True if obj has an MTI child in self.child_model. The optional 2nd argument request (passed from VirtualField.value_from_object) is ignored.