Tuesday, September 29, 2015

Reproducing #219

Hamza could not reproduce #219 using my instructions, so I checked them for possible misunderstandings and try to formulate them again:

You can reproduce it easily in our Mio or in the public online demo of Noi at http://team.lino-framework.org as follows:

  • Log in e.g. as “jean” or “robin”
  • Open the list of tickets using the `[Tickets]` quick link
  • Click “Create” (“Insert a new record”) button and confirm the dialog window to create a new ticket
  • In the detail window, in the Workflow panel, click on Confirmed
  • Note that Lino seems to fail to update the state of your ticket (it remains at New).
  • Hit ESCAPE to close the window
  • You can see now that Lino has created your ticket twice instead of only once. The first ticket is Confirmed while the second tcket is New.

If you watch the network traffic using the web console of your browser, then you can see that the click on “Confirmed” caused a HTTP call with method POST. This is the problem. This POST should have been a GET.

You can find the definition of Lino.tickets.Tickets.wf3 in the generated javascript file which is referenced in the page’s source code:

<script type="text/javascript"

This file has been generated by lino.modlib.extjs.ext_renderer.ExtRenderer.write_lino_js() (and more precisely by js_render_custom_action() (I guess).

The link URL (i.e. javascript:Lino.tickets.Tickets.wf3(“ext-comp-1074”,18,{})) is generated by Python code in lino.core.model.Model.workflow_buttons which calls lino.core.requests.BaseRequest.action_button() which calls lino.modlib.extjs.ext_renderer.ExtRenderer.action_button() which calls a myriad of rather chaotic methods like get_panel_btn_handler and so on.

This ticket is in the heart of Lino. This code is historically grown and not beautiful. Don’t panic. Fixing this ticket will be probably just one line of code. The challenge is to understand the complex interaction between Python and Javascript.

Debugging generated Javascript code

Hamza wrote:

I make some js breakpoints and I following the tracelog until this function js_render_custom_action. I get a simple error. When I want to edit that function (or an other which deal with the js and extjs), this don’t work for me even when I used a new private chrome session to avoid cache problems.

I started a document Debugging generated ExtJS Javascript code where I plan to centralize useful hints about this situation.

How to manage movement clearing

This is the first time that tim2lino must import accounting data. So as expected there are some surprises.

I tidied up most test suites (except Renamed “Lino Faggio” to “Lino Voga” which can wait) and checked in because I needed to think about how to import the match field of movements. This field was a CharField (similar to the approach used in TIM) until some months ago. Why did I change it into a pointer to Movement?

The (current) Lino approach has some disadvantages compared to the TIM approach:

  • what happens when the user deletes or unregisters a cleared voucher
  • we need groupers (lino_cosi.lib.finan.models.Grouper) in order to manage grouped payments
  • tim2lino will have hard work to convert clearings from TIM to Lino

But the new approach seems really better because

  • it is 3NF
  • it allows to handle clearing at multiple levels (which will probably be used in Lino Welfare)