bzr revid: fp@tinyerp.com-20090121130518-7sx5szls9f2rzvd7
This commit is contained in:
Fabien Pinckaers 2009-01-21 14:05:18 +01:00
commit 0b7023326a
20 changed files with 155 additions and 84 deletions

View File

@ -40,42 +40,22 @@
<workflow action="invoice_open" model="account.invoice" ref="test_invoice_1"/>
<!--
<assert id="test_invoice_1" model="account.invoice" string="Test invoice 1 is now open">
<test expr="state">open</test>
</assert>
-->
<!--
journal_id: bank_journal
period_id: period_7 (or 'period_' +time.strftime('m'))
pay_amount: 1850 (or amount_total)
acc_id = pool.get('account.journal').browse(cr, uid, journal_id, context).default_credit_account_id.id
pay_and_reconcile(self, cr, uid,
ids,
pay_amount,
pay_account_id,
period_id,
pay_journal_id,
writeoff_acc_id,
writeoff_period_id,
writeoff_journal_id,
context={}):
-->
<!--
<function model="account.invoice" name="pay_and_reconcile">
<value eval="[ref('test_invoice_1')]"/>
<value eval="1850"/>
<value eval="ref('cash')"/>
<value eval="ref('account.period_' + str(int(time.strftime('%m'))))"/>
<value eval="ref('bank_journal')"/>
<value eval="ref('cash')"/>
<value eval="ref('account.period_' + str(int(time.strftime('%m'))))"/>
<value eval="ref('bank_journal')"/>
<!-- ids = --> <value eval="[ref('test_invoice_1')]"/>
<!-- pay_amount = --> <value eval="1850"/>
<!-- pay_account_id = --> <value eval="ref('cash')"/>
<!-- period_id = --> <value eval="ref('account.period_' + str(int(time.strftime('%m'))))"/>
<!-- pay_journal_id = --> <value eval="ref('bank_journal')"/>
<!-- writeoff_acc_id = --> <value eval="ref('cash')"/>
<!-- writeoff_period_id = --> <value eval="ref('account.period_' + str(int(time.strftime('%m'))))"/>
<!-- writeoff_journal_id = --> <value eval="ref('bank_journal')"/>
</function>
<assert id="test_invoice_1" model="account.invoice" string="Test invoice 1 is now paid">
<test expr="state">paid</test>
</assert>
-->
</data>
</openerp>

View File

@ -196,11 +196,11 @@ class account_invoice(osv.osv):
('in_refund','Supplier Refund'),
],'Type', readonly=True, select=True),
'number': fields.char('Invoice Number', size=32, readonly=True, help="Uniq number of the invoice, computed automatically when the invoice is created."),
'number': fields.char('Invoice Number', size=32, readonly=True, help="Unique number of the invoice, computed automatically when the invoice is created."),
'reference': fields.char('Invoice Reference', size=64, help="The partner reference of this invoice."),
'reference_type': fields.selection(_get_reference_type, 'Reference Type',
required=True),
'comment': fields.text('Additionnal Information'),
'comment': fields.text('Additional Information'),
'state': fields.selection([
('draft','Draft'),
@ -208,7 +208,7 @@ class account_invoice(osv.osv):
('proforma2','Pro-forma'),
('open','Open'),
('paid','Done'),
('cancel','Canceled')
('cancel','Cancelled')
],'State', select=True, readonly=True),
'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}),
@ -284,7 +284,7 @@ class account_invoice(osv.osv):
'reference_type': lambda *a: 'none',
}
def unlink(self, cr, uid, ids):
def unlink(self, cr, uid, ids, context=None):
invoices = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for t in invoices:
@ -292,7 +292,7 @@ class account_invoice(osv.osv):
unlink_ids.append(t['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) which are already opened or paid !'))
osv.osv.unlink(self, cr, uid, unlink_ids)
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True
# def get_invoice_address(self, cr, uid, ids):
@ -429,6 +429,7 @@ class account_invoice(osv.osv):
for taxe in ait_obj.compute(cr, uid, id).values():
ait_obj.create(cr, uid, taxe)
# Update the stored value (fields.function), so we write to trigger recompute
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
return True
@ -622,7 +623,7 @@ class account_invoice(osv.osv):
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
if journal.centralisation:
raise osv.except_osv(_('UserError'),
_('Can not create invoice move on centralized journal'))
_('Can not create invoice move on centralised journal'))
move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date}
period_id=inv.period_id and inv.period_id.id or False
if not period_id:

