modifs
authorFabien Pinckaers <fp@tinyerp.com>
Wed, 17 Sep 2008 07:49:51 +0000 (09:49 +0200)
committerFabien Pinckaers <fp@tinyerp.com>
Wed, 17 Sep 2008 07:49:51 +0000 (09:49 +0200)
bzr revid: fp@tinyerp.com-20080917074951-b7z409hh5rafzm0g

1  2 
addons/process/process.py
addons/stock/report/__init__.py
addons/stock/report/product_location.py
addons/stock/report/product_location.xsl
addons/stock/report_stock_view.xml
addons/stock/stock.py
addons/stock/stock_report.xml
addons/stock/stock_view.xml

@@@ -45,12 -45,12 +45,9 @@@ class process_process(osv.osv)
      }
  
      def graph_get(self, cr, uid, id, res_model, res_id, scale, context):
--        
          pool = pooler.get_pool(cr.dbname)
--
          process = pool.get('process.process').browse(cr, uid, [id])[0]
          current_object = pool.get(res_model).browse(cr, uid, [res_id])[0]
--
          nodes = {}
          start = []
          transitions = {}
                  pass
  
              nodes[node.id] = data
--
              if node.flow_start:
                  start.append(node.id)
  
              for tr in node.transition_ids:
                  data = {}
                  data['name'] = tr.name
                  data['source'] = tr.source_node_id.id
                  data['target'] = tr.target_node_id.id
--
                  data['buttons'] = buttons = []
                  for b in tr.action_ids:
                      button = {}
                      button['name'] = b.name
                      buttons.append(button)
--
                  data['roles'] = roles = []
                  for r in tr.role_ids:
                      role = {}
                      role['name'] = r.name
                      roles.append(role)
--                    
                  transitions[tr.id] = data
  
          g = tools.graph(nodes.keys(), map(lambda x: (x['source'], x['target']), transitions.values()))
          g.process(start)
          #g.scale(100, 100, 180, 120)
          g.scale(*scale)
--
          graph = g.result_get()
          miny = -1
  
          for k,v in nodes.items():
--
              x = graph[k]['y']
              y = graph[k]['x']
--
              if miny == -1:
                  miny = y
--
              miny = min(y, miny)
--
              v['x'] = x
              v['y'] = y
  
          for k, v in nodes.items():
              y = v['y']
              v['y'] = min(y - miny + 10, y)
--
          return dict(nodes=nodes, transitions=transitions)
  
  process_process()
@@@ -165,8 -165,8 +150,6 @@@ class process_transition(osv.osv)
          'role_ids': fields.many2many('res.roles', 'process_transition_roles_rel', 'process_transition_id', 'role_id', 'Roles Required'),
          'note': fields.text('Description'),
      }
--    _defaults = {
--    }
  process_transition()
  
  class process_transition_action(osv.osv):
      }
  process_transition_action()
  
--
--
--
--# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--
@@@ -30,7 -30,7 +30,6 @@@
  
  #import lot_overview
  import product_stock
--import product_location
  import lot_location
  import ups
  import picking
