[MERGE] merged lp:~openerp-dev/openobject-addons/mso-trunk-dev-addons1

bzr revid: hmo@tinyerp.com-20100426064647-6lp8331zdrthktcf
This commit is contained in:
Harry (Open ERP) 2010-04-26 12:16:47 +05:30
commit d423fe65f4
9 changed files with 213 additions and 18 deletions

View File

@ -28,6 +28,17 @@ class delivery_carrier(osv.osv):
_name = "delivery.carrier"
_description = "Carrier and delivery grids"
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
order_id = context.get('order_id',False)
if not order_id:
res = super(delivery_carrier, self).name_get(cr, uid, ids, context=context)
else:
order = self.pool.get('sale.order').browse(cr, uid, [order_id])[0]
currency = order.pricelist_id.currency_id.name or ''
res = [(r['id'], r['name']+' ('+(str(r['price']))+' '+currency+')') for r in self.read(cr, uid, ids, ['name', 'price'], context)]
return res
def get_price(self, cr, uid, ids, field_name, arg=None, context={}):
res={}
sale_obj=self.pool.get('sale.order')
@ -94,9 +105,7 @@ class delivery_grid(osv.osv):
}
_order = 'sequence'
def get_price(self, cr, uid, id, order, dt, context):
total = 0
weight = 0
volume = 0
@ -112,7 +121,6 @@ class delivery_grid(osv.osv):
def get_price_from_picking(self, cr, uid, id, total, weight, volume, context={}):
grid = self.browse(cr, uid, id, context)
price = 0.0
ok = False

View File

@ -289,5 +289,16 @@
</field>
</record>
<record model="ir.ui.view" id="edit_project_multicompany">
<field name="name">sale.order.multicompany</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Sale Order']/group[1]/button[@name='button_dummy']" position="after">
<button name="%(action_delivery_cost)d" states="draft" string="Delivery Costs" type="action" icon="gtk-execute" context="{'order_id':id}"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -50,7 +50,11 @@ class make_delivery(osv.osv_memory):
res = super(make_delivery, self).default_get(cr, uid, fields, context=context)
order_obj = self.pool.get('sale.order')
for order in order_obj.browse(cr, uid, context.get('active_ids', [])):
res.update({'carrier_id': order.partner_id.property_delivery_carrier.id})
carrier = order.carrier_id.id
if not carrier:
carrier = order.partner_id.property_delivery_carrier.id
res.update({'carrier_id': carrier})
return res
def view_init(self, cr , uid , fields, context=None):

View File

@ -11,26 +11,28 @@
<field name="arch" type="xml">
<form string="Create Deliveries">
<separator colspan="4" string="Delivery Method" />
<field name="carrier_id"/>
<field name="carrier_id" widget="selection"/>
<newline/>
<separator colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="delivery_set" string="Add Delivery Costs"
colspan="1" type="object" icon="gtk-ok" />
string="_Cancel" />
<button name="delivery_set" string="_Apply"
colspan="1" type="object" icon="gtk-apply" />
</group>
</form>
</field>
</record>
<record id="action_delivery_cost" model="ir.actions.act_window">
<field name="name">Delivery Costs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">delivery.sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_make_delivery_wizard"/>
<field name="target">new</field>
</record>
<act_window name="Delivery Costs"
res_model="delivery.sale.order"
src_model="sale.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="act_delivery_cost"/>
</data>
</openerp>

View File

@ -188,7 +188,7 @@
</tree>
</field>
<newline/>
<group col="7" colspan="4">
<group col="8" colspan="5">
<field name="amount_untaxed" sum="Untaxed amount"/>
<field name="amount_tax"/>
<field name="amount_total" sum="Total amount"/>

View File

@ -62,6 +62,7 @@ Thanks to the double entry management, the inventory controlling is powerful and
"product_data.xml",
"product_view.xml",
"partner_view.xml",
"report/report_stock_move_view.xml",
"report/report_stock_view.xml",
"report/report_stock_picking_view.xml",
"security/stock_security.xml",

