=========================
Tuesday, January 27, 2015
=========================

Documentation is getting better
===============================

More tidy-up routine work in the documentation.

There was yet another problem ("choicelists.get_by_name expected
string") due to a bug in
:attr:`lino.modlib.vat.Plugin.default_vat_class`.

I finally created the plugin :mod:`lino.modlib.office`.

And yet another tutorial: :lino:`/tutorials/addrloc/index`.

And I moved the :attr:`country_code
<lino.modlib.countries.Plugin.country_code>` setting from
:mod:`lino.modlib.vat` to :mod:`lino.modlib.countries`.


Convert Partner to Person
=========================

Worked for :ticket:`80` (Convert Partner to Person). 

How to reproduce it:

- go to the directory of :mod:`lino.projects.min1`
- run `initdb_demo` and `runserver`
- Create a Partner. Lino opens the detail window on that partner.
- Check the "is Person" checkbox and click Save button.
- Click the "(show)" link in order to see the person.
- Fields `first_name` and `last_name` are empty.

The solution was rather complex and tricky:

- The :meth:`full_clean <lino.core.model.Model.full_clean>` method of
  :class:`lino.modlib.contacts.models.Person` now reacts if `first_name`
  and `last_name` are both empty and `name` is *not* empty. In that case
  it uses :func:`lino.modlib.contacts.utils.name2kw` to fill both
  fields.

- :class:`lino.utils.mti.EnableChild`
  now calls 
  :func:`lino.utils.mti.insert_child` 
  with the new keyword parameter `full_clean`.
  Which has the effect of calling
  :meth:`full_clean <lino.core.model.Model.full_clean>` 
  on the new child.

- New function :func:`lino.core.utils.error2str` with the side effect
  that messages caused by `ValidationError` are now reported in a more
  user-friendly way.