diff --cc addons/stock/report/product_location.py
index 1128d05,1128d05..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,78 -1,78 +1,0 @@@
--# -*- encoding: utf-8 -*-
--##############################################################################
--#
--# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
--#
--# $Id$
--#
--# WARNING: This program as such is intended to be used by professional
--# programmers who take the whole responsability of assessing all potential
--# consequences resulting from its eventual inadequacies and bugs
--# End users who are looking for a ready-to-use solution with commercial
--# garantees and support are strongly adviced to contract a Free Software
--# Service Company
--#
--# This program is Free Software; you can redistribute it and/or
--# modify it under the terms of the GNU General Public License
--# as published by the Free Software Foundation; either version 2
--# of the License, or (at your option) any later version.
--#
--# This program is distributed in the hope that it will be useful,
--# but WITHOUT ANY WARRANTY; without even the implied warranty of
--# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--# GNU General Public License for more details.
--#
--# You should have received a copy of the GNU General Public License
--# along with this program; if not, write to the Free Software
--# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
--#
--##############################################################################
--
--from report.interface import report_rml
--from report.interface import toxml
--import pooler
--
--
--class report_custom(report_rml):
--
--    def create_xml(self, cr, uid, ids, datas, context=None):
--        pool = pooler.get_pool(cr.dbname)
--        product_obj = pool.get('product.product')
--        location_obj = pool.get('stock.location')
--
--        products = product_obj.read(cr, uid, ids, ['name','uom_id'])
--        cr.execute('SELECT id FROM stock_location WHERE usage = %s',
--                ('internal',))
--        location_ids = [ x[0] for x in cr.fetchall() ]
--        location_ids.sort()
--        locs_info = {}
--        locs_name = dict(location_obj.name_get(cr, uid, location_ids))
--        for location_id in locs_name.keys():
--            locs_info[location_id] = location_obj._product_get(cr, uid,
--                    location_id, ids)
--
--        xml = '<?xml version="1.0" ?><report>'
--        for p in products:
--            xml += '<product>' \
--                '<name>' + toxml(p['name']) + '</name>' \
--                '<unit>' + toxml(p['uom_id'][1]) + '</unit>' \
--                '<locations>'
--            for loc_id in locs_info.keys():
--                if locs_info[loc_id].get(p['id']):
--                    xml += '<location>'
--                    xml += '<loc_name>' + toxml(locs_name[loc_id]) \
--                            + '</loc_name>'
--                    xml += '<loc_qty>' + toxml(locs_info[loc_id].get(p['id'])) \
--                            + '</loc_qty>'
--                    xml += '</location>'
--            xml += '</locations>' \
--                '</product>'
--        xml += '</report>'
--        return self.post_process_xml_data(cr, uid, xml, context)
--
--report_custom('report.stock.product.location', 'stock.location', '',
--        'addons/stock/report/product_location.xsl')
--
--
--# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--
diff --cc addons/stock/report/product_location.xsl
index d5e1731,d5e1731..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,78 -1,78 +1,0 @@@
--<?xml version="1.0" encoding="utf-8"?>
--<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
--
--      <xsl:import href="../../custom/corporate_defaults.xsl"/>
--      <xsl:import href="../../base/report/rml_template.xsl"/>
--      <xsl:variable name="page_format">a4_normal</xsl:variable>
--
--      <xsl:template match="/">
--              <xsl:call-template name="rml"/>
--      </xsl:template>
--
--      <!-- stylesheet -->
--
--      <xsl:template name="stylesheet">
--              <paraStyle name="title" fontName="Helvetica-Bold" fontSize="12" alignment="center"/>
--              <blockTableStyle id="headerm">
--                      <blockBackground colorName="grey" start="0,0" stop="-1,0"/>
--                      <blockValign value="TOP"/>
--                       <blockAlignment value="CENTER"/>
--                       <lineStyle kind="GRID" colorName="black"/>
--              </blockTableStyle>
--              <blockTableStyle id="header">
--                      <blockBackground colorName="lightgrey" start="0,0" stop="-1,0"/>
--                      <blockValign value="TOP"/>
--                      <blockAlignment value="RIGHT" start="-1,0" stop="-1,-1"/>
--                      <lineStyle kind="GRID" colorName="black"/>
--              </blockTableStyle>
--</xsl:template>
--
--      <xsl:template name="story">
--              <xsl:apply-templates select="report"/>
--      </xsl:template>
--      
--      <xsl:template match="report">
--              <xsl:apply-templates select="product"/>
--      </xsl:template>
--
--      <xsl:template match="product">
--              <blockTable style="headerm" colWidths="15cm">
--              <tr>
--                      <td>
--                              <para style="title">
--                                      <xsl:value-of select="name"/>
--                                      <xsl:text> (</xsl:text>
--                                      <xsl:value-of select="unit"/>
--                                      <xsl:text>)</xsl:text>
--                              </para>
--                      </td>
--              </tr>
--              </blockTable>
--              <xsl:apply-templates select="locations"/>
--              <spacer length="5mm" width="5mm"/>
--      </xsl:template>
--
--      <xsl:template match="locations">
--              <blockTable style="header" colWidths="12cm,3cm">
--              <tr>
--                      <td t="1">Location</td>
--                      <td t="1">Quantity</td>
--              </tr>
--              <xsl:apply-templates select="location"/>
--              </blockTable>
--      </xsl:template>
--
--      <xsl:template match="location">
--              <tr>
--                      <td>
--                              <para>
--                                      <xsl:value-of select="loc_name"/>
--                              </para>
--                      </td>
--                      <td>
--                                      <xsl:value-of select="loc_qty"/>
--                      </td>
--              </tr>
--      </xsl:template>
--
--</xsl:stylesheet>
@@@ -1,36 -1,36 +1,69 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
      <data>