View File

@ -28,6 +28,7 @@ import lot_overview
import lot_overview_all
import report_stock
import report_stock_picking
import report_stock_move
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,62 @@
# -*- 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 tools
from osv import fields,osv
class report_stock_move(osv.osv):
_name = "report.stock.move"
_description = "Stock Statistics"
_auto = False
_columns = {
'date': fields.date('Date', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'location_id':fields.many2one('stock.location', 'Location', readonly=True),
'product_qty':fields.integer('Qty',readonly=True),
'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
\nThe state is \'Waiting\' if the move is waiting for another one.'),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_stock_move')
cr.execute("""
create or replace view report_stock_move as (
select min(m.id) as id,
m.date as date,
to_char(date_trunc('day',m.date), 'YYYY') as year,
to_char(date_trunc('day',m.date), 'MM') as month,
to_char(date_trunc('day',m.date), 'YYYY-MM-DD') as day,
m.location_id as location_id,
m.product_id as product_id,
m.state as state,
sum(m.product_qty) as product_qty
from stock_move as m group by m.product_id, m.location_id, m.id, m.date, m.state
)
""")
report_stock_move()

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_stock_tree" model="ir.ui.view">
<field name="name">report.stock.move.tree</field>
<field name="model">report.stock.move</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stock Orders Statistics">
<field name="date"/>
<field name="year" invisible="1" />
<field name="month" invisible="1"/>
<field name="day" invisible="1"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="location_id"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_stock_graph" model="ir.ui.view">
<field name="name">report.stock.move.graph</field>
<field name="model">report.stock.move</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Stock Moves Statistics" type="bar">
<field name="product_id"/>
<field name="product_qty"/>
</graph>
</field>
</record>
<record id="view_stock_search" model="ir.ui.view">
<field name="name">report.stock.move.search</field>
<field name="model">report.stock.move</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Stock Move">
<group>
<filter icon="terp-stock"
string="This Year"
domain="[('year','=',time.strftime('%%Y'))]"
help="Stock Moves of the year"/>
<filter icon="terp-stock"
string="This Month"
domain="[('month','=',time.strftime('%%m'))]"
help="Stock Moves of this month"/>
<filter icon="terp-stock"
string="Current Stock"
separator="1"
domain="[('date', '=', time.strftime('%%Y-%%m-%%d')]"
help="Stock Moves of today"/>
<separator orientation="vertical"/>
<filter string="Waiting"
icon="terp-stock"
domain="[('state','=','waiting')]"
help = "Confirmed Stock-Moves"/>
<filter string="Available"
icon="terp-stock"
domain="[('state','=','assigned')]"
help = "Available Stock-Moves"/>
<filter string="Done"
icon="terp-stock"
domain="[('state','=','done')]"
help = "Completed Stock-Moves"/>
<separator orientation="vertical"/>
<field name="product_id" select="1" widget="selection"/>
<field name="location_id" select="1" widget="selection"/>
</group>
<newline/>
<group expand="1" string="Group By..." >
<filter string="Product" icon="terp-stock" context="{'group_by':'product_id'}"/>
<filter string="Location" icon="terp-stock" context="{'group_by':'location_id'}"/>
<filter string="State" icon="terp-stock" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-stock" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-stock" context="{'group_by':'date'}"/>
<filter string="Year" icon="terp-stock" context="{'group_by':'year'}"/>
</group>
</search>
</field>
</record>
<record id="action_stock_move_report" model="ir.actions.act_window">
<field name="name">Stock Moves</field>
<field name="res_model">report.stock.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_stock_search"/>
</record>
<menuitem
id="stock.next_id_61"
name="Reporting"
parent="stock.menu_stock_root" groups="base.group_user"/>
<menuitem action="action_stock_move_report" id="menu_action_stock_move_report" parent="next_id_61" sequence="5"/>
</data>
</openerp>