View File

@ -236,7 +236,7 @@ class account_report_history(osv.osv):
cr.execute('''create or replace view account_report as (select ar.id as tmp,((pr.id*100000)+ar.id) as id,ar.id as name,pr.id as period_id,pr.fiscalyear_id as fiscalyear_id from account_report_report as ar cross join account_period as pr group by ar.id,pr.id,pr.fiscalyear_id)''')
def unlink(self, cr, uid, ids, context={}):
raise osv.except_osv(_('Error !'), _('You can not delete an indicator history record. You may have to delete the concerned Indicator!'))
raise osv.except_osv(_('Error !'), _('You cannot delete an indicator history record. You may have to delete the concerned Indicator!'))
account_report_history()

View File

@ -173,7 +173,7 @@ class account_voucher(osv.osv):
return True
def unlink(self, cr, uid, ids):
def unlink(self, cr, uid, ids, context=None):
vouchers = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for t in vouchers:
@ -181,7 +181,7 @@ class account_voucher(osv.osv):
unlink_ids.append(t['id'])
else:
raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
osv.osv.unlink(self, cr, uid, unlink_ids)
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True

View File

@ -20,6 +20,7 @@
#
##############################################################################
import hr_timesheet_project
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# 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 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
class project_work(osv.osv):
_inherit = 'project.task.work'
_columns = {
'date' : fields.datetime('Date', required=True),
}
project_work()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -437,7 +437,7 @@ class mrp_production(osv.osv):
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.production') or '/',
}
_order = 'date_planned asc, priority desc';
def unlink(self, cr, uid, ids):
def unlink(self, cr, uid, ids, context=None):
productions = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in productions:
@ -445,7 +445,7 @@ class mrp_production(osv.osv):
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Production Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids)
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def location_id_change(self, cr, uid, ids, src, dest, context={}):
if dest:
@ -796,7 +796,7 @@ class mrp_procurement(osv.osv):
'procure_method': lambda *a: 'make_to_order',
}
def unlink(self, cr, uid, ids):
def unlink(self, cr, uid, ids, context=None):
procurements = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in procurements:
@ -804,7 +804,7 @@ class mrp_procurement(osv.osv):
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids)
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
if product_id:

View File