--        
++
          <record id="stock_report_prodlots_tree" model="ir.ui.view">
              <field name="name">stock.report.prodlots.view</field>
              <field name="model">stock.report.prodlots</field>
              <field name="type">tree</field>
              <field name="arch" type="xml">
--                <tree string="Stock by production lots">
--                    <field name="location_id" select="1"/>
--                    <field name="product_id" select="1"/>
--                    <field name="prodlot_id" select="1"/>
++                <tree string="Stock by Lots">
++                    <field name="location_id"/>
++                    <field name="product_id"/>
++                    <field name="prodlot_id"/>
                      <field name="name"/>
                  </tree>
              </field>
          </record>
--        
          <record id="action_stock_report_prodlots_form" model="ir.actions.act_window">
--            <field name="name">Stock by production lots</field>
++            <field name="name">Stock by Lots</field>
              <field name="type">ir.actions.act_window</field>
              <field name="res_model">stock.report.prodlots</field>
              <field name="view_type">form</field>
              <field name="view_mode">form,tree</field>
          </record>
--        
--        <menuitem id="next_id_61" name="Reporting" parent="stock.menu_stock_root"/><menuitem id="next_id_62" name="Traceability" parent="next_id_61"/><menuitem action="action_stock_report_prodlots_form" id="menu_stock_report_prodlots" parent="next_id_62"/>
--        
--        <act_window domain="[('location_id', '=', active_id)]" id="act_stock_location_2_stock_report_prodlots" name="Stock by production lots" res_model="stock.report.prodlots" src_model="stock.location"/>
--        
--        <act_window domain="[('product_id', '=', active_id)]" id="act_product_product_2_stock_report_prodlots" name="Stock by production lots" res_model="stock.report.prodlots" src_model="product.product"/>
--        
--        <act_window domain="[('prodlot_id', '=', active_id)]" id="act_stock_production_lot_2_stock_report_prodlots" name="Stock" res_model="stock.report.prodlots" src_model="stock.production.lot"/>
--        
++
++        <menuitem
++            id="next_id_61"
++            name="Reporting"
++            parent="stock.menu_stock_root"/>
++
++        <menuitem
++            id="next_id_62"
++            name="Traceability"
++            parent="next_id_61"/>
++
++        <menuitem
++            action="action_stock_report_prodlots_form"
++            id="menu_stock_report_prodlots"
++            parent="next_id_62"/>
++
++        <act_window
++            context="{'product_id': active_id}"
++            id="act_stock_product_location_open"
++            name="Stock by Location"
++            res_model="stock.location"
++            src_model="product.product"/>
++
++        <act_window
++            domain="[('location_id', '=', active_id)]"
++            id="act_stock_location_2_stock_report_prodlots"
++            name="Stock by Lots"
++            res_model="stock.report.prodlots"
++            src_model="stock.location"/>
++
++        <act_window
++            domain="[('product_id','=',active_id)]"
++            id="act_product_product_2_stock_report_prodlots"
++            name="Stock by Lots"
++            res_model="stock.report.prodlots"
++            src_model="product.product"/>
++
++        <act_window
++            domain="[('prodlot_id', '=', active_id)]" 
++            id="act_stock_production_lot_2_stock_report_prodlots" 
++            name="Stock" res_model="stock.report.prodlots"
++            src_model="stock.production.lot"/>
++
      </data>
  </openerp>
@@@ -61,12 -61,12 +61,34 @@@ class stock_location(osv.osv)
      _name = "stock.location"
      _description = "Location"
      _parent_name = "location_id"
