[MERGE]: Merged with trunk-addons.

bzr revid: uco@tinyerp.com-20100617050309-t7nuiyu6ns6i10qx
This commit is contained in:
uco (OpenERP)
2010-06-17 10:33:09 +05:30
22 changed files with 69 additions and 298 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: account
+1 -1
View File
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base_module_quality
+1 -1
View File
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: board
+1 -1
View File
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: google_map
+1 -1
View File
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: mrp_operations
+1 -1
View File
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: mrp_repair
+1 -1
View File
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: multi_company
+1 -1
View File
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: product
@@ -24,3 +24,5 @@
"access_account_sequence_fiscalyear_purchase_user","account.sequence.fiscalyear purchase","account.model_account_sequence_fiscalyear","group_purchase_user",1,1,1,1
"access_res_partner_purchase_user","res.partner purchase","base.model_res_partner","group_purchase_user",1,0,0,0
"access_res_partner_address_purchase_user","res.partner.address purchase","base.model_res_partner_address","group_purchase_user",1,0,0,0
"access_account_journal","account.journal","account.model_account_journal","purchase.group_purchase_user",1,1,1,0
"access_account_journal_manager","account.journal","account.model_account_journal","purchase.group_purchase_manager",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
24 access_account_sequence_fiscalyear_purchase_user account.sequence.fiscalyear purchase account.model_account_sequence_fiscalyear group_purchase_user 1 1 1 1
25 access_res_partner_purchase_user res.partner purchase base.model_res_partner group_purchase_user 1 0 0 0
26 access_res_partner_address_purchase_user res.partner.address purchase base.model_res_partner_address group_purchase_user 1 0 0 0
27 access_account_journal account.journal account.model_account_journal purchase.group_purchase_user 1 1 1 0
28 access_account_journal_manager account.journal account.model_account_journal purchase.group_purchase_manager 1 1 1 1
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem icon="terp-partner" id="base.menu_base_partner" name="Sales" sequence="0" groups="sale.group_sale_user"/>
<menuitem id="base.menu_sales" name="Sales" parent="base.menu_base_partner" sequence="1"/>
<menuitem id="base.menu_product" name="Products" parent="base.menu_base_partner" sequence="9"/>
+1 -1
View File
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: stock
+1 -1
View File
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-16 03:49+0000\n"
"X-Launchpad-Export-Date: 2010-06-17 03:33+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: stock
+3 -1
View File
@@ -50,4 +50,6 @@
"access_stock_replacement_result","stock.replacement.result","model_stock_replacement_result","stock.group_stock_user",1,1,1,1
"access_stock_ups","stock.ups","model_stock_ups","stock.group_stock_user",1,1,1,1
"access_stock_ups_final","stock.ups.final","model_stock_ups_final","stock.group_stock_user",1,1,1,1
"access_stock_ups_upload","stock.ups.upload","model_stock_ups_upload","stock.group_stock_user",1,1,1,1
"access_stock_ups_upload","stock.ups.upload","model_stock_ups_upload","stock.group_stock_user",1,1,1,1
"access_stock_split_into","stock.split.into","model_stock_split_into","stock.group_stock_user",1,1,1,0
"access_stock_split_into_manager","stock.split.into","model_stock_split_into","stock.group_stock_manager",1,1,1,1
Can't render this file because it contains an unexpected character in line 40 and column 53.
+45 -20
View File
@@ -632,15 +632,18 @@
<button
name="%(stock.track_line)d"
string="Split in production lots"
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
@@ -678,9 +681,11 @@
<newline/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"
groups="base.group_extended" />
<button name="%(move_scrap)d" string="Scrap Move Line" type="action" icon="gtk-justify-fill"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" />
<separator colspan="4" string="Move State"/>
<field name="state"/>
@@ -793,9 +798,11 @@
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
@@ -838,9 +845,12 @@
<field groups="base.group_extended" name="tracking_id"/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
<button name="%(track_line)d" string="Split in production lots"
groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<separator colspan="4" string="Move State"/>
@@ -994,9 +1004,11 @@
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize"
groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
@@ -1028,9 +1040,12 @@
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
<field groups="base.group_extended" name="tracking_id"/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"
groups="base.group_extended"
/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<label/>
@@ -1178,14 +1193,17 @@
<field name="prodlot_id" groups="base.group_extended"/>
<button
name="%(stock.track_line)d"
string="Split in production lots"
string="Split in production ii lots"
groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<field name="state"/>
@@ -1217,7 +1235,9 @@
<label/>
<button groups="base.group_extended" name="267" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="275" string="Split Stock Moves" type="action" icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}" states="draft,assigned,confirmed,done"/>
<button name="275" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}" states="draft,assigned,confirmed,done"/>
<separator colspan="4" string="Move State"/>
<field name="state"/>
<group colspan="2">
@@ -1366,17 +1386,18 @@
icon="gtk-convert" context="{'scrap': True}"
states="draft,waiting,confirmed,assigned" />
<field name="prodlot_id" groups="base.group_extended"/>
<button name="%(track_line)d" string="Split" type="action"
icon="gtk-justify-fill" attrs="{'invisible': [('prodlot_id','&lt;&gt;',False)]}"
<button name="%(track_line)d" string="Split in Production Lots" type="action"
icon="gtk-justify-fill"
states="assigned,confirmed"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
@@ -1436,9 +1457,12 @@
<newline/>
<group colspan="4" col="4">
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
<button name="%(track_line)d"
groups="base.group_extended"
string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
</group>
@@ -1531,10 +1555,12 @@
groups="base.group_extended"/>
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="date_planned"/>
@@ -1570,24 +1596,23 @@
<field name="date_expected"/>
<field name="priority"/>
<field name="address_id" context="{'contact_display':'partner'}"/>
<newline/>
<field name="picking_id"/>
<newline/>
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
<field groups="base.group_extended" name="tracking_id"/>
<newline/>
<field name="picking_id"/>
<group col="2" colspan="2">
<label/>
<button name="%(track_line)d" string="Split in production lots"
groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
</group>
<separator colspan="4" string="Move State"/>
<field name="state"/>
<group col="5" colspan="2">
+2 -2
View File
@@ -120,7 +120,7 @@
<group colspan="4" attrs="{'invisible':[('use_exist','=',True)]}">
<field name="line_ids" colspan="4" nolabel="1">
<tree string="Lots Number" editable="top">
<tree string="Lots Number" editable="bottom">
<field name="name" string="Lots"/>
<field name="quantity" />
</tree>
@@ -132,7 +132,7 @@
</group>
<group colspan="4" attrs="{'invisible':[('use_exist','!=',True)]}">
<field name="line_exist_ids" colspan="4" nolabel="1">
<tree string="Lots Number" editable="top">
<tree string="Lots Number" editable="bottom">
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
<field name="quantity" />
</tree>
+6 -6
View File
@@ -57,26 +57,26 @@ class stock_split_into(osv.osv_memory):
value_to_split = self.browse(cr, uid, data[0], context)
quantity = value_to_split.quantity or 0.0
ir_sequence_obj = self.pool.get('ir.sequence')
prodlot_obj = self.pool.get('stock.production.lot')
track_obj = self.pool.get('stock.tracking')
for move in move_obj.browse(cr, uid, rec_id):
move_qty = move.product_qty
uos_qty_rest = move.product_uos_qty
quantity_rest = move_qty - quantity
if quantity_rest == 0:
continue
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence}, {'product_id': move.product_id.id})
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.tracking')
tracking_id = track_obj.create(cr, uid, {'name': sequence}, {'product_id': move.product_id.id})
uos_qty = quantity / move_qty * move.product_uos_qty
uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
default_val = {
'product_qty': quantity,
'product_qty': quantity_rest,
'product_uos_qty': uos_qty,
'state': move.state
}
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
update_val['product_qty'] = quantity_rest
update_val['prodlot_id'] = prodlot_id
update_val['product_qty'] = quantity
update_val['tracking_id'] = tracking_id
update_val['product_uos_qty'] = uos_qty_rest
move_obj.write(cr, uid, [move.id], update_val)
return {}
-25
View File
@@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import stock_avg_consommation
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Stock Average consommation',
'version': '1.0',
'category': 'Generic Modules/Inventory Control',
'author': 'Tiny',
'depends': ['stock'],
'init_xml': [],
'update_xml': ['stock_avg_consommation_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,100 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
import ir
import pooler
from mx import DateTime
from datetime import datetime
import time
from dateutil.relativedelta import relativedelta
class stock_avg_consommation(osv.osv):
_name = "stock.avg.consommation"
_inherit="product.product"
def _compute_avg_consommation(self, cr, uid, ids, fields, args, context={}):
print ids, fields, args, context
date_str=False
from_date=context.get('from_date',False)
to_date=context.get('to_date',False)
if from_date and to_date:
date_str="date_planned>='%s' and date_planned<='%s'"%(from_date,to_date)
elif from_date:
date_str="date_planned>='%s'"%(from_date)
elif to_date:
date_str="date_planned<='%s'"%(to_date)
date_object_to = to_date and datetime.strptime(to_date, '%Y-%m-%d %H:%M:%S') or datetime.now()
date_object_from = from_date and datetime.strptime(from_date, '%Y-%m-%d %H:%M:%S') or (datetime.now() + relativedelta(days=-30))
dd = date_object_to - date_object_from
total_days=dd.days+1
if not from_date and not to_date:
date_str="date_planned>='%s' and date_planned<='%s'"%(date_object_from.strftime('%Y-%m-%d 00:00:00'), date_object_to.strftime('%Y-%m-%d 23:59:59'))
elif not from_date:
date_str="date_planned>='%s'"%(date_object_from.strftime('%Y-%m-%d 00:00:00'))
elif not to_date:
date_str="date_planned<='%s'"%(date_object_to.strftime('%Y-%m-%d 23:59:59'))
res={}
for line_id in ids:
res[line_id] = False
location_ids = []
if context.get('location', False):
if type(context['location']) == type(1):
location_ids = [context['location']]
elif type(context['location']) in (type(''), type(u'')):
location_ids = self.pool.get('stock.location').search(cr, uid, [('name','ilike',context['location'])], context=context)
else:
location_ids = context['location']
else:
location_ids = []
wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)
for w in self.pool.get('stock.warehouse').browse(cr, uid, wids, context=context):
location_ids.append(w.lot_stock_id.id)
# build the list of ids of children of the location given by id
if context.get('compute_child',True):
child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)])
location_ids = child_location_ids or location_ids
else:
location_ids = location_ids
#sql = """select product_id,sum(product_qty) from stock_move sm,stock_picking sp where sm.picking_id=sp.id and sp.type in ('out','delivery') and %s and location_id <> ANY(%s) and location_dest_id =ANY(%s) group by product_id""" % (date_str, location_ids, location_ids)
sql = """select product_id,sum(product_qty) from stock_move sm,stock_picking sp where sm.picking_id=sp.id and sp.type in ('out','delivery') and """+date_str+""" and sm.location_id not in %s and sm.location_dest_id in %s group by product_id"""
cr.execute(sql, [tuple(location_ids), tuple(location_ids)])
product_ids = []
res_sum = cr.fetchall()
for line_id, avg in res_sum:
res[line_id] = avg/total_days
product_ids.append(avg)
return res
_columns = {
'avg_consommation':fields.function(_compute_avg_consommation,method=True, type='float', string="Average Consommation"),
}
stock_avg_consommation()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,18 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="stock_avg_consommation_tree" model="ir.ui.view">
<field name="name">stock.avg.consommation.tree</field>
<field name="model">stock.avg.consommation</field>
<field name="type">tree</field>
<field name="inherit_id" ref="product.product_product_tree_view"/>
<field name="arch" type="xml">
<field name="state" position="after">
<field name="avg_consommation" />
</field>
</field>
</record>
</data>
</openerp>
@@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import stock_avg_consommation_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,57 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
class stock_location_product(osv.osv_memory):
_inherit = "stock.location.product"
def action_open_window(self, cr, uid, ids, context):
""" To open location wise product information specific to given duration
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: An ID or list of IDs if we want more than one
@param context: A standard dictionary
@return: Invoice type
"""
mod_obj = self.pool.get('ir.model.data')
view = mod_obj._get_id(cr, uid, 'stock_avg_consommation', 'stock_avg_consommation_tree')
id = mod_obj.read(cr, uid, view, ['res_id'])
for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']):
return {
'name': False,
'view_id':[id['res_id']],
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.avg.consommation',
'type': 'ir.actions.act_window',
'context': {'location': context['active_id'],
'from_date': location_obj['from_date'],
'to_date': location_obj['to_date']},
'domain': [('type', '<>', 'service')],
}
stock_location_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: