title: Odoo / Postgres: Concatenate rows value until condition = true
body: <p>I'm creating a new view for a customized PoS module for my restaurant. It's a specific view for kitchen, already filtered to show just kitchen's related items of a PoS order.<br/>
  Now I would like to show a particular series of product with the name starting with "#" in a field populated by a function side by side with the "standard" products. In fact I'm speaking of a set of instructions coded as products to be available on PoS and to suit my needs I decided to create kitchen instructions as a product (service). In my PoS there are 3 categories that are not products but instructions (ADD, SUBTRACT, ADDITIONAL NOTE).<br/><br/></p>
  
  <p>A typical order will show as:<br/></p>
  
  <pre><code>Product                    Quantity 
  [1007] Pom. Secchi                1
  # + Búfala                        1
  # - Mussarela                     1
  [2002] Nutella banana             1
  # + Mussarela                     1
  </code></pre>
  
  <p>What I would like to archive is a view like:<br/></p>
  
  <pre><code>Product                  Note                        Quantity 
  [1007] Pom. Secchi       # + Búfala # - Mussarela           1
  [2002] Nutella banana    # + Mussarela                      1
  </code></pre>
  
  <p>I need to select just the strings starting with the "#" between two internal code starting with "[code]" and this is the hard thing to do. I don't need to delete the values I "move" because I need the stock view when I print the receipt.<br/>
  I will call this function using python (and psycopg2 on postgresql 9.4) with on_change or extending the workflow when an order is marked as "paid". I don't think if doing it directly in Python is viable.
  I've tried with <pre>string_agg(,)</pre> but with bad results.<br/> 
  Any tips about what should be the correct path to start coding? Thanks.</p>