# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
-
+import time
import netsvc
from osv import fields,osv,orm
from tools.translate import _
class delivery_carrier(osv.osv):
_name = "delivery.carrier"
- _description = "Carrier and delivery grids"
+ _description = "Carrier and delivery grids"
+
+ def get_price(self, cr, uid, ids, field_name, arg=None, context={}):
+ res={}
+ sale_obj=self.pool.get('sale.order')
+ grid_obj=self.pool.get('delivery.grid')
+ for carrier in self.browse(cr,uid,ids,context):
+ order_id=context.get('order_id',False)
+ price=False
+ if order_id:
+ order = sale_obj.browse(cr, uid, [order_id])[0]
+ carrier_grid=self.grid_get(cr,uid,[carrier.id],order.partner_shipping_id.id,context)
+ price=grid_obj.get_price(cr, uid, carrier_grid, order, time.strftime('%Y-%m-%d'), context)
+ res[carrier.id]=price
+ return res
_columns = {
'name': fields.char('Carrier', size=64, required=True),
'partner_id': fields.many2one('res.partner', 'Carrier Partner', required=True),
'product_id': fields.many2one('product.product', 'Delivery Product', required=True),
'grids_id': fields.one2many('delivery.grid', 'carrier_id', 'Delivery Grids'),
+ 'price' : fields.function(get_price, method=True,string='Price'),
'active': fields.boolean('Active')
}
_defaults = {
total = 0
weight = 0
- volume = 0
-
- for line in order.order_line:
+ volume = 0
+ for line in order.order_line:
if not line.product_id:
continue
total += line.price_subtotal or 0.0
delivery_grid_line()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<tree string="Carrier">
<field name="name"/>
<field name="partner_id"/>
+ <field name="price" invisible="'order_id' not in context"/>
</tree>
</field>
</record>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<separator string="Notes" position="before">
- <field name="carrier_id"/>
+ <field name="carrier_id" context="{'order_id':active_id}"/>
</separator>
</field>
</record>
<field name="res_model">stock.picking</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
- <field name="view_mode">tree,form</field>
+ <field name="view_mode">tree,form</field>
<field name="domain">[('invoice_state','=','2binvoiced'),('state','=','done'),('type','=','out')]</field>
</record>
<menuitem action="action_picking_tree4" id="menu_action_picking_tree3" parent="stock.menu_action_picking_tree"/>
delivery_form = """<?xml version="1.0"?>
<form string="Create deliveries">
<separator colspan="4" string="Delivery Method" />
- <field name="carrier_id" />
+ <field name="carrier_id"/>
</form>
"""
def _delivery_default(self, cr, uid, data, context):
order_obj = pooler.get_pool(cr.dbname).get('sale.order')
order = order_obj.browse(cr, uid, data['ids'])[0]
+
if not order.state in ('draft'):
raise wizard.except_wizard(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
+
carrier_id = order.partner_id.property_delivery_carrier.id
return {'carrier_id': carrier_id}
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('user_id','=',uid)]</field>
+
</record>
<menuitem action="action_order_tree" id="menu_action_order_tree" parent="sale.menu_sale_order"/>
return result
def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context={}, states=['done'], what=('in', 'out')):
+
product_obj = self.pool.get('product.product')
states_str = ','.join(map(lambda s: "'%s'" % s, states))
if not product_ids:
location_ids_str = ','.join(map(str, ids))
results = []
results2 = []
+
+ from_date=context.get('from_date',False)
+ to_date=context.get('to_date',False)
+ date_str=False
+ if from_date and to_date:
+ date_str="date>='%s' and date<=%s"%(from_date,to_date)
+ elif from_date:
+ date_str="date>='%s'"%(from_date)
+ elif to_date:
+ date_str="date<='%s'"%(to_date)
+
if 'in' in what:
- # all moves from a location out of the set to a location in the set
+ # all moves from a location out of the set to a location in the set
cr.execute(
'select sum(product_qty), product_id, product_uom '\
'from stock_move '\
'where location_id not in ('+location_ids_str+') '\
'and location_dest_id in ('+location_ids_str+') '\
'and product_id in ('+prod_ids_str+') '\
- 'and state in ('+states_str+') '\
+ 'and state in ('+states_str+') '+ (date_str and 'and '+date_str+' ' or '') +''\
'group by product_id,product_uom'
)
results = cr.fetchall()
if 'out' in what:
- # all moves from a location in the set to a location out of the set
+ # all moves from a location in the set to a location out of the set
cr.execute(
'select sum(product_qty), product_id, product_uom '\
'from stock_move '\
'where location_id in ('+location_ids_str+') '\
'and location_dest_id not in ('+location_ids_str+') '\
'and product_id in ('+prod_ids_str+') '\
- 'and state in ('+states_str+') '\
+ 'and state in ('+states_str+') '+ (date_str and 'and '+date_str+' ' or '') + ''\
'group by product_id,product_uom'
)
results2 = cr.fetchall()
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
- <menuitem action="action_incoterms_tree" id="menu_action_incoterms_tree" parent="menu_stock_configuration"/>
+ <menuitem action="action_incoterms_tree" id="menu_action_incoterms_tree" parent="menu_stock_configuration"/>
<act_window context="{'location': active_id}" domain="[('type','<>','service')]" id="act_product_location_open" name="Products" res_model="product.product" src_model="stock.location"/>
<act_window context="{'location': active_id}" domain="[('product_id','=',active_id)]" id="act_product_stock_move_open" name="Stock Moves" res_model="stock.move" src_model="product.product"/>
-
- <record id="ir_act_product_location_open" model="ir.values">
+
+ <record id="ir_act_product_location_open" model="ir.values">
<field name="key2">tree_but_open</field>
<field name="model">stock.location</field>
<field name="name">Products</field>
<field eval="'ir.actions.act_window,%d'%act_product_location_open" name="value"/>
<field eval="True" name="object"/>
- </record>
+ </record>
+
+
+ <record id="ir_act_product_location_open" model="ir.values">
+ <field name="key2">tree_but_open</field>
+ <field name="model">stock.location</field>
+ <field name="name">Open Products</field>
+ <field eval="'ir.actions.wizard,%d'%ref('location_product')" name="value"/>
+ <field eval="True" name="object"/>
+ </record>
+
+
+
</data>
</openerp>
keyword="client_action_multi"
id="wizard_fill_inventory"
/>
+
+ <wizard id="location_product" model="stock.location" name="stock.location.products" string="Products by Location"/>
</data>
</openerp>
import wizard_track_line
import wizard_ups
import wizard_invoice_onshipping
-import wizard_move_by_location
+import wizard_location_product
import wizard_inventory
import inventory_merge_zero
import inventory_merge
--- /dev/null
+# -*- 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.
+#
+##############################################################################
+
+import wizard
+import pooler
+import time
+
+def _action_open_window(self, cr, uid, data, context):
+ return {
+ 'view_type': 'form',
+ "view_mode": 'tree,form',
+ 'res_model': 'product.product',
+ 'type': 'ir.actions.act_window',
+ 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']},
+ 'domain':[('type','<>','service')]
+ }
+
+
+class product_by_location(wizard.interface):
+
+ form1 = '''<?xml version="1.0"?>
+ <form string="View Stock of Products">
+ <field name="from_date"/>
+ <newline/>
+ <field name="to_date"/>
+ </form>'''
+
+ form1_fields = {
+ 'from_date': {
+ 'string': 'From',
+ 'type': 'date',
+ },
+ 'to_date': {
+ 'string': 'To',
+ 'type': 'date',
+ },
+ }
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [ ('open', 'Open Products'),('end', 'Cancel')]}
+ },
+ 'open': {
+ 'actions': [],
+ 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
+ }
+ }
+
+product_by_location('stock.location.products')
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+++ /dev/null
-# -*- encoding: utf-8 -*-
-import wizard
-import pooler
-import time
-
-def _action_open_window(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- mod_obj = pool.get('ir.model.data')
- act_obj = pool.get('ir.actions.act_window')
-
- result = mod_obj._get_id(cr, uid, 'stock', 'action_move_form2')
- id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
- result = act_obj.read(cr, uid, [id])[0]
- location_id = data['ids'][0]
-
- domain = []
-# domain += [ '|' ,('location_id', '=', location_id) , ('location_dest_id', '=', location_id)]
- if data['form']['from']:
- domain += [('date_planned', '>=', data['form']['from'])]
-
- if data['form']['to']:
- domain += [('date_planned', '<=', data['form']['to'])]
- result['domain'] = str(domain)
-# result['context'] = str({'location_id': location_id })
- return result
-
-
-class move_by_location(wizard.interface):
-
- form1 = '''<?xml version="1.0"?>
- <form string="View Stock Moves">
- <field name="from"/>
- <newline/>
- <field name="to"/>
- </form>'''
-
- form1_fields = {
- 'from': {
- 'string': 'From',
- 'type': 'date',
- },
- 'to': {
- 'string': 'To',
- 'type': 'date',
-# 'default': lambda *a: time.strftime("%Y-%m-%d"),
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [ ('open', 'Open Moves'),('end', 'Cancel')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-
-move_by_location('stock.location.moves')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file