++    _parent_store = True
++    _parent_order = 'name'
++    _order = 'parent_left'
++
++    def _complete_name(self, cr, uid, ids, name, args, context):
++        def _get_one_full_name(location, level=4):
++            if level<=0:
++                return '...'
++            if location.location_id:
++                parent_path = _get_one_full_name(location.location_id, level-1) + "/"
++            else:
++                parent_path = ''
++            return parent_path + location.name
++        res = {}
++        for m in self.browse(cr, uid, ids, context=context):
++            res[m.id] = _get_one_full_name(m)
++        return res
++
      _columns = {
          'name': fields.char('Location Name', size=64, required=True, translate=True),
          'active': fields.boolean('Active'),
--        'usage': fields.selection([('supplier','Supplier Location'),('view','View'),('internal','Internal Location'),('customer','Customer Location'),('inventory','Inventory'),('procurement','Procurement'),('production','Production')], 'Location type'),
++        'usage': fields.selection([('supplier','Supplier Location'),('view','View'),('internal','Internal Location'),('customer','Customer Location'),('inventory','Inventory'),('procurement','Procurement'),('production','Production')], 'Location type', required=True),
          'allocation_method': fields.selection([('fifo','FIFO'),('lifo','LIFO'),('nearest','Nearest')], 'Allocation Method', required=True),
  
++        'complete_name': fields.function(_complete_name, method=True, type='char', size=100, string="Location Name"),
++        #'qty_available': fields.function(_product_qty_available, method=True, type='float', string='Real Stock'),
++        #'virtual_available': fields.function(_product_virtual_available, method=True, type='float', string='Virtual Stock'),
++
          'account_id': fields.many2one('account.account', string='Inventory Account', domain=[('type','!=','view')]),
          'location_id': fields.many2one('stock.location', 'Parent Location', select=True),
          'child_ids': fields.one2many('stock.location', 'location_id', 'Contains'),
@@@ -377,7 -377,7 +399,7 @@@ class stock_picking(osv.osv)
  
      _columns = {
          'name': fields.char('Reference', size=64, required=True, select=True),
--        'origin': fields.char('Origin', size=64),
++        'origin': fields.char('Origin Reference', size=64),
          'backorder_id': fields.many2one('stock.picking', 'Back Order'),
          'type': fields.selection([('out','Sending Goods'),('in','Getting Goods'),('internal','Internal'),('delivery','Delivery')], 'Shipping Type', required=True, select=True),
          'active': fields.boolean('Active'),
              ("invoiced","Invoiced"),
              ("2binvoiced","To be invoiced"),
              ("none","Not from Packing")], "Invoice Status", 
--            select=True),
++            select=True, required=True),
      }
      _defaults = {
          'name': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'stock.picking'),
@@@ -13,8 -13,8 +13,6 @@@
          
          <report auto="False" id="report_lot_location" model="stock.location" name="lot.location" rml="stock/report/lot_location.rml" string="Lots by location"/>
          
--        <report auto="False" id="report_product_location" model="product.product" name="stock.product.location" string="Products Localisations"/>
--        
          <report id="report_location_overview_all" model="stock.location" name="stock.location.overview.all" string="Location Content (With childs)" xml="stock/report/lot_overview_all.xml" xsl="stock/report/lot_overview_all.xsl"/>
      
      </data>
          </record>
          <menuitem action="action_inventory_form" id="menu_action_inventory_form" parent="menu_stock_root"/>
  
--        <record id="action_inventory_line_form" model="ir.actions.act_window">
--            <field name="name">Inventory Lines</field>
++        <record id="action_inventory_form_draft" model="ir.actions.act_window">
++            <field name="name">Draft Physical Inventories</field>
              <field name="type">ir.actions.act_window</field>
--            <field name="res_model">stock.inventory.line</field>
++            <field name="res_model">stock.inventory</field>
              <field name="view_type">form</field>
--            <field name="view_mode">tree,form</field>
--            <field name="view_id" ref="stock_inventory_line_tree"/>
++            <field name="domain">[('state','=','draft')]</field>
          </record>
--        <menuitem action="action_inventory_line_form" groups="base.group_extended" id="menu_action_inventory_line_form" parent="menu_action_inventory_form"/>
++        <menuitem action="action_inventory_form_draft" id="menu_action_inventory_form_draft" parent="menu_action_inventory_form"/>
++        <record id="action_inventory_form_new" model="ir.actions.act_window">
++            <field name="name">New Physical Inventory</field>
++            <field name="type">ir.actions.act_window</field>
++            <field name="res_model">stock.inventory</field>
++            <field name="view_type">form</field>
++            <field name="view_mode">form,tree</field>
++        </record>
++        <menuitem action="action_inventory_form_new" id="menu_action_inventory_form_new" parent="menu_action_inventory_form"/>
  
  
          =============================
              <field name="model">stock.location</field>
              <field name="type">tree</field>
              <field name="arch" type="xml">
--                <tree string="Stock location">
--                    <field name="name"/>
++                <tree string="Stock location" colors="blue:usage=='internal'">
++                    <field name="complete_name"/>
                      <field name="usage"/>
                      <field name="account_id"/>
                      <field name="active"/>
                          <field name="origin" select="2"/>
                          <field name="invoice_state" select="2" string="Invoice Control"/>
                          <field name="name" readonly="1" select="1"/>
--                        <field name="min_date" select="2"/>
++                        <field name="min_date" select="2" readonly="1"/>
                      </group>
                      <notebook colspan="4">
                          <page string="General Information">