@ -25,6 +25,7 @@ import netsvc
from osv import fields, osv
from mx import DateTime
from tools.translate import _
import tools
class pos_config_journal(osv.osv):
@ -915,7 +916,7 @@ class report_transaction_pos(osv.osv):
_description = "transaction for the pos"
_auto = False
_columns = {
'date_create': fields.date('Date', readonly=True),
'date_create': fields.char('Date', size=16, readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal', readonly=True),
'user_id': fields.many2one('res.users', 'User', readonly=True),
'no_trans': fields.float('Number of transaction', readonly=True),
@ -924,6 +925,7 @@ class report_transaction_pos(osv.osv):
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_transaction_pos')
cr.execute("""
create or replace view report_transaction_pos as (
select
@ -931,7 +933,7 @@ class report_transaction_pos(osv.osv):
count(pp.id) as no_trans,
sum(amount) as amount,
pp.journal_id,
date_trunc('day',pp.create_date)::date as date_create,
date_trunc('day',pp.create_date)::text as date_create,
ps.user_id,
ps.invoice_id
from

View File

@ -255,7 +255,7 @@
<form string="POS ">
<field name="user_id" select="1"/>
<field name="journal_id" select="1"/>
<field name="date_create" select="1"/>
<field name="date_create" select="1" widget="date"/>
<field name="no_trans" select="2"/>
<field name="amount" select="2"/>
<field name="invoice_id" select="2"/>
@ -270,7 +270,7 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="POS">
<field name="date_create"/>
<field name="date_create" widget="date" />
<field name="user_id"/>
<field name="journal_id"/>
<field name="no_trans" sum="Total Transaction"/>

View File

@ -87,8 +87,11 @@ class process_process(osv.osv):
pool = pooler.get_pool(cr.dbname)
process = pool.get('process.process').browse(cr, uid, [id])[0]
title = process.name
process = pool.get('process.process').browse(cr, uid, [id], context)[0]
name = process.name
resource = None
state = 'N/A'
expr_context = {}
states = {}
@ -101,7 +104,9 @@ class process_process(osv.osv):
current_object = pool.get(res_model).browse(cr, uid, [res_id], context)[0]
current_user = pool.get('res.users').browse(cr, uid, [uid], context)[0]
expr_context = Env(current_object, current_user)
title = _("%s - Resource: %s, State: %s") % (process.name, current_object.name, states.get(getattr(current_object, 'state'), 'N/A'))
resource = current_object.name
if 'state' in current_object:
state = states.get(current_object.state, 'N/A')
perm = pool.get(res_model).perm_read(cr, uid, [res_id], context)[0]
notes = process.note or "N/A"
@ -247,7 +252,7 @@ class process_process(osv.osv):
y = v['y']
v['y'] = min(y - miny + 10, y)
return dict(title=title, perm=perm, notes=notes, nodes=nodes, transitions=transitions)
return dict(name=name, resource=resource, state=state, perm=perm, notes=notes, nodes=nodes, transitions=transitions)
def copy(self, cr, uid, id, default=None, context={}):
""" Deep copy the entire process.

View File

@ -95,7 +95,7 @@ class project_work(osv.osv):
# delete entry from timesheet too while deleting entry to task.
list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, [])
if timesheet_id in list_avail_ids:
obj = self.pool.get('hr.analytic.timesheet').unlink(cr, uid, [timesheet_id], *args)
obj = self.pool.get('hr.analytic.timesheet').unlink(cr, uid, [timesheet_id], *args, **kwargs)
return super(project_work,self).unlink(cr, uid, ids, *args, **kwargs)

View File

@ -273,22 +273,22 @@
<para style="terp_default_9">[[ line.name ]]</para>
</td>
<td>
<para style="terp_default_9">[[ ', '.join(map(lambda x: x.name, line.taxes_id)) or '0.00' ]]</para>
<para style="terp_default_9">[[ ', '.join(map(lambda x: x.name, line.taxes_id)) or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ formatLang( line.date_planned, date=True) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ line.product_qty or '0.00' ]] </para>
<para style="terp_default_Right_9">[[ line.product_qty or formatLang(0.00) ]] </para>
</td>
<td>
<para style="terp_default_Right_9">[[ line.product_uom.name ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ line.price_unit or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ line.price_unit or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ line.price_subtotal or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ line.price_subtotal or formatLang(0.00) ]]</para>
</td>
</tr>
<tr>
@ -339,7 +339,7 @@
<para style="terp_default_9">Net Total :</para>
</td>
<td>
<para style="terp_default_Right_9">[[ o.amount_untaxed or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ o.amount_untaxed or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ o.pricelist_id.currency_id.name ]]</para>
@ -355,7 +355,7 @@
<para style="P1">Taxes :</para>
</td>
<td>
<para style="terp_default_Right_9">[[ o.amount_tax or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ o.amount_tax or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ o.pricelist_id.currency_id.name ]]</para>
@ -371,7 +371,7 @@
<para style="P3">Total :</para>
</td>
<td>
<para style="terp_default_Bold_9_Right">[[ o.amount_total or '0.00' ]]</para>
<para style="terp_default_Bold_9_Right">[[ o.amount_total or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Bold_9_Right">[[ o.pricelist_id.currency_id.name ]]</para>

View File

@ -137,7 +137,7 @@
<para style="terp_default_Centre_9">[[ formatLang(order_line.date_planned, date = True) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ order_line.product_qty or '' ]]</para>
<para style="terp_default_Right_9">[[ order_line.product_qty or formatLang(0.00)]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ (order_line.product_uom and order_line.product_uom.name) or '' ]]</para>

View File

@ -98,12 +98,6 @@
<paraStyle name="P5" rightIndent="0.0" leftIndent="-2.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P6" rightIndent="0.0" leftIndent="11.0" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P7" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" rightIndent="0.0" leftIndent="14.0" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" rightIndent="0.0" leftIndent="-2.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" rightIndent="0.0" leftIndent="11.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" rightIndent="0.0" leftIndent="11.0" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="12.0" spaceAfter="6.0"/>
@ -256,22 +250,22 @@
<para style="terp_default_9">[[ line.name ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[formatLang( ', '.join(map(lambda x: x.name, line.tax_id))) or '0.00' ]]</para>
<para style="terp_default_Centre_9">[[ ', '.join(map(lambda x: x.name, line.tax_id)) or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line.product_uos and line.product_uos_qty or line.product_uom_qty) or '0.00']] </para>
<para style="terp_default_Right_9">[[ line.product_uos and line.product_uos_qty or line.product_uom_qty or formatLang(0.00) ]] </para>
</td>
<td>
<para style="terp_default_Right_9">[[ line.product_uos and line.product_uos.name or line.product_uom.name ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line.price_unit) or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ line.price_unit or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line.discount) and str(line.discount) or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ line.discount and str(line.discount) or formatLang(0.00) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line.price_subtotal) or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ line.price_subtotal or formatLang(0.00) ]]</para>
</td>
</tr>
<tr>
@ -322,7 +316,7 @@
<para style="P5">Net Total :</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(o.amount_untaxed) or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ o.amount_untaxed or formatLang(0.00) ]]</para>
</td>
<td>
<para style="P1">[[ o.pricelist_id.currency_id.name ]]</para>
@ -338,7 +332,7 @@
<para style="P4">Taxes :</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(o.amount_tax) or '0.00' ]]</para>
<para style="terp_default_Right_9">[[ o.amount_tax or formatLang(0.00) ]]</para>
</td>
<td>
<para style="P1">[[ o.pricelist_id.currency_id.name ]]</para>
@ -354,7 +348,7 @@
<para style="P3">Total :</para>
</td>
<td>
<para style="terp_default_Right_9_Bold">[[ formatLang(o.amount_total) or '0.00' ]] </para>
<para style="terp_default_Right_9_Bold">[[ o.amount_total or formatLang(0.00) ]] </para>
</td>
<td>
<para style="P2">[[ o.pricelist_id.currency_id.name ]]</para>

