- """ % (data['id'],)
-
-
- 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}
-
-def _delivery_set(self, cr, uid, data, context):
- order_obj = pooler.get_pool(cr.dbname).get('sale.order')
- line_obj = pooler.get_pool(cr.dbname).get('sale.order.line')
- order_objs = order_obj.browse(cr, uid, data['ids'], context)
-
- for order in order_objs:
- grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id)
- if not grid_id:
- raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !'))
- grid_obj=pooler.get_pool(cr.dbname).get('delivery.grid')
- grid = grid_obj.browse(cr, uid, [grid_id])[0]
-
- taxes = grid.carrier_id.product_id.taxes_id
- fpos = order.fiscal_position or False
- taxes_ids = pooler.get_pool(cr.dbname).get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
- line_obj.create(cr, uid, {
- 'order_id': order.id,
- 'name': grid.carrier_id.name,
- 'product_uom_qty': 1,
- 'product_uom': grid.carrier_id.product_id.uom_id.id,
- 'product_id': grid.carrier_id.product_id.id,
- 'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
- 'tax_id': [(6,0,taxes_ids)],
- 'type': 'make_to_stock'
- })
-
- return {}
-
-class make_delivery(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [_delivery_default],
- 'result' : {'type' : 'form', 'arch' : delivery_form, 'fields' : delivery_fields, 'state' : [('end', 'Cancel', 'gtk-cancel'),('delivery', 'Add Delivery Costs', 'gtk-ok') ]}
- },
- 'delivery' : {
- 'actions' : [_delivery_set],
- 'result' : {'type' : 'state', 'state' : 'end'}
- },
+ _columns = {
+ 'carrier_id': fields.many2one('delivery.carrier','Delivery Method', required=True),
}
-make_delivery("delivery.sale.order")
+
+
+ def default_get(self, cr, uid, fields, context):
+ """
+ @summary: To get default values for the object.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+
+ @return: A dictionary which of fields with values.
+
+ """
+ rec_id = context and context.get('active_id',False)
+ res = {}
+ order_obj = self.pool.get('sale.order')
+ order = order_obj.browse(cr, uid, rec_id)
+
+ if not order.state in ('draft'):
+ raise osv.except_osv(_('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
+ res['carrier_id'] = carrier_id
+ return res
+
+ def delivery_set(self, cr, uid, ids, context):
+ """
+ @summary: Adds delivery costs to Sale Order Line.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ rec_ids = context and context.get('active_ids',[])
+ order_obj = self.pool.get('sale.order')
+ line_obj = self.pool.get('sale.order.line')
+ grid_obj = self.pool.get('delivery.grid')
+ carrier_obj = self.pool.get('delivery.carrier')
+ acc_fp_obj = self.pool.get('account.fiscal.position')
+ order_objs = order_obj.browse(cr, uid, rec_ids, context)
+ for datas in self.browse(cr, uid, ids):
+ for order in order_objs:
+ grid_id = carrier_obj.grid_get(cr, uid, [datas.carrier_id.id],order.partner_shipping_id.id)
+ if not grid_id:
+ raise osv.except_osv(_('No grid available !'), _('No grid matching for this carrier !'))
+
+ if not order.state in ('draft'):
+ raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
+
+ grid = grid_obj.browse(cr, uid, grid_id)
+
+ taxes = grid.carrier_id.product_id.taxes_id
+ fpos = order.fiscal_position or False
+ taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
+ line_obj.create(cr, uid, {
+ 'order_id': order.id,
+ 'name': grid.carrier_id.name,
+ 'product_uom_qty': 1,
+ 'product_uom': grid.carrier_id.product_id.uom_id.id,
+ 'product_id': grid.carrier_id.product_id.id,
+ 'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
+ 'tax_id': [(6,0,taxes_ids)],
+ 'type': 'make_to_stock'
+ })
+
+ return {}
+
+make_delivery()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/delivery/wizard/delivery_sale_order_view.xml b/addons/delivery/wizard/delivery_sale_order_view.xml
new file mode 100644
index 00000000000..c2609bc3923
--- /dev/null
+++ b/addons/delivery/wizard/delivery_sale_order_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Delivery Costs
+ delivery.sale.order
+ form
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py
index b219d932141..90ca012bc48 100644
--- a/addons/mrp/__init__.py
+++ b/addons/mrp/__init__.py
@@ -21,7 +21,6 @@
import mrp
import installer
-import mrp_wizard
import wizard
import report
import company
diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py
index a147266ce1d..e77cabcabbd 100644
--- a/addons/mrp/__terp__.py
+++ b/addons/mrp/__terp__.py
@@ -60,8 +60,12 @@
'security/ir.model.access.csv',
'mrp_workflow.xml',
'mrp_data.xml',
- 'mrp_wizard_view.xml',
+ 'wizard/mrp_product_produce_view.xml',
+ 'wizard/make_procurement_view.xml',
+ 'wizard/change_production_qty_view.xml',
+ 'wizard/orderpoint_procurement_view.xml',
'mrp_view.xml',
+ 'wizard/schedulers_all_view.xml',
'mrp_wizard.xml',
'mrp_report.xml',
'company_view.xml',
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 40fd2e46525..8bccab81e56 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -188,7 +188,7 @@ class mrp_bom(osv.osv):
'revision_type': fields.selection([('numeric','numeric indices'),('alpha','alphabetical indices')], 'Index type'),
'child_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
'child_complete_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
- 'company_id': fields.many2one('res.company','Company',required=True),
+ 'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
'active': lambda *a: 1,
@@ -196,7 +196,7 @@ class mrp_bom(osv.osv):
'product_qty': lambda *a: 1.0,
'product_rounding': lambda *a: 1.0,
'type': lambda *a: 'normal',
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c)
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c),
}
_order = "sequence"
_sql_constraints = [
@@ -375,30 +375,7 @@ class one2many_domain(fields.one2many):
class mrp_production(osv.osv):
_name = 'mrp.production'
_description = 'Production'
- _date_name = 'date_planned'
-
- def _get_sale_order(self,cr,uid,ids,field_name=False):
- move_obj=self.pool.get('stock.move')
- def get_parent_move(move_id):
- move = move_obj.browse(cr,uid,move_id)
- if move.move_dest_id:
- return get_parent_move(move.move_dest_id.id)
- return move_id
- productions=self.read(cr,uid,ids,['id','move_prod_id'])
- res={}
- for production in productions:
- res[production['id']]=False
- if production.get('move_prod_id',False):
- parent_move_line=get_parent_move(production['move_prod_id'][0])
- if parent_move_line:
- move = move_obj.browse(cr,uid,parent_move_line)
- #TODO: fix me sale module can not be used here,
- #as may be mrp can be installed without sale module
- if field_name=='name':
- res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False
- if field_name=='client_order_ref':
- res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
- return res
+ _date_name = 'date_planned'
def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}):
result = {}
@@ -424,11 +401,12 @@ class mrp_production(osv.osv):
result[prod.id] = prod.date_planned[:10]
return result
- def _sale_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
- return self._get_sale_order(cr,uid,ids,field_name='name')
-
- def _sale_ref_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
- return self._get_sale_order(cr,uid,ids,field_name='client_order_ref')
+ def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
+ res = {}
+ for f in field_names:
+ for order_id in ids:
+ res[order_id] = {f:False}
+ return res
_columns = {
'name': fields.char('Reference', size=64, required=True),
@@ -470,8 +448,8 @@ class mrp_production(osv.osv):
'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'),
'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'),
- 'sale_name': fields.function(_sale_name_calc, method=True, type='char', string='Sale Name', help='Indicate the name of sale order.'),
- 'sale_ref': fields.function(_sale_ref_calc, method=True, type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
+ 'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'),
+ 'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
@@ -1385,13 +1363,32 @@ class StockMove(osv.osv):
def consume_moves(self, cr, uid, ids, product_qty, location_id=False, location_dest_id=False, consume=True, context=None):
res = []
production_obj = self.pool.get('mrp.production')
+ wf_service = netsvc.LocalService("workflow")
for move in self.browse(cr, uid, ids):
new_moves = super(StockMove, self).consume_moves(cr, uid, [move.id], product_qty, location_id, location_dest_id, consume, context=context)
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
+ for prod in production_obj.browse(cr, uid, production_ids, context=context):
+ if prod.state == 'confirmed':
+ production_obj.force_production(cr, uid, [prod.id])
+ wf_service.trg_validate(uid, 'mrp.production', prod.id, 'button_produce', cr)
for new_move in new_moves:
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
res.append(new_move)
- return res
+ return res
+
+ def scrap_moves(self, cr, uid, ids, product_qty, location_id, context=None):
+ res = []
+ production_obj = self.pool.get('mrp.production')
+ wf_service = netsvc.LocalService("workflow")
+ for move in self.browse(cr, uid, ids):
+ new_moves = super(StockMove, self).scrap_moves(cr, uid, [move.id], product_qty, location_id, context=context)
+ production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
+ for prod_id in production_ids:
+ wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr)
+ for new_move in new_moves:
+ production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
+ res.append(new_move)
+ return {}
StockMove()
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 29e37f9532b..260deed7839 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -438,15 +438,7 @@
-
-
-
+
mrp.production.form
@@ -462,7 +454,9 @@
-
+
@@ -484,35 +478,27 @@
mode="tree,form" height="275" domain="[('state','<>', ('done', 'cancel'))]">
-
-
-
-
-
+
+
+
+
-
-
+
-
-
-
-
-
+
+
+
+
+ states="done,cancel" />
+
-
@@ -547,24 +529,17 @@
mode="tree,form" height="275" domain="[('state','<>', ('done', 'cancel'))]">
-
-
-
-
-
+
+
+
+
-
-
-
+
-
diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml
index 74001494c77..f42409559ba 100644
--- a/addons/mrp/mrp_wizard.xml
+++ b/addons/mrp/mrp_wizard.xml
@@ -1,17 +1,6 @@
-
-
-
-
-
-
-
@@ -24,12 +13,5 @@
-
-
diff --git a/addons/mrp/schedulers.py b/addons/mrp/schedulers.py
index 509d50b46b9..097f81f7529 100644
--- a/addons/mrp/schedulers.py
+++ b/addons/mrp/schedulers.py
@@ -195,9 +195,9 @@ class mrp_procurement(osv.osv):
qty = max(op.product_min_qty, op.product_max_qty)-prods
reste = qty % op.qty_multiple
if reste > 0:
- qty += op.qty_multiple - reste
+ qty += op.qty_multiple - reste
newdate = DateTime.now() + DateTime.RelativeDateTime(
- days=op.product_id.seller_delay)
+ days=int(op.product_id.seller_delay))
if op.product_id.supply_method == 'buy':
location_id = op.warehouse_id.lot_input_id
elif op.product_id.supply_method == 'produce':
diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv
index cdc658ff7c0..2e7c5d062e7 100644
--- a/addons/mrp/security/ir.model.access.csv
+++ b/addons/mrp/security/ir.model.access.csv
@@ -32,3 +32,7 @@
"access_mrp_production_stock_worker","mrp.production stock_worker","model_mrp_production","stock.group_stock_user",1,0,0,0
"access_mrp_installer","mrp.installer","model_mrp_installer","mrp.group_mrp_user",1,0,0,0
"access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,0,0,0
+"access_mrp_make_procurement","make.procurement","model_make_procurement","mrp.group_mrp_user",1,0,0,0
+"access_mrp_change_production_qty","change.production.qty","model_change_production_qty","mrp.group_mrp_user",1,0,0,0
+"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all","mrp.group_mrp_user",1,0,0,0
+"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute","mrp.group_mrp_user",1,0,0,0
diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py
index 240f25daa9d..b18384fd0b2 100644
--- a/addons/mrp/wizard/__init__.py
+++ b/addons/mrp/wizard/__init__.py
@@ -19,14 +19,15 @@
#
##############################################################################
-import wizard_orderpoint_procurement
+import mrp_product_produce
+import orderpoint_procurement
import wizard_procurement
-import wizard_schedulers_all
+import schedulers_all
import wizard_price
import wizard_workcenter_load
import wizard_track_prod
-import wizard_change_production_qty
-import make_procurement
+import change_production_qty
+import make_procurement_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py
new file mode 100644
index 00000000000..cf3a9069239
--- /dev/null
+++ b/addons/mrp/wizard/change_production_qty.py
@@ -0,0 +1,114 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import time
+import ir
+from osv.osv import except_osv
+from osv import fields, osv
+import netsvc
+from tools.translate import _
+
+class change_production_qty(osv.osv_memory):
+ _name = 'change.production.qty'
+ _description = 'Change Quantity of Products'
+
+ _columns = {
+ 'product_qty': fields.float('Product Qty', required=True),
+ }
+
+ def default_get(self, cr, uid, fields, context):
+ """
+ @summary: To get default values for the object.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+
+ @return: A dictionary which of fields with values.
+
+ """
+ res = {}
+ record_id = context and context.get('active_id',False)
+ if not record_id:
+ return res
+ prod_obj = self.pool.get('mrp.production')
+ prod = prod_obj.browse(cr, uid, record_id)
+ if prod.state in ('in_production','cancel', 'done'):
+ raise osv.except_osv(_('Warning !'), _('The production is in "%s" state. You can not change the production quantity anymore') % (prod.state).upper() )
+
+ res['product_qty'] = prod.product_qty
+ return res
+
+ def change_prod_qty(self, cr, uid, ids, context):
+ """
+ @summary: Changes the Quantity of Product.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ record_id = context and context.get('active_id',False)
+ assert record_id, _('Active Id is not found')
+ prod_obj = self.pool.get('mrp.production')
+ product_lines_obj = self.pool.get('mrp.production.product.line')
+ bom_obj = self.pool.get('mrp.bom')
+ for wiz_qty in self.browse(cr, uid, ids):
+ prod = prod_obj.browse(cr, uid,record_id)
+ prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty})
+ prod_obj.action_compute(cr, uid, [prod.id])
+
+ move_lines_obj = self.pool.get('stock.move')
+ for move in prod.move_lines:
+ bom_point = prod.bom_id
+ bom_id = prod.bom_id.id
+ if not bom_point:
+ bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
+ if not bom_id:
+ raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
+ prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
+ bom_point = sbom_obj.browse(cr, uid, [bom_id])[0]
+
+ if not bom_id:
+ raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
+
+ factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
+ res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
+ for r in res[0]:
+ if r['product_id']== move.product_id.id:
+ move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']})
+
+
+
+ for m in prod.move_created_ids:
+ move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty})
+
+ return {}
+
+change_production_qty()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/wizard/change_production_qty_view.xml b/addons/mrp/wizard/change_production_qty_view.xml
new file mode 100644
index 00000000000..34520a71721
--- /dev/null
+++ b/addons/mrp/wizard/change_production_qty_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Change Product Qty
+ change.production.qty
+ form
+
+
+
+
+
+
+ Change Product Qty
+ ir.actions.act_window
+ change.production.qty
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/mrp/wizard/make_procurement.py b/addons/mrp/wizard/make_procurement.py
deleted file mode 100644
index 0cf12107181..00000000000
--- a/addons/mrp/wizard/make_procurement.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import netsvc
-
-import time
-
-def _get_default(obj, cr, uid, data, context=None):
- pool = pooler.get_pool(cr.dbname)
- product = pool.get('product.product').browse(cr, uid, data['id'], context)
- return {'product_id': product.id, 'uom_id':product.uom_id.id, 'qty':1.0}
-
-def make_procurement(obj, cr, uid, data, context=None):
- '''Create procurement'''
- pool = pooler.get_pool(cr.dbname)
- wh = pool.get('stock.warehouse').browse(cr, uid, data['form']['warehouse_id'], context)
- user = pool.get('res.users').browse(cr, uid, uid, context)
- procure_id = pool.get('mrp.procurement').create(cr, uid, {
- 'name':'INT:'+str(user.login),
- 'date_planned':data['form']['date_planned'],
- 'product_id':data['form']['product_id'],
- 'product_qty':data['form']['qty'],
- 'product_uom':data['form']['uom_id'],
- 'location_id':wh.lot_stock_id.id,
- 'procure_method':'make_to_order',
- }, context=context)
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
- return {}
-
-
-class MakeProcurement(wizard.interface):
- '''Wizard that create a procurement from a product form'''
-
- done_form = """
-"""
- procurement_form = """
-"""
- procurement_fields = {
- 'qty': {'string': 'Quantity', 'type': 'float', 'digits':(16,2), 'required': True},
- 'product_id': {'string': 'product', 'type': 'many2one', 'relation': 'product.product', 'required': True, 'readonly':1},
- 'uom_id': {'string': 'Unit of Measure', 'type': 'many2one', 'relation': 'product.uom', 'required':True},
- 'warehouse_id': {'string': 'Warehouse', 'type': 'many2one', 'relation':'stock.warehouse', 'required':True},
- 'date_planned': {'string': 'Planned Date', 'type': 'date', 'required':True, 'default': lambda *args: time.strftime('%Y-%m-%d')}
- }
-
- states = {
- 'init': {
- 'actions': [_get_default],
- 'result': {'type': 'form', 'arch': procurement_form, 'fields': procurement_fields,
- 'state': [
- ('end', 'Cancel'),
- ('create', 'Ask New Products')
- ]
- }
- },
- 'done': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': done_form, 'fields': {},
- 'state': [
- ('end', 'Close'),
- ]
- }
- },
- 'create': {
- 'actions': [],
- 'result': {'type': 'action', 'action': make_procurement, 'state': 'done'}
- }
- }
-
-MakeProcurement('product.product.procurement')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp/wizard/make_procurement_product.py b/addons/mrp/wizard/make_procurement_product.py
new file mode 100644
index 00000000000..ce703a435a9
--- /dev/null
+++ b/addons/mrp/wizard/make_procurement_product.py
@@ -0,0 +1,130 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+import time
+
+from osv import fields, osv
+
+class make_procurement(osv.osv_memory):
+ _name = 'make.procurement'
+ _description = 'Make Procurements'
+
+ def onchange_product_id(self, cr, uid, ids, prod_id):
+ """
+ @summary: On Change of Product ID getting the value of related UoM.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param prod_id: Changed ID of Product
+
+ @return: A dictionary which gives the UoM of the changed Product
+
+ """
+ product = self.pool.get('product.product').browse(cr, uid, prod_id)
+ return {'value': {'uom_id': product.uom_id.id}}
+
+ _columns = {
+ 'qty': fields.float('Quantity', digits=(16,2), required=True),
+ 'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1),
+ 'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
+ 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
+ 'date_planned': fields.date('Planned Date', required=True),
+ }
+
+ _defaults = {
+ 'date_planned': lambda *args: time.strftime('%Y-%m-%d'),
+ 'qty': lambda *args: 1.0,
+ }
+
+ def make_procurement(self, cr, uid, ids, context=None):
+ """
+ @summary: Creates procurement order for selected product.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return: A dictionary which loads Procurement form view.
+
+ """
+ user = self.pool.get('res.users').browse(cr, uid, uid, context).login
+ for proc in self.browse(cr, uid, ids):
+ wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context)
+ procure_id = self.pool.get('mrp.procurement').create(cr, uid, {
+ 'name':'INT: '+str(user),
+ 'date_planned': proc.date_planned,
+ 'product_id': proc.product_id.id,
+ 'product_qty': proc.qty,
+ 'product_uom': proc.uom_id.id,
+ 'location_id': wh.lot_stock_id.id,
+ 'procure_method':'make_to_order',
+ })
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
+
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view')
+ id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ if id3:
+ id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'mrp.procurement',
+ 'res_id' : procure_id,
+ 'views': [(id3,'form'),(id2,'tree')],
+ 'type': 'ir.actions.act_window',
+ }
+
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ @summary: To get default values for the object.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+
+ @return: A dictionary which of fields with values.
+
+ """
+ record_id = context and context.get('active_id', False) or False
+
+ res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
+
+ if record_id:
+ product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
+ res['product_id'] = product_id
+
+ return res
+
+make_procurement()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp/wizard/make_procurement_view.xml b/addons/mrp/wizard/make_procurement_view.xml
new file mode 100644
index 00000000000..08c4b2cabf5
--- /dev/null
+++ b/addons/mrp/wizard/make_procurement_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ Requisition Request
+ make.procurement
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/mrp_wizard.py b/addons/mrp/wizard/mrp_product_produce.py
similarity index 100%
rename from addons/mrp/mrp_wizard.py
rename to addons/mrp/wizard/mrp_product_produce.py
diff --git a/addons/mrp/mrp_wizard_view.xml b/addons/mrp/wizard/mrp_product_produce_view.xml
similarity index 100%
rename from addons/mrp/mrp_wizard_view.xml
rename to addons/mrp/wizard/mrp_product_produce_view.xml
diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py
new file mode 100644
index 00000000000..731c3fca440
--- /dev/null
+++ b/addons/mrp/wizard/orderpoint_procurement.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+#
+# Order Point Method:
+# - Order if the virtual stock of today is bellow the min of the defined order point
+#
+
+import threading
+from osv import fields,osv
+
+class procurement_compute(osv.osv_memory):
+ _name = 'mrp.procurement.orderpoint.compute'
+ _description = 'Automatic Order Point'
+
+ _columns = {
+ 'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
+ }
+
+ _defaults = {
+ 'automatic' : lambda *a: False,
+ }
+
+ def _procure_calculation_orderpoint(self, cr, uid, ids, context):
+ """
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ """
+ proc_obj = self.pool.get('mrp.procurement')
+ for proc in self.browse(cr, uid, ids):
+ proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
+
+ return {}
+
+ def procure_calculation(self, cr, uid, ids, context):
+ """
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ """
+ threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
+ threaded_calculation.start()
+ return {}
+
+procurement_compute()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/wizard/orderpoint_procurement_view.xml b/addons/mrp/wizard/orderpoint_procurement_view.xml
new file mode 100644
index 00000000000..c17bedae84f
--- /dev/null
+++ b/addons/mrp/wizard/orderpoint_procurement_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ Compute Stock Minimum Rules Only
+ mrp.procurement.orderpoint.compute
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/schedulers_all.py b/addons/mrp/wizard/schedulers_all.py
new file mode 100644
index 00000000000..62497564905
--- /dev/null
+++ b/addons/mrp/wizard/schedulers_all.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import threading
+
+from osv import osv, fields
+
+class procurement_compute(osv.osv_memory):
+ _name = 'mrp.procurement.compute.all'
+ _description = 'Compute all schedulers'
+
+ _columns = {
+ 'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'),
+ }
+
+ _defaults ={
+ 'automatic': lambda *a: False,
+ }
+
+ def _procure_calculation_all(self, cr, uid, ids, context):
+ """
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ """
+ proc_obj = self.pool.get('mrp.procurement')
+ for proc in self.browse(cr, uid, ids):
+ proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
+ context=context)
+ return {}
+
+ def procure_calculation(self, cr, uid, ids, context):
+ """
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ """
+ threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
+ threaded_calculation.start()
+ return {}
+
+procurement_compute()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp/wizard/schedulers_all_view.xml b/addons/mrp/wizard/schedulers_all_view.xml
new file mode 100644
index 00000000000..b8b465e03e9
--- /dev/null
+++ b/addons/mrp/wizard/schedulers_all_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ Compute Schedulers
+ mrp.procurement.compute.all
+ form
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/wizard_change_production_qty.py b/addons/mrp/wizard/wizard_change_production_qty.py
deleted file mode 100644
index a9a8387acdf..00000000000
--- a/addons/mrp/wizard/wizard_change_production_qty.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import time
-import wizard
-import ir
-import pooler
-from osv.osv import except_osv
-from osv import fields,osv
-import netsvc
-from tools.translate import _
-
-
-form1 = '''
-'''
-
-form1_fields={
- 'product_qty': {'string': 'Product Qty', 'type':'float', 'required':True},
- }
-
-def _get_qty(self,cr,uid, data, state):
- prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
- prod = prod_obj.browse(cr, uid,data['ids'])[0]
- form1_fields['product_qty']['default']=prod.product_qty
- return {}
-def _get_states(self, cr, uid, data, context):
- prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
- prod = prod_obj.browse(cr, uid,data['ids'])[0]
- if prod.state in ('cancel', 'done'):
- raise wizard.except_wizard(_('Warning !'), _('The production is in "%s" state. You can not change the production quantity anymore') % (prod.state).upper() )
- return 'end'
- if prod.state in ('draft'):
- #raise wizard.except_wizard('Warning !', 'The production is in "%s" state. You can change the production quantity directly...!!!' % (prod.state).upper() )
- return 'end'
- else:
- return 'confirm'
-
-def _change_prod_qty(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- prod_obj = pool.get('mrp.production')
- prod = prod_obj.browse(cr, uid,data['ids'])[0]
- prod_obj.write(cr, uid,prod.id, {'product_qty' : data['form']['product_qty']})
- prod_obj.action_compute(cr, uid, [prod.id])
-
- move_lines_obj = pool.get('stock.move')
- for move in prod.move_lines:
- bom_point = prod.bom_id
- bom_id = prod.bom_id.id
- if not bom_point:
- bom_id = pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
- if not bom_id:
- raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
- self.write(cr, uid, [prod.id], {'bom_id': bom_id})
- bom_point = pool.get('mrp.bom').browse(cr, uid, [bom_id])[0]
-
- if not bom_id:
- raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
-
- factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
- res = pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
- for r in res[0]:
- if r['product_id']== move.product_id.id:
- move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']})
-
- product_lines_obj = pool.get('mrp.production.product.line')
-
- for m in prod.move_created_ids:
- move_lines_obj.write(cr, uid,m.id, {'product_qty' : data['form']['product_qty']})
-
- return {}
-
-class change_production_qty(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state' : _get_states}
- },
-
- 'confirm' : {
- 'actions' : [_get_qty],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state':[('end','Cancel'),('validate','Validate')]}
- },
-
- 'validate': {
- 'actions': [],
- 'result': {'type':'action', 'action':_change_prod_qty, 'state':'end'}
- },
-
- 'end' : {
- 'actions' : [],
- 'result': {'type': 'state', 'state': 'end'},
- },
- }
-
-change_production_qty('change_production_qty')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/wizard/wizard_orderpoint_procurement.py b/addons/mrp/wizard/wizard_orderpoint_procurement.py
deleted file mode 100644
index a4fa57bb9a8..00000000000
--- a/addons/mrp/wizard/wizard_orderpoint_procurement.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-#
-# Order Point Method:
-# - Order if the virtual stock of today is bellow the min of the defined order point
-#
-
-import wizard
-import threading
-import pooler
-
-parameter_form = '''
-'''
-
-parameter_fields = {
- 'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'If the stock of a product is under 0, it will act like an orderpoint', 'default': lambda *a: False},
-}
-
-def _procure_calculation_orderpoint(self, db_name, uid, data, context):
- db, pool = pooler.get_db_and_pool(db_name)
- cr = db.cursor()
- try:
- proc_obj = pool.get('mrp.procurement')
- automatic = data['form']['automatic']
- proc_obj._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
- use_new_cursor=cr.dbname, context=context)
- finally:
- cr.close()
- return {}
-
-def _procure_calculation(self, cr, uid, data, context):
- threaded_calculation = threading.Thread(target=_procure_calculation_orderpoint, args=(self, cr.dbname, uid, data, context))
- threaded_calculation.start()
- return {}
-
-class procurement_compute(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock')]}
- },
- 'compute': {
- 'actions': [_procure_calculation],
- 'result': {'type': 'state', 'state':'end'}
- },
- }
-procurement_compute('mrp.procurement.orderpoint.compute')
-
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp/wizard/wizard_schedulers_all.py b/addons/mrp/wizard/wizard_schedulers_all.py
deleted file mode 100644
index e93e31c0599..00000000000
--- a/addons/mrp/wizard/wizard_schedulers_all.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import threading
-import pooler
-
-parameter_form = '''
-'''
-
-parameter_fields = {
- 'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.', 'default': lambda *a: False},
-}
-
-def _procure_calculation_all(self, db_name, uid, data, context):
- db, pool = pooler.get_db_and_pool(db_name)
- cr = db.cursor()
- proc_obj = pool.get('mrp.procurement')
- automatic = data['form']['automatic']
- proc_obj.run_scheduler(cr, uid, automatic=automatic, use_new_cursor=cr.dbname,\
- context=context)
- cr.close()
- return {}
-
-def _procure_calculation(self, cr, uid, data, context):
- threaded_calculation = threading.Thread(target=_procure_calculation_all, args=(self, cr.dbname, uid, data, context))
- threaded_calculation.start()
- return {}
-
-class procurement_compute(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock') ]}
- },
- 'compute': {
- 'actions': [_procure_calculation],
- 'result': {'type': 'state', 'state':'end'}
- },
- }
-procurement_compute('mrp.procurement.compute.all')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp_repair/__terp__.py b/addons/mrp_repair/__terp__.py
index 2f44e257a80..12a796b4f3b 100644
--- a/addons/mrp_repair/__terp__.py
+++ b/addons/mrp_repair/__terp__.py
@@ -37,11 +37,12 @@
'depends': ['base', 'sale', 'account'],
'update_xml': [
'security/ir.model.access.csv',
- 'mrp_repair_sequence.xml',
- 'mrp_repair_wizard.xml',
+ 'mrp_repair_sequence.xml',
+ 'wizard/mrp_repair_cancel_view.xml',
+ 'wizard/mrp_repair_make_invoice_view.xml',
'mrp_repair_view.xml',
'mrp_repair_workflow.xml',
- 'mrp_repair_report.xml'
+ 'mrp_repair_report.xml',
],
'demo_xml': [],
'installable': True,
diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py
index fc91fe1f9e6..4bdb313c3a0 100644
--- a/addons/mrp_repair/mrp_repair.py
+++ b/addons/mrp_repair/mrp_repair.py
@@ -95,7 +95,7 @@ class mrp_repair(osv.osv):
\n* The \'To be Invoiced\' state is used to generate the invoice before or after repairing done. \
\n* The \'Done\' state is set when repairing is completed.\
\n* The \'Cancelled\' state is used when user cancel repair order.'),
- 'location_id': fields.many2one('stock.location', 'Current Location', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'location_id': fields.many2one('stock.location', 'Current Location', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'location_dest_id': fields.many2one('stock.location', 'Delivery Location', readonly=True, states={'draft':[('readonly',False)]}),
'move_id': fields.many2one('stock.move', 'Move',required=True, domain="[('product_id','=',product_id)]", readonly=True, states={'draft':[('readonly',False)]}),
'guarantee_limit': fields.date('Guarantee limit', help="The guarantee limit is computed as: last move date + warranty defined on selected product. If the current date is below the guarantee limit, each operation and fee you will add will be set as 'not to invoiced' by default. Note that you can change manually afterwards."),
@@ -261,12 +261,12 @@ class mrp_repair(osv.osv):
def action_invoice_create(self, cr, uid, ids, group=False, context=None):
res={}
invoices_group = {}
- for repair in self.browse(cr, uid, ids, context=context):
+ for repair in self.browse(cr, uid, ids, context=context):
res[repair.id]=False
if repair.state in ('draft','cancel') or repair.invoice_id:
continue
if not (repair.partner_id.id and repair.partner_invoice_id.id):
- raise osv.except_osv(_('No partner !'),_('You have to select a partner in the repair form !'))
+ raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !'))
comment=repair.quotation_notes
if (repair.invoice_method != 'none'):
if group and repair.partner_invoice_id.id in invoices_group:
diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml
deleted file mode 100644
index 42383f517cc..00000000000
--- a/addons/mrp_repair/mrp_repair_wizard.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/addons/mrp_repair/wizard/__init__.py b/addons/mrp_repair/wizard/__init__.py
index ec3063f01de..4f3075f055c 100644
--- a/addons/mrp_repair/wizard/__init__.py
+++ b/addons/mrp_repair/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_cancel_repair
-import wizard_make_invoice
+import cancel_repair
+import make_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_repair/wizard/cancel_repair.py b/addons/mrp_repair/wizard/cancel_repair.py
new file mode 100644
index 00000000000..1dc4159257e
--- /dev/null
+++ b/addons/mrp_repair/wizard/cancel_repair.py
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class repair_cancel(osv.osv_memory):
+ _name = 'mrp.repair.cancel'
+ _description = 'Cancel Repair'
+
+ def cancel_repair(self, cr, uid, ids, context):
+ """
+ @summary: Cancels the repair
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ record_id = context and context.get('active_id', False) or False
+ assert record_id, _('Active ID is not Found')
+ repair_order_obj = self.pool.get('mrp.repair')
+ repair_line_obj = self.pool.get('mrp.repair.line')
+ repair_order = repair_order_obj.browse(cr, uid, record_id)
+
+ if repair_order.invoiced or repair_order.invoice_method == 'none':
+ repair_order_obj.action_cancel(cr, uid, [record_id], context=context)
+ else:
+ raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.'))
+
+ return {}
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ """
+ @summary: Changes the view dynamically
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param context: A standard dictionary
+
+ @return: New arch of view.
+
+ """
+ record_id = context and context.get('order_id', False) or False
+ res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+ if record_id:
+ repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id)
+ if not repair_order.invoiced:
+ res['arch'] = """
+ """
+ return res
+
+repair_cancel()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp_repair/wizard/make_invoice.py b/addons/mrp_repair/wizard/make_invoice.py
new file mode 100644
index 00000000000..cc82f0590da
--- /dev/null
+++ b/addons/mrp_repair/wizard/make_invoice.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv, fields
+
+class make_invoice(osv.osv_memory):
+ _name = 'mrp.repair.make_invoice'
+ _description = 'Make Invoice'
+
+ _columns = {
+ 'group': fields.boolean('Group by partner invoice address'),
+ }
+
+ def make_invoices(self, cr, uid, ids, context):
+ """
+ @summary: Generates invoice(s) of selected records.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return: Loads the view of new invoice(s).
+
+ """
+ inv = self.browse(cr, uid, ids[0])
+ order_obj = self.pool.get('mrp.repair')
+ newinv = order_obj.action_invoice_create(cr, uid, context['active_ids'], group=inv.group,context=context)
+
+ return {
+ 'domain': [('id','in', newinv.values())],
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'view_id': False,
+ 'context': "{'type':'out_invoice'}",
+ 'type': 'ir.actions.act_window'
+ }
+
+make_invoice()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml b/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml
new file mode 100644
index 00000000000..c4c939486d0
--- /dev/null
+++ b/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ Cancel Repair
+ mrp.repair.cancel
+ form
+
+
+
+
+
+
+ Cancel Repair Order
+ ir.actions.act_window
+ mrp.repair.cancel
+ form
+ form
+ new
+ {'order_id':active_id}
+
+
+
+
+
diff --git a/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml b/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml
new file mode 100644
index 00000000000..f914d198d06
--- /dev/null
+++ b/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Make Invoice
+ mrp.repair.make_invoice
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp_repair/wizard/wizard_cancel_repair.py b/addons/mrp_repair/wizard/wizard_cancel_repair.py
deleted file mode 100644
index d895096ce6f..00000000000
--- a/addons/mrp_repair/wizard/wizard_cancel_repair.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-cancel_form = """
-
-"""
-
-cancel_fields = {}
-
-def check_state(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
- if repair_obj.invoice_id:
- return 'display'
- else:
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
- return 'end'
-
-
-def _cancel_repair(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
- mrp_line_obj = pool.get('mrp.repair.line')
- for line in repair_obj:
- mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
- return {}
-
-class repair_cancel(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state' : check_state}
- },
-
- 'display' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : cancel_form,
- 'fields' : cancel_fields,
- 'state' : [('end', 'No'),('yes', 'Yes') ]}
- },
- 'yes' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action' : _cancel_repair,
- 'state' : 'end'}
- },
- 'end' : {
- 'actions' : [],
- 'result': {'type': 'state', 'state': 'end'},
- },
- }
-repair_cancel("mrp.repair.cancel")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp_repair/wizard/wizard_make_invoice.py b/addons/mrp_repair/wizard/wizard_make_invoice.py
deleted file mode 100644
index 71aefadfe4b..00000000000
--- a/addons/mrp_repair/wizard/wizard_make_invoice.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-invoice_form = """
-
-"""
-invoice_fields = {
- 'group': {
- 'string': 'Group by partner invoice address',
- 'type':'boolean'
- },
-}
-
-ack_form = """
-"""
-
-ack_fields = {}
-
-def _makeInvoices(self, cr, uid, data, context):
- order_obj = pooler.get_pool(cr.dbname).get('mrp.repair')
- newinv = order_obj.action_invoice_create(cr, uid, data['ids'],group=data['form']['group'],context=context)
-
- return {
- 'domain': [('id','in', newinv.values())],
- 'name': 'Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'view_id': False,
- 'context': "{'type':'out_refund'}",
- 'type': 'ir.actions.act_window'
- }
-
-
-class make_invoice(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : invoice_form,
- 'fields' : invoice_fields,
- 'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]}
- },
- 'invoice' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action' : _makeInvoices,
- 'state' : 'end'}
- },
- }
-make_invoice("mrp.repair.make_invoice")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/__terp__.py b/addons/point_of_sale/__terp__.py
index 794793e3baa..464cb57ccf4 100644
--- a/addons/point_of_sale/__terp__.py
+++ b/addons/point_of_sale/__terp__.py
@@ -43,6 +43,7 @@ Main features :
'security/ir.model.access.csv',
'pos_report.xml',
'pos_wizard.xml',
+ 'wizard/pos_add_product.xml',
'pos_view.xml',
'pos_sequence.xml',
'posrule_data.xml',
diff --git a/addons/point_of_sale/wizard/__init__.py b/addons/point_of_sale/wizard/__init__.py
index 1ff9c124861..155c9b40c8c 100644
--- a/addons/point_of_sale/wizard/__init__.py
+++ b/addons/point_of_sale/wizard/__init__.py
@@ -23,7 +23,6 @@
import wizard_pos_payment
import wizard_default_journal
import wizard_refund_order
-import wizard_add_product
import wizard_confirm
import wizard_discount
import wizard_get_sale
@@ -39,5 +38,6 @@ import wizard_pos_sales_user_current_user
import wizard_pos_details
import wizard_open_statement
import wizard_all_closed_cashbox_of_the_day
+import pos_add_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py
new file mode 100644
index 00000000000..5ff3c38192a
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_add_product.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class add_product(osv.osv_memory):
+ _name = 'pos.add.product'
+ _description = 'Add Product'
+
+ _columns = {
+ 'product_id': fields.many2one('product.product', 'Product',required=True),
+ 'quantity': fields.float('Quantity ', required=True),
+ }
+ _defaults = {
+ 'quantity': lambda *a: 1,
+ }
+
+ def select_product(self, cr, uid, ids, context):
+ """
+ @summary: To get the product and quantity and add in order .
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param context: A standard dictionary
+ @return : Retrun the add product form again for addin more product
+ """
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id',False)
+ assert record_id, _('Active ID is not found')
+ if record_id:
+ order_obj = self.pool.get('pos.order')
+ order_obj.add_product(cr, uid, record_id, this.product_id.id,this.quantity,context=context)
+
+ return {
+ 'name': _('Add Product'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'pos.add.product',
+ 'view_id': False,
+ 'target':'new',
+ 'views': False,
+ 'type': 'ir.actions.act_window',
+ }
+add_product()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_add_product.xml b/addons/point_of_sale/wizard/pos_add_product.xml
new file mode 100644
index 00000000000..5d380624f0d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_add_product.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Add Product
+ pos.add.product
+ form
+
+
+
+
+
+
+ Add Product
+ ir.actions.act_window
+ pos.add.product
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/point_of_sale/wizard/wizard_add_product.py b/addons/point_of_sale/wizard/wizard_add_product.py
deleted file mode 100644
index 0daa0bdf0db..00000000000
--- a/addons/point_of_sale/wizard/wizard_add_product.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import wizard
-
-
-_form = """
-
-"""
-_fields = {
- 'product': {
- 'string': 'Product',
- 'type': 'many2one',
- 'relation': 'product.product',
- 'required': True,
- 'default': False
- },
-
- 'quantity': {
- 'string': 'Quantity',
- 'type': 'integer',
- 'required': True,
- 'default': 1},
- }
-
-
-def _add(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_obj = pool.get('pos.order')
- order_obj.add_product(cr, uid, data['id'], data['form']['product'],
- data['form']['quantity'], context=context)
-
- return {}
-
-
-def _pre_init(self, cr, uid, data, context):
- return {'product': False, 'quantity': 1}
-
-
-class add_product(wizard.interface):
-
- states = {
- 'init': {
- 'actions': [_pre_init],
- 'result': {
- 'type': 'form',
- 'arch': _form,
- 'fields': _fields,
- 'state': [('end', 'Cancel'), ('add', '_Add product', 'gtk-ok', True)
- ]
- }
- },
- 'add': {
- 'actions': [_add],
- 'result': {
- 'type': 'state',
- 'state': 'init',
- }
- },
- }
-
-add_product('pos.add_product')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/product_margin/__terp__.py b/addons/product_margin/__terp__.py
index b0e81f341a7..9272287371a 100644
--- a/addons/product_margin/__terp__.py
+++ b/addons/product_margin/__terp__.py
@@ -31,7 +31,7 @@ the report has several options to help you get the data you need.
""",
'author': 'Tiny',
'depends': ['base', 'product', 'account'],
- 'update_xml': ['product_margin_view.xml'],
+ 'update_xml': ['wizard/product_margin_view.xml','product_margin_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,
diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml
index 03dfbdf2280..b2681fccda8 100644
--- a/addons/product_margin/product_margin_view.xml
+++ b/addons/product_margin/product_margin_view.xml
@@ -1,15 +1,13 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
product.margin.graphproduct.product
diff --git a/addons/product_margin/wizard/__init__.py b/addons/product_margin/wizard/__init__.py
index 4e2ecc2e39a..e1f1680bccb 100644
--- a/addons/product_margin/wizard/__init__.py
+++ b/addons/product_margin/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_product_margin
+import product_margin
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py
new file mode 100644
index 00000000000..e3f03b625d4
--- /dev/null
+++ b/addons/product_margin/wizard/product_margin.py
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+import time
+from osv import osv
+from osv import fields
+
+import netsvc
+import time
+from tools.translate import _
+class product_margin(osv.osv_memory):
+ '''
+ Product Margin
+ '''
+ _name = 'product.margin'
+ _description = 'Product Margin'
+
+ def action_open_window(self, cr, uid, ids, context):
+ """
+ @summary:
+
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: the account ID or list of IDs if we want more than one
+
+ @return:
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
+ view_res3 = cr.fetchone()[0]
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
+ view_res2 = cr.fetchone()[0]
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
+ view_res = cr.fetchone()[0]
+
+ #get the current product.margin object to obtain the values from it
+ product_margin_obj = self.browse(cr,uid,ids)[0]
+
+ return {
+ 'name': _('Product Margins'),
+ 'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state},
+ 'view_type': 'form',
+ "view_mode": 'tree,form,graph',
+ 'res_model':'product.product',
+ 'type': 'ir.actions.act_window',
+ 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
+ 'view_id': False,
+ 'search_view_id': id['res_id']
+ }
+
+ def action_cancel(self, cr, uid, ids, context=None):
+ """
+ @summary:
+
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: the account ID or list of IDs if we want more than one
+
+ @return:
+ """
+ return {'type':'ir.actions.act_window_close'}
+
+ _columns = {
+ #TODO : import time required to get currect date
+ 'from_date': fields.date('From'),
+ #TODO : import time required to get currect date
+ 'to_date': fields.date('To'),
+ 'invoice_state':fields.selection([
+ ('paid','Paid'),
+ ('open_paid','Open and Paid'),
+ ('draft_open_paid','Draft, Open and Paid'),
+ ],'Invoice State', select=True, required=True),
+ }
+ _defaults = {
+ 'from_date': lambda *a:time.strftime('%Y-01-01'),
+ 'to_date': lambda *a:time.strftime('%Y-01-01'),
+ 'invoice_state': lambda *a:"open_paid",
+ }
+product_margin()
diff --git a/addons/product_margin/wizard/product_margin_view.xml b/addons/product_margin/wizard/product_margin_view.xml
new file mode 100644
index 00000000000..dae9a8fcf50
--- /dev/null
+++ b/addons/product_margin/wizard/product_margin_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ product.margin.form
+ product.margin
+ form
+
+
+
+
+
+ Product Margine
+ ir.actions.act_window
+ new
+ product.margin
+ form
+ form
+
+
+
+
diff --git a/addons/product_margin/wizard/wizard_product_margin.py b/addons/product_margin/wizard/wizard_product_margin.py
deleted file mode 100644
index 625cfd4c1df..00000000000
--- a/addons/product_margin/wizard/wizard_product_margin.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import time
-
-from tools.translate import _
-
-def _action_open_window(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- mod_obj = pool.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
- view_res3 = cr.fetchone()[0]
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
- view_res2 = cr.fetchone()[0]
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
- view_res = cr.fetchone()[0]
- return {
- 'name': _('Product Margins'),
- 'context':{'date_from':data['form']['from_date'],'date_to':data['form']['to_date'],'invoice_state' : data['form']['invoice_state']},
- 'view_type': 'form',
- "view_mode": 'tree,form,graph',
- 'res_model':'product.product',
- 'type': 'ir.actions.act_window',
- 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
- 'view_id': False,
- 'search_view_id': id['res_id']
- }
-
-
-class product_margins(wizard.interface):
- form1 = '''
- '''
- form1_fields = {
- 'from_date': {
- 'string': 'From',
- 'type': 'date',
- 'default': lambda *a:time.strftime('%Y-01-01'),
-
- },
- 'to_date': {
- 'string': 'To',
- 'type': 'date',
- 'default': lambda *a:time.strftime('%Y-12-31'),
-
- },
- 'invoice_state': {
- 'string': 'Invoice State',
- 'type': 'selection',
- 'selection': [('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid'),],
- 'required': True,
- 'default': lambda *a:"open_paid",
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Margins','gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-product_margins('product.margins')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/__terp__.py b/addons/sale/__terp__.py
index 70d9f084afb..9b2bc14021c 100644
--- a/addons/sale/__terp__.py
+++ b/addons/sale/__terp__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,7 +15,7 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
@@ -45,16 +45,16 @@
'depends': ['product', 'stock', 'mrp', 'process'],
'init_xml': [],
'update_xml': [
+ 'wizard/sale_make_invoice_advance.xml',
+ 'wizard/sale_line_invoice.xml',
'security/sale_security.xml',
'security/ir.model.access.csv',
'sale_workflow.xml',
'sale_sequence.xml',
'sale_data.xml',
- 'sale_wizard.xml',
'sale_view.xml',
'sale_report_view.xml',
'sale_report.xml',
- 'sale_wizard.xml',
'stock_view.xml',
'report_sale_view.xml',
'process/sale_process.xml',
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index b3cec7496e4..2508ae0d6df 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -149,7 +149,12 @@
-
+
@@ -379,8 +384,14 @@
-
-
+
+
diff --git a/addons/sale/sale_wizard.xml b/addons/sale/sale_wizard.xml
deleted file mode 100644
index 9df05e8e5dd..00000000000
--- a/addons/sale/sale_wizard.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py
index 6141e90b83b..07c5ceea83d 100644
--- a/addons/sale/wizard/__init__.py
+++ b/addons/sale/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,13 +15,12 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
-from make_invoice import make_invoice
+#remaining make_invoice
+import sale_line_invoice
+import sale_make_invoice_advance
-import wizard_sale_line_invoice
-import make_invoice_advance
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale/wizard/make_invoice_advance.py b/addons/sale/wizard/make_invoice_advance.py
deleted file mode 100644
index eaa1fc4a14b..00000000000
--- a/addons/sale/wizard/make_invoice_advance.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-from osv import fields, osv
-from tools.translate import _
-
-form = """
-
-"""
-fields = {
- 'product_id': {'string':'Product', 'type':'many2one','relation':'product.product','required':True},
- 'amount': {'string':'Unit Price', 'type':'float', 'size':(16,2),'required':True},
- 'qtty': {'string':'Quantity', 'type':'float', 'size':(16,2),'required':True, 'default': lambda *a: 1},
-}
-
-form_msg = """
-
-"""
-fields_msg = {}
-
-def _createInvoices(self, cr, uid, data, context={}):
- list_inv = []
- pool_obj = pooler.get_pool(cr.dbname)
- obj_sale = pool_obj.get('sale.order')
- data_sale = obj_sale.browse(cr,uid,data['ids'])
- obj_lines = pool_obj.get('account.invoice.line')
- for sale in data_sale:
- address_contact = False
- address_invoice = False
- create_ids = []
- ids_inv = []
- if sale.order_policy == 'postpaid':
- raise osv.except_osv(
- _('Error'),
- _("You cannot make an advance on a sale order that is defined as 'Automatic Invoice after delivery'."))
- val = obj_lines.product_id_change(cr, uid, [], data['form']['product_id'],uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id)
- line_id =obj_lines.create(cr, uid, {
- 'name': val['value']['name'],
- 'account_id':val['value']['account_id'],
- 'price_unit': data['form']['amount'],
- 'quantity': data['form']['qtty'],
- 'discount': False,
- 'uos_id': val['value']['uos_id'],
- 'product_id':data['form']['product_id'],
- 'invoice_line_tax_id': [(6,0,val['value']['invoice_line_tax_id'])],
- 'account_analytic_id': sale.project_id and sale.project_id.id or False,
- 'note':'',
- })
- create_ids.append(line_id)
- inv = {
- 'name': sale.name,
- 'origin': sale.name,
- 'type': 'out_invoice',
- 'reference': False,
- 'account_id': sale.partner_id.property_account_receivable.id,
- 'partner_id': sale.partner_id.id,
- 'address_invoice_id':sale.partner_invoice_id.id,
- 'address_contact_id':sale.partner_order_id.id,
- 'invoice_line': [(6,0,create_ids)],
- 'currency_id' :sale.pricelist_id.currency_id.id,
- 'comment': '',
- 'payment_term':sale.payment_term.id,
- 'fiscal_position': sale.partner_id.property_account_position.id
- }
- inv_obj = pool_obj.get('account.invoice')
- inv_id = inv_obj.create(cr, uid, inv)
-
- for inv in sale.invoice_ids:
- ids_inv.append(inv.id)
- ids_inv.append(inv_id)
- obj_sale.write(cr,uid,sale.id,{'invoice_ids':[(6,0,ids_inv)]})
- list_inv.append(inv_id)
-#
-# If invoice on picking: add the cost on the SO
-# If not, the advance will be deduced when generating the final invoice
-#
- if sale.order_policy=='picking':
- pool_obj.get('sale.order.line').create(cr, uid, {
- 'order_id': sale.id,
- 'name': val['value']['name'],
- 'price_unit': -data['form']['amount'],
- 'product_uom_qty': data['form']['qtty'],
- 'product_uos_qty': data['form']['qtty'],
- 'product_uos': val['value']['uos_id'],
- 'product_uom': val['value']['uos_id'],
- 'product_id':data['form']['product_id'],
- 'discount': False,
- 'tax_id': [(6,0,val['value']['invoice_line_tax_id'])],
- }, context)
- return {'invoice_ids':list_inv}
-
-class sale_advance_payment(wizard.interface):
- def _open_invoice(self, cr, uid, data, context):
- pool_obj = pooler.get_pool(cr.dbname)
- mod_obj = pool_obj.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
- resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
- return {
- 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
- 'name': 'Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'views': [(False,'tree'),(resource_id,'form')],
- 'context': "{'type':'out_invoice'}",
- 'type': 'ir.actions.act_window',
- 'search_view_id': id['res_id']
- }
-
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form' , 'arch' : form,'fields' : fields,'state' : [('end','Cancel','gtk-cancel'),('create','Create Advance Invoice','gtk-ok')]}
- },
- 'create': {
- 'actions': [_createInvoices],
- 'result': {'type' : 'form' ,'arch' : form_msg,'fields' : fields_msg, 'state':[('end','Close','gtk-close'),('open','Open Advance Invoice','gtk-open')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type':'action', 'action':_open_invoice, 'state':'end'}
- }
- }
-
-sale_advance_payment("sale.advance_payment_inv")
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py
new file mode 100644
index 00000000000..0c08a0645e4
--- /dev/null
+++ b/addons/sale/wizard/sale_line_invoice.py
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+import wizard
+import netsvc
+import ir
+import pooler
+
+class sale_order_line_make_invoice(osv.osv_memory):
+ _name = "sale.order.line.make.invoice"
+ _description = "Sale OrderLine Make_invoice"
+ _columns = {
+ 'grouped': fields.boolean('Group the invoices'),
+ }
+ _default = {
+ 'grouped' : lambda *a: False
+ }
+
+ def makeInvoices(self, cr, uid, ids, context):
+ res = False
+ invoices = {}
+
+ #TODO: merge with sale.py/make_invoice
+ def make_invoice(order, lines):
+ a = order.partner_id.property_account_receivable.id
+ if order.partner_id and order.partner_id.property_payment_term.id:
+ pay_term = order.partner_id.property_payment_term.id
+ else:
+ pay_term = False
+ inv = {
+ 'name': order.name,
+ 'origin': order.name,
+ 'type': 'out_invoice',
+ 'reference': "P%dSO%d" % (order.partner_id.id, order.id),
+ 'account_id': a,
+ 'partner_id': order.partner_id.id,
+ 'address_invoice_id': order.partner_invoice_id.id,
+ 'address_contact_id': order.partner_invoice_id.id,
+ 'invoice_line': [(6,0,lines)],
+ 'currency_id' : order.pricelist_id.currency_id.id,
+ 'comment': order.note,
+ 'payment_term': pay_term,
+ 'fiscal_position': order.partner_id.property_account_position.id
+ }
+ inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
+ return inv_id
+
+ for line in self.pool.get('sale.order.line').browse(cr,uid,context['active_ids']):
+ if (not line.invoiced) and (line.state not in ('draft','cancel')):
+ if not line.order_id.id in invoices:
+ invoices[line.order_id.id] = []
+ line_id = self.pool.get('sale.order.line').invoice_line_create(cr, uid,
+ [line.id])
+ for lid in line_id:
+ invoices[line.order_id.id].append((line, lid))
+ self.pool.get('sale.order.line').write(cr, uid, [line.id],
+ {'invoiced': True})
+ flag = True
+ data_sale = self.pool.get('sale.order').browse(cr,uid,line.order_id.id)
+ for line in data_sale.order_line:
+ if not line.invoiced:
+ flag = False
+ break
+ if flag:
+ wf_service = netsvc.LocalService('workflow')
+ wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
+ self.pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'})
+
+ for result in invoices.values():
+ order = result[0][0].order_id
+ il = map(lambda x: x[1], result)
+ res = make_invoice(order, il)
+ cr.execute('INSERT INTO sale_order_invoice_rel \
+ (order_id,invoice_id) values (%s,%s)', (order.id, res))
+ return {}
+
+
+sale_order_line_make_invoice()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/wizard/sale_line_invoice.xml b/addons/sale/wizard/sale_line_invoice.xml
new file mode 100644
index 00000000000..a9ea13ea900
--- /dev/null
+++ b/addons/sale/wizard/sale_line_invoice.xml
@@ -0,0 +1,28 @@
+
+
+
+
+ Sale OrderLine Make Invoice
+ sale.order.line.make.invoice
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py
new file mode 100644
index 00000000000..9a079c4f8ec
--- /dev/null
+++ b/addons/sale/wizard/sale_make_invoice_advance.py
@@ -0,0 +1,154 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.translate import _
+import ir
+import netsvc
+import pooler
+import wizard
+
+
+class sale_advance_payment_inv(osv.osv_memory):
+ _name = "sale.advance.payment.inv"
+ _description = "Sale Advance Payment Invoice"
+ _columns = {
+ 'product_id': fields.many2one('product.product', 'Product', required=True),
+ 'amount': fields.float('Unit Price', size=(16, 2), required=True),
+ 'qtty': fields.float('Quantity', size=(16, 2), required=True),
+ }
+ _default = {
+ 'qtty' : lambda *a: 1
+ }
+ def createInvoices(self, cr, uid, ids, context={}):
+ list_inv = []
+ obj_sale = self.pool.get('sale.order')
+ obj_lines = self.pool.get('account.invoice.line')
+ for sale_adv_obj in self.browse(cr, uid, ids):
+ for sale in obj_sale.browse(cr, uid, context['active_ids']):
+ address_contact = False
+ address_invoice = False
+ create_ids = []
+ ids_inv = []
+ if sale.order_policy == 'postpaid':
+ raise osv.except_osv(
+ _('Error'),
+ _("You cannot make an advance on a sale order \
+ that is defined as 'Automatic Invoice after delivery'."))
+ val = obj_lines.product_id_change(cr, uid, [], sale_adv_obj.product_id.id,
+ uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id)
+ line_id =obj_lines.create(cr, uid, {
+ 'name': val['value']['name'],
+ 'account_id': val['value']['account_id'],
+ 'price_unit': sale_adv_obj.amount,
+ 'quantity': sale_adv_obj.qtty,
+ 'discount': False,
+ 'uos_id': val['value']['uos_id'],
+ 'product_id': sale_adv_obj.product_id.id,
+ 'invoice_line_tax_id': [(6, 0, val['value']['invoice_line_tax_id'])],
+ 'account_analytic_id': sale.project_id.id or False,
+ #'note':'',
+ })
+ create_ids.append(line_id)
+ inv = {
+ 'name': sale.name,
+ 'origin': sale.name,
+ 'type': 'out_invoice',
+ 'reference': False,
+ 'account_id': sale.partner_id.property_account_receivable.id,
+ 'partner_id': sale.partner_id.id,
+ 'address_invoice_id':sale.partner_invoice_id.id,
+ 'address_contact_id':sale.partner_order_id.id,
+ 'invoice_line': [(6, 0, create_ids)],
+ 'currency_id' :sale.pricelist_id.currency_id.id,
+ 'comment': '',
+ 'payment_term':sale.payment_term.id,
+ 'fiscal_position': sale.partner_id.property_account_position.id
+ }
+ inv_obj = self.pool.get('account.invoice')
+ inv_id = inv_obj.create(cr, uid, inv)
+
+ for inv in sale.invoice_ids:
+ ids_inv.append(inv.id)
+ ids_inv.append(inv_id)
+ obj_sale.write(cr, uid, sale.id, {'invoice_ids':[(6, 0, ids_inv)]})
+ list_inv.append(inv_id)
+ #
+ # If invoice on picking: add the cost on the SO
+ # If not, the advance will be deduced when generating the final invoice
+ #
+ if sale.order_policy=='picking':
+ self.pool.get('sale.order.line').create(cr, uid, {
+ 'order_id': sale.id,
+ 'name': val['value']['name'],
+ 'price_unit': -sale_adv_obj.amount,
+ 'product_uom_qty': sale_adv_obj.qtty,
+ 'product_uos_qty': sale_adv_obj.qtty,
+ 'product_uos': val['value']['uos_id'],
+ 'product_uom': val['value']['uos_id'],
+ 'product_id': sale_adv_obj.product_id.id,
+ 'discount': False,
+ 'tax_id': [(6, 0, val['value']['invoice_line_tax_id'])],
+ }, context)
+
+ return {#'invoice_ids':list_inv,
+ 'name': 'Open Invoice',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'sale.open.invoice',
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': "{'invoice_ids'=%s}" % (list_inv)
+ }
+
+sale_advance_payment_inv()
+
+class sale_open_invoice(osv.osv_memory):
+ _name = "sale.open.invoice"
+ _description = "Sale Open Invoice"
+ _columns = {
+ }
+
+ def open_invoice(self, cr, uid, ids, context):
+ mod_obj = self.pool.get('ir.model.data')
+ invoices = []
+ #TODO: Can not get invoice ids here
+ for advance_pay in self.browse(cr, uid, ids):
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ model_data_ids = self.pool.get('ir.model.data').search(cr, uid,
+ [('model', '=', 'ir.ui.view'), ('name', '=', 'invoice_form')])
+ resource_id = self.pool.get('ir.model.data').read(cr, uid, model_data_ids,
+ fields=['res_id'])[0]['res_id']
+ return {
+# 'domain': "[('id','in', ["+','.join(map(str, invoices))+"])]", # TODO
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'views': [(False, 'tree'), (resource_id, 'form')],
+ 'context': "{'type':'out_invoice'}",
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': id['res_id']
+ }
+sale_open_invoice()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/wizard/sale_make_invoice_advance.xml b/addons/sale/wizard/sale_make_invoice_advance.xml
new file mode 100644
index 00000000000..e0ad5605977
--- /dev/null
+++ b/addons/sale/wizard/sale_make_invoice_advance.xml
@@ -0,0 +1,59 @@
+
+
+
+
+ Sale Advance Payment Invoive
+ sale.advance.payment.inv
+ form
+
+
+
+
+
+
+
+
+
+
+ Open Invoice
+ sale.open.invoice
+ form
+
+
+
+
+
+
+ Open Invoice
+ ir.actions.act_window
+ sale.open.invoice
+ form
+ form
+ new
+
+
+
diff --git a/addons/sale/wizard/wizard_sale_line_invoice.py b/addons/sale/wizard/wizard_sale_line_invoice.py
deleted file mode 100644
index 8e1e49ab22d..00000000000
--- a/addons/sale/wizard/wizard_sale_line_invoice.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import ir
-import pooler
-
-invoice_form = """
-
-"""
-
-invoice_fields = {
- 'grouped' : {'string':'Group the invoices', 'type':'boolean', 'default': lambda *a: False}
-}
-
-def _makeInvoices(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- res = False
- invoices = {}
-
- #TODO: merge with sale.py/make_invoice
- def make_invoice(order, lines):
- a = order.partner_id.property_account_receivable.id
- if order.partner_id and order.partner_id.property_payment_term.id:
- pay_term = order.partner_id.property_payment_term.id
- else:
- pay_term = False
- inv = {
- 'name': order.name,
- 'origin': order.name,
- 'type': 'out_invoice',
- 'reference': "P%dSO%d" % (order.partner_id.id, order.id),
- 'account_id': a,
- 'partner_id': order.partner_id.id,
- 'address_invoice_id': order.partner_invoice_id.id,
- 'address_contact_id': order.partner_invoice_id.id,
- 'invoice_line': [(6,0,lines)],
- 'currency_id' : order.pricelist_id.currency_id.id,
- 'comment': order.note,
- 'payment_term': pay_term,
- 'fiscal_position': order.partner_id.property_account_position.id
- }
- inv_id = pool.get('account.invoice').create(cr, uid, inv)
- return inv_id
-
- for line in pool.get('sale.order.line').browse(cr,uid,data['ids']):
- if (not line.invoiced) and (line.state not in ('draft','cancel')):
- if not line.order_id.id in invoices:
- invoices[line.order_id.id] = []
- line_id = pool.get('sale.order.line').invoice_line_create(cr, uid,
- [line.id])
- for lid in line_id:
- invoices[line.order_id.id].append((line, lid))
- pool.get('sale.order.line').write(cr, uid, [line.id],
- {'invoiced': True})
- flag = True
- data_sale = pool.get('sale.order').browse(cr,uid,line.order_id.id)
- for line in data_sale.order_line:
- if not line.invoiced:
- flag = False
- break
- if flag:
- wf_service = netsvc.LocalService('workflow')
- wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
- pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'})
-
- for result in invoices.values():
- order = result[0][0].order_id
- il = map(lambda x: x[1], result)
- res = make_invoice(order, il)
- cr.execute('INSERT INTO sale_order_invoice_rel \
- (order_id,invoice_id) values (%s,%s)', (order.id, res))
- return {}
-
-
-class line_make_invoice(wizard.interface):
- states = {
- 'init' : {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': invoice_form,
- 'fields': invoice_fields,
- 'state': [
- ('end', 'Cancel'),
- ('invoice', 'Create invoices')
- ]
- }
- },
- 'invoice' : {
- 'actions' : [_makeInvoices],
- 'result' : {'type': 'state', 'state': 'end'}
- },
- }
-
-line_make_invoice("sale.order.line.make_invoice")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py
index d728efbf2fe..749ee99968d 100644
--- a/addons/stock/__init__.py
+++ b/addons/stock/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,7 +15,7 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
@@ -27,7 +27,6 @@ import report
import wizard
import report_stock
-import stock_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/__terp__.py b/addons/stock/__terp__.py
index 8081c4b6738..72ebda3b16e 100644
--- a/addons/stock/__terp__.py
+++ b/addons/stock/__terp__.py
@@ -41,11 +41,16 @@ Thanks to the double entry management, the inventory controlling is powerful and
"init_xml" : [],
"demo_xml" : ["stock_demo.xml"],
"update_xml" : [
- "stock_workflow.xml",
"stock_data.xml",
+ "wizard/stock_move_view.xml",
+ "wizard/stock_inventory_set_stock_zero_view.xml",
+ "wizard/stock_fill_inventory_view.xml",
+ "wizard/stock_invoice_onshipping_view.xml",
+ "wizard/stock_location_product_view.xml",
+ "wizard/stock_inventory_line_split_view.xml",
+ "stock_workflow.xml",
"stock_incoterms.xml",
- "stock_wizard.xml",
- "stock_wizard_view.xml",
+ "stock_wizard.xml",
"stock_view.xml",
"stock_report.xml",
"stock_sequence.xml",
diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv
index eea058ebde1..581308694b8 100644
--- a/addons/stock/security/ir.model.access.csv
+++ b/addons/stock/security/ir.model.access.csv
@@ -22,4 +22,10 @@
"access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0
"access_stock_move_scrap","stock.move.scrap","model_stock_move_scrap","stock.group_stock_user",1,0,0,0
"access_stock_move_split","stock.move.split","model_stock_move_split","stock.group_stock_user",1,0,0,0
+"access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0"access_report_products_to_received_planned","report.products.to.received.planned","model_report_products_to_received_planned","stock.group_stock_user",1,0,0,0
+"access_report_delivery_products_planned","report.delivery.products.planned","model_report_delivery_products_planned","stock.group_stock_user",1,0,0,0
+"access_stock_move_track","stock.move.track","model_stock_move_track","stock.group_stock_user",1,0,0,0
+"access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0
+"access_stock_move_scrap","stock.move.scrap","model_stock_move_scrap","stock.group_stock_user",1,0,0,0
+"access_stock_move_split","stock.move.split","model_stock_move_split","stock.group_stock_user",1,0,0,0
"access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0
\ No newline at end of file
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index a403c141be4..31ffe5b6242 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1309,7 +1309,40 @@ class stock_move(osv.osv):
wf_service.trg_trigger(uid, 'stock.move', id, cr)
#self.action_cancel(cr,uid, ids2, context)
return True
-
+
+ def action_scrap(self, cr, uid, ids,context=None):
+ '''
+ add the damaged product into consumed product by updating its state to cancel and
+ add same product since we need that product to manufacture the parent product.
+
+ :param cr: the database cursor
+ :param uid: the user id
+ :param ids: ids of product object to be scraped
+ :param context: context arguments
+ :return:
+ '''
+# to find the parent id(manufacturing order) of the active record(product to consume),
+# obtain active record id 1st and then get the production_id from mrp_production_move_ids
+ active_id=ids[0]
+ cr.execute("select production_id from mrp_production_move_ids where move_id=%s" % (active_id))
+# it gives parent id in [list(tuple)] format so extract it [(21,)]
+ parent_id = int(cr.fetchall()[0][0])
+# get the parent object
+ parent_obj = self.pool.get('mrp.production').browse(cr, uid, parent_id)
+# create copy for multiple id processing for product to consume which r scraped
+ for id in ids:
+ #create copy of the product records which are scraped due to damage since they are
+ #still required to manufacture the product.
+ new_rec_id = self.copy(cr, uid, id, {'state': 'waiting'}, context)
+
+ #assign all new products which will replace damaged product to the current manufacturing order
+ cr.execute('insert into mrp_production_move_ids (production_id,move_id) values (%s,%s)', (parent_id, new_rec_id))
+
+# all damaged product needs to be in consumed product window having cancel state.
+ vals={'state': 'cancel', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')}
+ self.pool.get('stock.move').write(cr, uid, ids,vals )
+
+ return True
def action_done(self, cr, uid, ids, context=None):
track_flag = False
picking_ids = []
@@ -1563,11 +1596,27 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.id], update_val)
if consume:
- self.action_done(cr, uid, res)
+ self.action_done(cr, uid, res)
+ else:
+ self.action_scrap(cr, uid, res,context)
return res
def scrap_moves(self, cr, uid, ids, quantity, location_dest_id, context=None):
- return self.consume_moves(cr, uid, ids, quantity, location_id=False, location_dest_id=location_dest_id, consume=False, context=context)
+ if quantity <= 0:
+ raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
+ res = []
+ for move in self.browse(cr, uid, ids, context=context):
+ move_qty = move.product_qty
+ uos_qty = quantity / move_qty * move.product_uos_qty
+ default_val = {
+ 'product_qty': quantity,
+ 'product_uos_qty': uos_qty,
+ 'state': move.state,
+ 'location_dest_id': location_dest_id
+ }
+ new_move = self.copy(cr, uid, move.id, default_val)
+ res += [new_move]
+ return res
stock_move()
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 3cada5cbb6d..f6ffdb9cbde 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -32,8 +32,10 @@
-
-
+
+
@@ -50,6 +52,7 @@
+
@@ -64,6 +67,7 @@
+
stock.inventory.form
@@ -89,11 +93,12 @@
+
-
-
-
-
+
+
@@ -106,6 +111,7 @@
+
@@ -138,6 +144,9 @@
+
+
+
@@ -259,6 +268,7 @@
+
@@ -524,7 +534,7 @@
new{'action_id': active_id}
-
+
stock.picking.calendar
@@ -585,7 +595,7 @@
-
+
-
+
@@ -683,7 +693,8 @@
-
+
+
@@ -726,6 +737,7 @@
+
@@ -740,7 +752,7 @@
-
+
-
+
@@ -831,7 +843,8 @@
-
+
+
@@ -890,9 +903,6 @@
-
@@ -925,7 +935,7 @@
-
+
-
-
+
+
+
@@ -1110,8 +1121,8 @@
name="%(stock.move_scrap)d"
string="D" type="action"
icon="gtk-convert"
- states="draft,waiting,confirmed,assigned" />
-
+ states="done,cancel" />
+
+
+
@@ -1240,7 +1252,8 @@
-
+
+
@@ -1278,7 +1291,7 @@
-
+
@@ -1317,7 +1330,7 @@
-
+
@@ -1327,7 +1340,7 @@
domain="[('product_id','=?',product_id)]"
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
-
+
@@ -1359,7 +1372,8 @@
-
+
+
@@ -1410,7 +1424,7 @@
-
+
@@ -1488,11 +1502,12 @@
-
+
-
-
+
+
+
@@ -1606,7 +1621,7 @@
tree_but_openstock.locationOpen Products
-
+
diff --git a/addons/stock/stock_wizard.xml b/addons/stock/stock_wizard.xml
index 5db1269d42c..d562ddfbb9f 100644
--- a/addons/stock/stock_wizard.xml
+++ b/addons/stock/stock_wizard.xml
@@ -43,20 +43,6 @@
name="stock.return.picking"
string="Return picking"/>
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py
index 6a15449a151..4d0db45aa45 100644
--- a/addons/stock/wizard/__init__.py
+++ b/addons/stock/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,11 +15,12 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
import stock_traceability
+import stock_move
import wizard_partial_picking
import wizard_partial_move
import wizard_picking_make
@@ -27,12 +28,13 @@ import wizard_replacement
import wizard_return
import wizard_split_lot_line
import wizard_ups
-import wizard_invoice_onshipping
-import wizard_location_product
-import wizard_inventory
-import wizard_split_inventory_lots
-import inventory_merge_zero
import inventory_merge
+import stock_inventory_set_stock_zero
+import stock_fill_inventory
+import stock_inventory_line_split
+import stock_invoice_onshipping
+import stock_location_product
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py
deleted file mode 100644
index 3aa2b1e9fd9..00000000000
--- a/addons/stock/wizard/inventory_merge_zero.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-
-import wizard
-import pooler
-from tools.translate import _
-
-
-_form = """
-
-"""
-_inventory_fields = {
- 'location_id' : {
- 'string':'Location',
- 'type':'many2one',
- 'relation':'stock.location',
- 'required':True
- }
-}
-
-
-def do_merge(self, cr, uid, data, context):
- invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
- invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
- prod_obj = pooler.get_pool(cr.dbname).get('product.product')
-
- if len(data['ids']) <> 1:
- raise wizard.except_wizard(_('Warning'),
- _('Please select one and only one inventory !'))
-
- loc = str(data['form']['location_id'])
-
- cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],))
- inv = cr.fetchall()
- cr.execute('select distinct product_id from stock_move where location_dest_id=%s or location_id=%s',(loc,loc,))
- stock = cr.fetchall()
- for s in stock:
- if (loc,s[0]) not in inv:
- p = prod_obj.browse(cr, uid, s[0])
- invent_line_obj.create(cr, uid, {
- 'inventory_id': data['ids'][0],
- 'location_id': loc,
- 'product_id': s[0],
- 'product_uom': p.uom_id.id,
- 'product_qty': 0.0,
- })
- return {}
-
-
-class merge_inventory(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : _form,
- 'fields' : _inventory_fields,
- 'state' : [('end', 'Cancel', 'gtk-cancel'),
- ('merge', 'Set to Zero', 'gtk-apply', True) ]}
- },
- 'merge' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action': do_merge,
- 'state' : 'end'}
- },
- }
-merge_inventory("inventory.merge.stock.zero")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py
new file mode 100644
index 00000000000..1874e66141d
--- /dev/null
+++ b/addons/stock/wizard/stock_fill_inventory.py
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+
+class stock_fill_inventory(osv.osv_memory):
+ _name = "stock.fill.inventory"
+ _description = "Fill Inventory"
+ _columns = {
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ 'recursive': fields.boolean("Include all childs for the location"),
+ }
+
+ def fill_inventory(self, cr, uid, ids, context):
+ inventory_line_obj = self.pool.get('stock.inventory.line')
+ location_obj = self.pool.get('stock.location')
+ for fill_inventory in self.browse(cr, uid, ids):
+ res = {}
+ res_location = {}
+ if fill_inventory.recursive :
+ location_ids = location_obj.search(cr, uid, [('location_id',
+ 'child_of', fill_inventory.location_id.id)])
+ for location in location_ids :
+ res = location_obj._product_get(cr, uid, location)
+ res_location[location] = res
+ else:
+ context.update({'compute_child': False})
+ res = location_obj._product_get(cr, uid,
+ fill_inventory.location_id.id, context=context)
+ res_location[fill_inventory.location_id.id] = res
+
+ product_ids = []
+ for location in res_location.keys():
+ res = res_location[location]
+ for product_id in res.keys():
+ prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0]
+ uom = prod.uom_id.id
+ context.update({'uom': uom})
+ amount = self.pool.get('stock.location')._product_get(cr, uid,
+ location, [product_id], context=context)[product_id]
+
+ if(amount):
+ line_ids=inventory_line_obj.search(cr, uid,
+ [('inventory_id', '=', context['active_ids']),
+ ('location_id', '=', location),
+ ('product_id', '=', product_id),
+ ('product_uom', '=', uom),
+ ('product_qty', '=', amount)])
+ if not len(line_ids):
+ inventory_line = {'inventory_id': context['active_ids'][0],
+ 'location_id': location,
+ 'product_id': product_id,
+ 'product_uom': uom,
+ 'product_qty': amount}
+ inventory_line_obj.create(cr, uid, inventory_line)
+ product_ids.append(product_id)
+
+ if(len(product_ids) == 0):
+ raise osv.except_osv(_('Message !'), _('No product in this location.'))
+ return {}
+
+stock_fill_inventory()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml
new file mode 100644
index 00000000000..ef95a3bf447
--- /dev/null
+++ b/addons/stock/wizard/stock_fill_inventory_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ Fill Inventory
+ stock.fill.inventory
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py
new file mode 100644
index 00000000000..1723f7b3032
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_line_split.py
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_inventory_line_split(osv.osv_memory):
+ _name = "stock.inventory.line.split"
+ _description = "Split inventory lines"
+ _columns = {
+ 'prefix': fields.char('Prefix', size=64),
+ 'quantity': fields.float('Quantity per lot'),
+ }
+
+ def _check_production_lot(self, cr, uid, context):
+ for inv_obj in self.pool.get('stock.inventory.line').browse(cr, uid, \
+ context['active_ids']):
+ if not inv_obj.prod_lot_id:
+ raise osv.except_osv(_('Caution!'), _('Before splitting the \
+inventory lines, make sure the production lot is assigned to this product.'))
+ return
+
+ _defaults = {
+ 'quantity': lambda *a: '1',
+ 'prefix': _check_production_lot,
+ }
+
+ def split_lines(self, cr, uid, ids, context):
+ inv_id = context['active_id']
+ inv_line_obj = self.pool.get('stock.inventory.line')
+ prodlot_obj = self.pool.get('stock.production.lot')
+ for linesplit_obj in self.browse(cr, uid, ids):
+ ir_sequence_obj = self.pool.get('ir.sequence')
+
+ sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
+ if not sequence:
+ raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
+ if linesplit_obj.prefix:
+ sequence = linesplit_obj.prefix + '/' + (sequence or '')
+
+ inv = inv_line_obj.browse(cr, uid, [inv_id])[0]
+ quantity = linesplit_obj.quantity
+ prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name': sequence})
+
+ if quantity <= 0 or inv.product_qty == 0:
+ return {}
+
+ quantity_rest = inv.product_qty % quantity
+
+ update_val = {
+ 'product_qty': quantity,
+ }
+
+ new_line = []
+ for idx in range(int(inv.product_qty // quantity)):
+ if idx:
+ current_line = inv_line_obj.copy(cr, uid, inv.id,
+ {'prod_lot_id': inv.prod_lot_id.id})
+ new_line.append(current_line)
+ else:
+ current_line = inv.id
+ inv_line_obj.write(cr, uid, [current_line], update_val)
+
+ if quantity_rest > 0:
+ idx = int(inv.product_qty // quantity)
+ update_val['product_qty'] = quantity_rest
+
+ if idx:
+ current_line = inv_line_obj.copy(cr, uid, inv.id,
+ {'prod_lot_id': inv.prod_lot_id.id})
+ new_line.append(current_line)
+ else:
+ current_line = inv_line_obj.id
+ inv_line_obj.write(cr, uid, [current_line], update_val)
+
+ return {}
+
+stock_inventory_line_split()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_inventory_line_split_view.xml b/addons/stock/wizard/stock_inventory_line_split_view.xml
new file mode 100644
index 00000000000..a2c9f2d065a
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_line_split_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ Split inventory lines
+ stock.inventory.line.split
+ form
+
+
+
+
+
+
+ Split inventory lines
+ ir.actions.act_window
+ stock.inventory.line.split
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py
new file mode 100644
index 00000000000..3d14d8bc1c3
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_set_stock_zero.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+
+class inventory_merge_stock_zero(osv.osv_memory):
+ _name = "stock.inventory.merge.stock.zero"
+ _description = "Set Stock to 0"
+ _columns = {
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ }
+
+ def do_merge(self, cr, uid, ids, context):
+ invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
+ invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
+ prod_obj = pooler.get_pool(cr.dbname).get('product.product')
+
+ if len(context['active_ids']) <> 1:
+ raise wizard.except_wizard(_('Warning'),
+ _('Please select one and only one inventory !'))
+ for id in ids:
+ datas = self.read(cr, uid, id)
+ loc = str(datas['location_id'])
+
+ cr.execute('select distinct location_id,product_id \
+ from stock_inventory_line \
+ where inventory_id=%s', (context['active_id'],))
+ inv = cr.fetchall()
+ cr.execute('select distinct product_id from stock_move where \
+ location_dest_id=%s or location_id=%s', (loc, loc,))
+ stock = cr.fetchall()
+ for s in stock:
+ if (loc, s[0]) not in inv:
+ p = prod_obj.browse(cr, uid, s[0])
+ invent_line_obj.create(cr, uid, {
+ 'inventory_id': context['active_id'],
+ 'location_id': loc,
+ 'product_id': s[0],
+ 'product_uom': p.uom_id.id,
+ 'product_qty': 0.0,
+ })
+ return {}
+
+inventory_merge_stock_zero()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
new file mode 100644
index 00000000000..a6456917023
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Set Stock to Zero
+ stock.inventory.merge.stock.zero
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py
new file mode 100644
index 00000000000..82043fc0532
--- /dev/null
+++ b/addons/stock/wizard/stock_invoice_onshipping.py
@@ -0,0 +1,111 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_invoice_onshipping(osv.osv_memory):
+ _name = "stock.invoice.onshipping"
+ _description = "Stock Invoice Onshipping"
+ _columns = {
+ 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True),
+ 'group': fields.boolean("Group by partner"),
+ 'type': fields.selection([('out_invoice', 'Customer Invoice'),
+ ('in_invoice', 'Supplier Invoice'),
+ ('out_refund', 'Customer Refund'),
+ ('in_refund', 'Supplier Refund')] , 'Type', required=True),
+ 'invoice_date': fields.date('Invoiced date'),
+ }
+
+ def _get_type(self, cr, uid, context):
+ picking_obj = self.pool.get('stock.picking')
+ usage = 'customer'
+ pick = picking_obj.browse(cr, uid, context['active_id'])
+ if pick.invoice_state == 'invoiced':
+ raise osv.except_osv(_('UserError'), _('Invoice is already created.'))
+ if pick.invoice_state == 'none':
+ raise osv.except_osv(_('UserError'), _('Invoice cannot be created from Picking.'))
+ if pick.move_lines:
+ usage = pick.move_lines[0].location_id.usage
+
+ if pick.type == 'out' and usage == 'supplier':
+ type = 'in_refund'
+ elif pick.type == 'out' and usage == 'customer':
+ type = 'out_invoice'
+ elif pick.type == 'in' and usage == 'supplier':
+ type = 'in_invoice'
+ elif pick.type == 'in' and usage == 'customer':
+ type = 'out_refund'
+ else:
+ type = 'out_invoice'
+ return type
+
+ _defaults = {
+ 'type': _get_type,
+ }
+
+ def create_invoice(self, cr, uid, ids, context):
+ result = []
+ for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']):
+ if context.get('new_picking', False):
+ onshipdata_obj[id] = onshipdata_obj.new_picking
+ onshipdata_obj[ids] = onshipdata_obj.new_picking
+
+ picking_obj = self.pool.get('stock.picking')
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+
+ type = onshipdata_obj['type']
+ context['date_inv'] = onshipdata_obj['invoice_date']
+ res = picking_obj.action_invoice_create(cr, uid,context['active_ids'],
+ journal_id = onshipdata_obj['journal_id'],
+ group=onshipdata_obj['group'],
+ type=type,
+ context=context)
+ invoice_ids = res.values()
+ if not invoice_ids:
+ raise osv.except_osv(_('Error'), _('Invoice is not created'))
+
+ if type == 'out_invoice':
+ xml_id = 'action_invoice_tree1'
+ elif type == 'in_invoice':
+ xml_id = 'action_invoice_tree2'
+ elif type == 'out_refund':
+ xml_id = 'action_invoice_tree3'
+ else:
+ xml_id = 'action_invoice_tree4'
+
+ result = mod_obj._get_id(cr, uid, 'account', xml_id)
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ result = act_obj.read(cr, uid, id['res_id'])
+ result['res_id'] = invoice_ids
+ return result
+
+stock_invoice_onshipping()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock/wizard/stock_invoice_onshipping_view.xml
new file mode 100644
index 00000000000..62689019af0
--- /dev/null
+++ b/addons/stock/wizard/stock_invoice_onshipping_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ Stock Invoice Onshipping
+ stock.invoice.onshipping
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_location_product.py b/addons/stock/wizard/stock_location_product.py
new file mode 100755
index 00000000000..0c307492bf3
--- /dev/null
+++ b/addons/stock/wizard/stock_location_product.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_location_product(osv.osv_memory):
+ _name = "stock.location.product"
+ _description = "Products by Location"
+ _columns = {
+ 'from_date': fields.datetime('From'),
+ 'to_date': fields.datetime('To'),
+ }
+
+ def action_open_window(self, cr, uid, ids, context):
+ mod_obj = self.pool.get('ir.model.data')
+ for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']):
+ result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ return {
+ 'name': 'product',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'product.product',
+ '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')],
+ 'search_view_id': id['res_id']
+ }
+
+stock_location_product()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_location_product_view.xml b/addons/stock/wizard/stock_location_product_view.xml
new file mode 100644
index 00000000000..518bc6eab35
--- /dev/null
+++ b/addons/stock/wizard/stock_location_product_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ Products by Location
+ stock.location.product
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/stock_wizard.py b/addons/stock/wizard/stock_move.py
similarity index 100%
rename from addons/stock/stock_wizard.py
rename to addons/stock/wizard/stock_move.py
diff --git a/addons/stock/stock_wizard_view.xml b/addons/stock/wizard/stock_move_view.xml
similarity index 100%
rename from addons/stock/stock_wizard_view.xml
rename to addons/stock/wizard/stock_move_view.xml
diff --git a/addons/stock/wizard/wizard_inventory.py b/addons/stock/wizard/wizard_inventory.py
deleted file mode 100644
index 42345353866..00000000000
--- a/addons/stock/wizard/wizard_inventory.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import time
-import wizard
-import ir
-import pooler
-from osv.osv import except_osv
-from osv import fields,osv
-import netsvc
-from tools.translate import _
-
-inventory_form = """
-
-"""
-
-inventory_fields = {
- 'location_id' : {
- 'string':'Location',
- 'type':'many2one',
- 'relation':'stock.location',
- 'required':True
- },
- 'recursive' : {'string':'Include all childs for the location', 'type':'boolean'}
-}
-
-
-
-def _fill_inventory(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- inventory_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
- location_obj = pooler.get_pool(cr.dbname).get('stock.location')
- res={}
- res_location={}
- if data['form']['recursive'] :
- location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', [data['form']['location_id']])])
- for location in location_ids :
- res=location_obj._product_get(cr, uid, location)
- res_location[location]=res
- else:
- context.update({'compute_child':False})
- res=location_obj._product_get(cr, uid, data['form']['location_id'],context=context)
- res_location[data['form']['location_id']]=res
-
- product_ids=[]
- for location in res_location.keys():
- res=res_location[location]
- for product_id in res.keys():
- #product_ids.append(product_id)
- prod = pool.get('product.product').browse(cr, uid, [product_id])[0]
- uom = prod.uom_id.id
- context.update({'uom': uom})
- amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], context=context)[product_id]
-
- if(amount):
- line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)])
- if not len(line_ids):
- inventory_line={'inventory_id':data['id'],'location_id':location,'product_id':product_id,'product_uom':uom,'product_qty':amount}
- inventory_line_obj.create(cr, uid, inventory_line)
- product_ids.append(product_id)
-
- if(len(product_ids)==0):
- raise wizard.except_wizard(_('Message !'), _('No product in this location.'))
- return {}
-
-
-
-class fill_inventory(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : inventory_form,
- 'fields' : inventory_fields,
- 'state' : [('end', 'Cancel', 'gtk-cancel'),('fill_inventory', 'Fill Inventory', 'gtk-apply', True) ]}
- },
- 'fill_inventory' : {
- 'actions' : [],
- 'result' : {'type' : 'action', 'action': _fill_inventory, 'state' : 'end'}
- },
- }
-fill_inventory("stock.fill_inventory")
-
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/wizard_invoice_onshipping.py b/addons/stock/wizard/wizard_invoice_onshipping.py
deleted file mode 100644
index 22cdbc97e70..00000000000
--- a/addons/stock/wizard/wizard_invoice_onshipping.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-from tools.translate import _
-
-invoice_form = """
-
-"""
-
-invoice_fields = {
- 'journal_id': {
- 'string': 'Destination Journal',
- 'type': 'many2one',
- 'relation': 'account.journal',
- 'required': True
- },
- 'group': {
- 'string': 'Group by partner',
- 'type': 'boolean'
- },
- 'type': {
- 'string': 'Type',
- 'type': 'selection',
- 'selection': [],
- 'required': True
- },
- 'invoice_date': {'string': 'Invoiced date', 'type':'date' }
-}
-
-
-def _get_type(obj, cr, uid, data, context):
- picking_obj = pooler.get_pool(cr.dbname).get('stock.picking')
- usage = 'customer'
- pick = picking_obj.browse(cr, uid, data['id'], context)
- if pick.invoice_state == 'invoiced':
- raise wizard.except_wizard(_('UserError'), _('Invoice is already created.'))
- if pick.invoice_state == 'none':
- raise wizard.except_wizard(_('UserError'), _('Invoice cannot be created from Picking.'))
-
- if pick.move_lines:
- usage = pick.move_lines[0].location_id.usage
-
- if pick.type =='out':
- invoice_fields['type']['selection'] = [
- ('out_invoice', 'Customer Invoice'),
- ('in_refund', 'Supplier Refund'),
- ]
- elif pick.type =='in':
- invoice_fields['type']['selection'] = [
- ('in_invoice', 'Supplier Invoice'),
- ('out_refund', 'Customer Refund'),
- ]
- else:
- invoice_fields['type']['selection']=[
- ('out_invoice', 'Customer Invoice'),
- ('in_invoice', 'Supplier Invoice'),
- ('out_refund', 'Customer Refund'),
- ('in_refund', 'Supplier Refund'),
- ]
-
- if pick.type == 'out' and usage == 'supplier':
- type = 'in_refund'
- elif pick.type == 'out' and usage == 'customer':
- type = 'out_invoice'
- elif pick.type == 'in' and usage == 'supplier':
- type = 'in_invoice'
- elif pick.type == 'in' and usage == 'customer':
- type = 'out_refund'
- else:
- type = 'out_invoice'
- return {'type': type}
-
-
-def _create_invoice(obj, cr, uid, data, context):
- if data['form'].get('new_picking', False):
- data['id'] = data['form']['new_picking']
- data['ids'] = [data['form']['new_picking']]
- pool = pooler.get_pool(cr.dbname)
- picking_obj = pooler.get_pool(cr.dbname).get('stock.picking')
- mod_obj = pool.get('ir.model.data')
- act_obj = pool.get('ir.actions.act_window')
-
- type = data['form']['type']
-
- context['date_inv'] = data['form']['invoice_date']
- res = picking_obj.action_invoice_create(cr, uid, data['ids'],
- journal_id = data['form']['journal_id'], group=data['form']['group'],
- type=type, context= context)
-
- invoice_ids = res.values()
- if not invoice_ids:
- raise wizard.except_wizard(_('Error'), _('Invoice is not created'))
-
- if type == 'out_invoice':
- xml_id = 'action_invoice_tree1'
- elif type == 'in_invoice':
- xml_id = 'action_invoice_tree2'
- elif type == 'out_refund':
- xml_id = 'action_invoice_tree3'
- else:
- xml_id = 'action_invoice_tree4'
-
- result = mod_obj._get_id(cr, uid, 'account', xml_id)
- id = mod_obj.read(cr, uid, result, ['res_id'])
- result = act_obj.read(cr, uid, id['res_id'])
- result['res_id'] = invoice_ids
- return result
-
-
-class make_invoice_onshipping(wizard.interface):
- states = {
- 'init': {
- 'actions': [_get_type],
- 'result': {
- 'type': 'form',
- 'arch': invoice_form,
- 'fields': invoice_fields,
- 'state': [
- ('end', 'Cancel', 'gtk-cancel'),
- ('create_invoice', 'Create invoice', 'gtk-apply', True)
- ]
- }
- },
- 'create_invoice': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': _create_invoice,
- 'state': 'end'
- }
- },
- }
-
-make_invoice_onshipping("stock.invoice_onshipping")
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/wizard_location_product.py b/addons/stock/wizard/wizard_location_product.py
deleted file mode 100755
index c423c426832..00000000000
--- a/addons/stock/wizard/wizard_location_product.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-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')
- result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- return {
- 'name': False,
- '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')],
- 'search_view_id': id['res_id']
- }
-
-
-class product_by_location(wizard.interface):
- form1 = '''
- '''
- form1_fields = {
- 'from_date': {
- 'string': 'From',
- 'type': 'datetime',
- },
- 'to_date': {
- 'string': 'To',
- 'type': 'datetime',
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel', 'gtk-cancel'),('open', 'Open Products', 'gtk-apply', True)]}
- },
- '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:
diff --git a/addons/stock/wizard/wizard_split_inventory_lots.py b/addons/stock/wizard/wizard_split_inventory_lots.py
deleted file mode 100644
index 92963f0b145..00000000000
--- a/addons/stock/wizard/wizard_split_inventory_lots.py
+++ /dev/null
@@ -1,98 +0,0 @@
-import wizard
-import netsvc
-import pooler
-
-import time
-from osv import osv
-from tools.translate import _
-
-inv_form = '''
-
-'''
-inv_fields = {
- 'prefix': {
- 'string': 'Prefix',
- 'type': 'char',
- 'size': 64,
- },
- 'quantity': {
- 'string': 'Quantity per lot',
- 'type': 'float',
- 'default': 1,
- }
-}
-
-def _check_production_lot(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- inv_obj = pool.get('stock.inventory.line').browse(cr, uid, data['id'])
- if not inv_obj.prod_lot_id:
- raise wizard.except_wizard(_('Caution!'), _('Before splitting the inventory lines, make sure the production lot is assigned to this product.'))
- return data['form']
-
-def _split_lines(self, cr, uid, data, context):
- inv_id = data['id']
-
- pool = pooler.get_pool(cr.dbname)
- inv_line_obj = pool.get('stock.inventory.line')
- prodlot_obj = pool.get('stock.production.lot')
-
- ir_sequence_obj = pool.get('ir.sequence')
-
- sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
- if not sequence:
- raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
- if data['form']['prefix']:
- sequence=data['form']['prefix']+'/'+(sequence or '')
-
- inv = inv_line_obj.browse(cr, uid, [inv_id])[0]
- quantity=data['form']['quantity']
- prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name':sequence})
-
- if quantity <= 0 or inv.product_qty == 0:
- return {}
-
- quantity_rest = inv.product_qty%quantity
-
- update_val = {
- 'product_qty': quantity,
- }
-
- new_line = []
- for idx in range(int(inv.product_qty//quantity)):
- if idx:
- current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id})
- new_line.append(current_line)
- else:
- current_line = inv.id
- inv_line_obj.write(cr, uid, [current_line], update_val)
-
- if quantity_rest > 0:
- idx = int(inv.product_qty//quantity)
- update_val['product_qty']=quantity_rest
-
- if idx:
- current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id})
- new_line.append(current_line)
- else:
- current_line = inv.id
- inv_line_obj.write(cr, uid, [current_line], update_val)
-
- return {}
-
-class wizard_split_inventory_lots(wizard.interface):
- states = {
- 'init': {
- 'actions': [_check_production_lot],
- 'result': {'type': 'form', 'arch': inv_form, 'fields': inv_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('split', 'Ok', 'gtk-apply', True)]},
- },
- 'split': {
- 'actions': [_split_lines],
- 'result': {'type':'state', 'state':'end'}
- }
- }
-
-wizard_split_inventory_lots('stock.inventory.line.split')
\ No newline at end of file