View File

@ -268,7 +268,7 @@ class sale_order(osv.osv):
_order = 'name desc'
# Form filling
def unlink(self, cr, uid, ids):
def unlink(self, cr, uid, ids, context=None):
sale_orders = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in sale_orders:
@ -276,7 +276,7 @@ class sale_order(osv.osv):
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sale Order(s) which are already confirmed !'))
return osv.osv.unlink(self, cr, uid, unlink_ids)
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_shop_id(self, cr, uid, ids, shop_id):

View File

@ -187,7 +187,7 @@
<para style="terp_default_Centre_8">[[ (picking.sale_id and picking.sale_id.partner_shipping_id and picking.sale_id.partner_shipping_id and picking.sale_id.partner_shipping_id.title) or '' ]] [[ (picking.sale_id and picking.sale_id.partner_shipping_id and picking.sale_id.partner_shipping_id.name) or '' ]] </para>
</td>
<td>
<para style="terp_default_Centre_8">[[ picking.date ]]</para>
<para style="terp_default_Centre_8">[[ formatLang(picking.date,date_time = True) ]]</para>
</td>
<td>
<para style="terp_default_Centre_8">[[ picking.weight or '']] </para>
@ -216,7 +216,9 @@
</td>
</tr>
</blockTable>
<para style="terp_default_2"/>
<para style="terp_default_2">
<font color="white"> </font>
</para>
<section>
<para style="terp_default_8">[[ repeatIn([line for line in picking.move_lines if (line.state == 'assigned' )],'move_lines') ]]</para>
<blockTable colWidths="277.0,51.0,56.0,58.0,22.0,56.0" style="Move_Line_Contect_Assign_State">

View File

@ -35,6 +35,7 @@ class stock_report_prodlots(osv.osv):
'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
'prodlot_id': fields.many2one('stock.production.lot', 'Production lot', readonly=True, select=True),
}
def init(self, cr):
cr.execute("""
create or replace view stock_report_prodlots as (
@ -68,5 +69,10 @@ class stock_report_prodlots(osv.osv):
) as report
group by location_id, product_id, prodlot_id
)""")
def unlink(self, cr, uid, ids, context={}):
raise osv.except_osv(_('Error !'), _('You cannot delete any record!'))
stock_report_prodlots()

View File

@ -99,7 +99,30 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date"/>
<menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date"/>
<record id="view_location_tree_3" model="ir.ui.view">
<field name="name">stock.location.tree</field>
<field name="model">stock.location</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stock Location" colors="blue:usage=='view';darkred:usage=='internal'">
<field name="complete_name"/>
<field name="stock_real_value" />
<field name="stock_virtual_value" />
</tree>
</field>
</record>
<record id="action_location_tree_3" model="ir.actions.act_window">
<field name="name">Locations' Values</field>
<field name="res_model">stock.location</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_location_tree_3"/>
</record>
<menuitem action="action_location_tree_3" id="menu_action_location_tree_3" parent="next_id_61" />
<!-- end... -->

View File

@ -84,7 +84,33 @@ class stock_location(osv.osv):
if 'stock_virtual' in field_names:
res[loc]['stock_virtual'] = prod.virtual_available
return res
def product_detail(self, cr, uid, id, field):
res = {}
res[id] = {}
final_value = 0.0
field_to_read = 'virtual_available'
if field == 'stock_real_value':
field_to_read = 'qty_available'
cr.execute('select distinct product_id from stock_move where location_id=%s',(id,))
result = cr.dictfetchall()
if result:
for r in result:
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read,'standard_price','name'])
final_value += (product[field_to_read] * product['standard_price'])
return final_value
def _product_value(self, cr, uid, ids, field_names, arg, context={}):
result = {}
for id in ids:
result[id] = {}.fromkeys(field_names, 0.0)
for field_name in field_names:
for loc in ids:
ret_dict = self.product_detail(cr,uid,loc,field=field_name)
result[loc][field_name] = ret_dict
return result
_columns = {
'name': fields.char('Location Name', size=64, required=True, translate=True),
'active': fields.boolean('Active'),
@ -123,6 +149,8 @@ class stock_location(osv.osv):
'parent_left': fields.integer('Left Parent', select=1),
'parent_right': fields.integer('Right Parent', select=1),
'stock_real_value': fields.function(_product_value, method=True, type='float', string='Real Stock Value', multi="stock"),
'stock_virtual_value': fields.function(_product_value, method=True, type='float', string='Virtual Stock Value', multi="stock"),
}
_defaults = {
'active': lambda *a: 1,
@ -307,7 +335,7 @@ class stock_tracking(osv.osv):
res = [(r['id'], r['name']+' ['+(r['serial'] or '')+']') for r in self.read(cr, uid, ids, ['name','serial'], context)]
return res
def unlink(self, cr ,uid, ids):
def unlink(self, cr ,uid, ids, context=None):
raise osv.except_osv(_('Error'), _('You can not remove a lot line !'))
stock_tracking()

View File

@ -403,7 +403,7 @@
<field name="view_id" ref="view_location_tree"/>
</record>
<menuitem action="action_location_tree" id="menu_action_location_tree" parent="menu_stock_root"/>
=============================
Warehouse
=============================
@ -1360,7 +1360,7 @@
context="{'location': active_id}"
domain="[('product_id','=',active_id),('state','in',('waiting','confirmed','assigned'))]"
id="act_product_stock_move_futur_open"
name="Futur Stock Moves"
name="Future Stock Moves"
res_model="stock.move"
src_model="product.product"/>
@ -1381,8 +1381,5 @@
<field eval="True" name="object"/>
</record>  
     
</data>
</openerp>