+
+
From 46a9cc35465a2c51625a1702d6ad02a1f8a17387 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Mon, 7 Mar 2011 11:54:32 +0530
Subject: [PATCH 07/11] [IMP]point_of_sale:code Optimize in pos_return.py
bzr revid: ron@tinyerp.com-20110307062432-dtrkxb9xuq6fmsvj
---
addons/point_of_sale/wizard/pos_return.py | 30 +++++++----------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
index 65a596d4dd3..c458044365f 100644
--- a/addons/point_of_sale/wizard/pos_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -63,15 +63,13 @@ class pos_return(osv.osv_memory):
context={}
active_ids = context.get('active_ids')
result=[]
- memory={}
for order in order_obj.browse(cr, uid, active_ids, context=context):
for line in order.lines:
- memory = {
+ result.append({
'product_id' : line.product_id.id,
'quantity' : line.qty,
'line_id':line.id
- }
- result.append(memory)
+ })
res.update({'pos_moves_ids': result})
return res
@@ -91,18 +89,11 @@ class pos_return(osv.osv_memory):
order_obj =self.pool.get('pos.order')
line_obj = self.pool.get('pos.order.line')
pos_current = order_obj.browse(cr, uid, context.get('active_id'), context=context)
- pos_line_ids = pos_current.lines
- if pos_line_ids:
- for pos_line in pos_line_ids:
- newline_vals = {}
- for record in current_rec.pos_moves_ids:
- if pos_line.id == record.line_id:
- less_qty = record.quantity
- pos_cur_line = line_obj.browse(cr, uid, pos_line.id, context=context)
- qty = pos_cur_line.qty
- qty = qty - less_qty
- newline_vals.update({'qty':qty})
- line_obj.write(cr, uid, pos_line.id, newline_vals, context=context)
+ for pos_line in pos_current.lines:
+ for record in current_rec.pos_moves_ids:
+ if pos_line.id == record.line_id:
+ less_qty = record.quantity
+ line_obj.write(cr, uid, pos_line.id, {'qty':pos_line.qty - less_qty}, context=context)
return {
'name': _('Add Product'),
'view_type': 'form',
@@ -156,11 +147,8 @@ class pos_return(osv.osv_memory):
for line in order_id.lines:
for record in data.pos_moves_ids:
if line.id == record.line_id:
- try:
- qty = record.quantity
- amount += qty * line.price_unit
- except :
- qty = line.qty
+ qty = record.quantity
+ amount += qty * line.price_unit
stock_move_obj.create(cr, uid, {
'product_qty': qty ,
'product_uos_qty': uom_obj._compute_qty(cr, uid, qty ,line.product_id.uom_id.id),
From d6d6475163b57079342999f93aab0bfdbe3f0bb4 Mon Sep 17 00:00:00 2001
From: "aag (OpenERP)"
Date: Tue, 8 Mar 2011 19:17:25 +0530
Subject: [PATCH 08/11] [IMP] STOCK :RD Project- old style wizard
conversion-add one new Func get_return_history
bzr revid: aag@tinyerp.co.in-20110308134725-2o5n6olzqtfn09tx
---
addons/stock/wizard/stock_return_picking.py | 43 ++++++++++++++-------
1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/addons/stock/wizard/stock_return_picking.py b/addons/stock/wizard/stock_return_picking.py
index b7c62f57039..09ba9fb90e8 100644
--- a/addons/stock/wizard/stock_return_picking.py
+++ b/addons/stock/wizard/stock_return_picking.py
@@ -69,14 +69,15 @@ class stock_return_picking(osv.osv_memory):
res.update({'invoice_state': '2binvoiced'})
else:
res.update({'invoice_state': 'none'})
-
+ return_history = self.get_return_history(cr, uid, record_id, context)
for line in pick.move_lines:
- return_id = 'return%s'%(line.id)
- if return_id in fields:
- res[return_id] = line.product_qty
- result1.append({'product_id': line.product_id.id, 'quantity': line.product_qty,'move_id':line.id})
- if 'product_return_moves' in fields:
- res.update({'product_return_moves': result1})
+ qty = line.product_qty - return_history[line.id]
+ if return_history[line.id] == 0:
+ result1.append({'product_id': line.product_id.id, 'quantity': line.product_qty,'move_id':line.id})
+ if qty > 0 and return_history[line.id] != 0:
+ result1.append({'product_id': line.product_id.id, 'quantity': qty,'move_id':line.id})
+ if 'product_return_moves' in fields:
+ res.update({'product_return_moves': result1})
return res
def view_init(self, cr, uid, fields_list, context=None):
@@ -97,18 +98,34 @@ class stock_return_picking(osv.osv_memory):
pick = pick_obj.browse(cr, uid, record_id, context=context)
if pick.state not in ['done','confirmed','assigned']:
raise osv.except_osv(_('Warning !'), _("You may only return pickings that are Confirmed, Available or Done!"))
- return_history = {}
valid_lines = 0
+ return_history = self.get_return_history(cr, uid, record_id, context)
for m in pick.move_lines:
- if m.state == 'done':
- return_history[m.id] = 0
- for rec in m.move_history_ids2:
- return_history[m.id] += (rec.product_qty * rec.product_uom.factor)
- if m.product_qty * m.product_uom.factor > return_history[m.id]:
+ if m.product_qty * m.product_uom.factor > return_history[m.id]:
valid_lines += 1
if not valid_lines:
raise osv.except_osv(_('Warning !'), _("There are no products to return (only lines in Done state and not fully returned yet can be returned)!"))
return res
+
+ def get_return_history(self, cr, uid, ids, context=None):
+ """
+ Get return_history.
+ @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 of values.
+ """
+ pick_obj = self.pool.get('stock.picking')
+ pick = pick_obj.browse(cr, uid, ids, context=context)
+ return_history = {}
+ for m in pick.move_lines:
+ if m.state == 'done':
+ return_history[m.id] = 0
+ for rec in m.move_history_ids2:
+ return_history[m.id] += (rec.product_qty * rec.product_uom.factor)
+ return return_history
def create_returns(self, cr, uid, ids, context=None):
"""
From c70f68837789ce02c5f32c3dac0bececb38397bd Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 9 Mar 2011 14:08:39 +0530
Subject: [PATCH 09/11] [IMP]point_of_sale:correct string and code improve for
property field
bzr revid: ron@tinyerp.com-20110309083839-pqfbqs85e2q6316m
---
addons/point_of_sale/wizard/pos_return.py | 13 +++----------
addons/point_of_sale/wizard/pos_return_view.xml | 4 ++--
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
index c458044365f..e45e6984a9a 100644
--- a/addons/point_of_sale/wizard/pos_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -124,14 +124,12 @@ class pos_return(osv.osv_memory):
date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
- prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')])
- val = property_obj.browse(cr, uid, prop_ids[0], context=context).value_reference
+ stock_dest_id = property_obj.get(cr, uid, 'property_stock_customer', 'res.partner', context=context).id
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
"WHERE w.lot_stock_id=s.id AND w.id=%s ",
(order_id.shop_id.warehouse_id.id,))
res = cr.fetchone()
location_id = res and res[0] or None
- stock_dest_id = val.id
new_picking = picking_obj.copy(cr, uid, order_id.picking_id.id, {'name':'%s (return)' % order_id.name,
'move_lines': [],
'state':'draft',
@@ -221,15 +219,12 @@ class add_product(osv.osv_memory):
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
prod=data['product_id']
qty=data['quantity']
- prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
- val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
+ stock_dest_id = property_obj.get(cr, uid, 'property_stock_customer', 'res.partner', context=context).id
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
"WHERE w.lot_stock_id=s.id AND w.id=%s ",
(order_id.shop_id.warehouse_id.id,))
res=cr.fetchone()
location_id=res and res[0] or None
- stock_dest_id = val.id
-
prod_id=prod_obj.browse(cr, uid, prod, context=context)
new_picking=picking_obj.create(cr, uid, {
'name':'%s (Added)' %order_id.name,
@@ -288,14 +283,12 @@ class add_product(osv.osv_memory):
order_obj.add_product(cr, uid, active_ids[0], self_data['product_id'], self_data['quantity'], context=context)
for order_id in order_obj.browse(cr, uid, active_ids, context=context):
- prop_ids =property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
- val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
+ stock_dest_id = property_obj.get(cr, uid, 'property_stock_customer', 'res.partner', context=context).id
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
" WHERE w.lot_stock_id=s.id AND w.id=%s ",
(order_id.shop_id.warehouse_id.id,))
res=cr.fetchone()
location_id=res and res[0] or None
- stock_dest_id = val.id
order_obj.write(cr,uid,[order_id.id],{'type_rec':'Exchange'})
if order_id.invoice_id:
diff --git a/addons/point_of_sale/wizard/pos_return_view.xml b/addons/point_of_sale/wizard/pos_return_view.xml
index b5248e93654..7509b55b5d8 100644
--- a/addons/point_of_sale/wizard/pos_return_view.xml
+++ b/addons/point_of_sale/wizard/pos_return_view.xml
@@ -7,14 +7,14 @@
form
-
+
-
+
From 15af8f9504857567ef6cf8efff4f4618e7038801 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Tue, 15 Mar 2011 11:54:29 +0100
Subject: [PATCH 10/11] [REM] mrp: removed unused wizard mrp_track_prod.py
bzr revid: qdp-launchpad@openerp.com-20110315105429-gr1l180zktpncbw4
---
addons/mrp/wizard/mrp_track_prod.py | 129 ----------------------
addons/mrp/wizard/mrp_track_prod_view.xml | 16 ---
2 files changed, 145 deletions(-)
delete mode 100644 addons/mrp/wizard/mrp_track_prod.py
delete mode 100644 addons/mrp/wizard/mrp_track_prod_view.xml
diff --git a/addons/mrp/wizard/mrp_track_prod.py b/addons/mrp/wizard/mrp_track_prod.py
deleted file mode 100644
index 9a99cb68c04..00000000000
--- a/addons/mrp/wizard/mrp_track_prod.py
+++ /dev/null
@@ -1,129 +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 .
-#
-##############################################################################
-
-from osv import osv, fields
-
-class mrp_track_move(osv.osv_memory):
- _name = 'mrp.production.track'
- _description = 'Production Track'
-
- def view_init(self, cr, uid, fields_list, context=None):
- """ Creates view dynamically and adding fields at runtime.
- @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 with new columns.
- """
- res = super(mrp_track_move, self).view_init(cr, uid, fields_list, context=context)
- record_id = context and context.get('active_id', False) or False
- if record_id:
- prod_obj = self.pool.get('mrp.production')
- try:
- prod = prod_obj.browse(cr, uid, record_id, context=context)
- for m in [line for line in prod.move_created_ids]:
- if 'track%s'%(m.id) not in self._columns:
- self._columns['track%s'%(m.id)] = fields.boolean(string=m.product_id.name)
- except:
- return res
- return res
-
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- """ 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.
- """
- if context is None:
- context = {}
- res = super(mrp_track_move, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
- record_id = context and context.get('active_id', False) or False
- active_model = context.get('active_model')
-
- if not record_id or (active_model and active_model != 'mrp.production'):
- return res
-
- prod_obj = self.pool.get('mrp.production')
- prod = prod_obj.browse(cr, uid, record_id, context=context)
- if prod.state != 'done':
- res['arch'] = '''
-
-
-
-
-
- '''
- else:
- arch_lst = ['
', '']
- for m in [line for line in prod.move_created_ids]:
- quantity = m.product_qty
- res['fields']['track%s' %m.id] = {'string' : m.product_id.name, 'type' : 'boolean', 'default' : lambda x,y,z: False}
- arch_lst.append('\n' %m.id)
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('
')
- res['arch'] = '\n'.join(arch_lst)
-
- return res
-
- def track_lines(self, cr, uid, ids, context=None):
- """ Tracks Finished products and splits products to finish lines.
- @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:
- """
- if context is None:
- context = {}
- record_id = context and context.get('active_id', False) or False
- assert record_id, 'Active ID not found'
- data = self.read(cr, uid, ids[0])
- prod_obj = self.pool.get('mrp.production')
- prod = prod_obj.browse(cr, uid, record_id, context=context)
- if not prod.move_created_ids and prod.state != 'done':
- return {}
- prodlot_obj = self.pool.get('stock.production.lot')
- move_obj = self.pool.get('stock.move')
- move_ids = [m.id for m in [line for line in prod.move_created_ids]]
- for idx, move in enumerate(move_obj.browse(cr, uid, move_ids, context=context)):
- if data['track%s' %move.id]:
- for idx in range(int(move.product_qty)):
- update_val = {'product_qty': 1}
- if idx:
- current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
- else:
- current_move = move.id
- new_prodlot = prodlot_obj.create(cr, uid, {'name': 'PRODUCTION:%d:LOT:%d' % (record_id, idx+1), 'product_id': move.product_id.id})
- update_val['prodlot_id'] = new_prodlot
- move_obj.write(cr, uid, [current_move], update_val)
- return {'type': 'ir.actions.act_window_close'}
-
-mrp_track_move()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp/wizard/mrp_track_prod_view.xml b/addons/mrp/wizard/mrp_track_prod_view.xml
deleted file mode 100644
index fe2e54026a2..00000000000
--- a/addons/mrp/wizard/mrp_track_prod_view.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
From e4326479515d55f2502aca5d83b08f5cf2eb20c8 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Tue, 15 Mar 2011 11:54:52 +0100
Subject: [PATCH 11/11] [REM] stock: removed unused wizard stock_split_move.py
bzr revid: qdp-launchpad@openerp.com-20110315105452-c1yzeqta7v8vr2i5
---
addons/stock/wizard/stock_split_move.py | 124 ------------------
addons/stock/wizard/stock_split_move_view.xml | 17 ---
2 files changed, 141 deletions(-)
delete mode 100644 addons/stock/wizard/stock_split_move.py
delete mode 100644 addons/stock/wizard/stock_split_move_view.xml
diff --git a/addons/stock/wizard/stock_split_move.py b/addons/stock/wizard/stock_split_move.py
deleted file mode 100644
index aa7e4c17e15..00000000000
--- a/addons/stock/wizard/stock_split_move.py
+++ /dev/null
@@ -1,124 +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 .
-#
-##############################################################################
-
-from osv import osv, fields
-
-class stock_split_move_line(osv.osv_memory):
- _name = 'stock.move.line.split'
- _description = "Split Moves"
-
- def default_get(self, cr, uid, fields, context=None):
- """ 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.
- """
- if context is None:
- context = {}
- res = super(stock_split_move_line, self).default_get(cr, uid, fields, context=context)
- record_id = context and context.get('active_id', False) or False
- pick_obj = self.pool.get('stock.picking')
- pick = pick_obj.browse(cr, uid, record_id, context=context)
- for m in [line for line in pick.move_lines]:
- res['move%s'%(m.id)] = m.product_qty
- return res
-
- def view_init(self, cr, uid, fields_list, context=None):
- """ Creates view dynamically and adding fields at runtime.
- @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 with new columns.
- """
- res = super(stock_split_move_line, self).view_init(cr, uid, fields_list, context=context)
- record_id = context and context.get('active_id', False) or False
- if record_id:
- pick_obj = self.pool.get('stock.picking')
- try:
- pick = pick_obj.browse(cr, uid, record_id, context=context)
- for m in [line for line in pick.move_lines]:
- if 'move%s' % m.id not in self._columns:
- self._columns['move%s' % m.id] = fields.float(string=m.product_id.name)
- except:
- return res
- return res
-
- def fields_view_get(self, cr, uid, view_id=None, view_type='form',
- context=None, toolbar=False, submenu=False):
- """ 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.
- """
- res = super(stock_split_move_line, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
- record_id = context and context.get('active_id', False) or False
- assert record_id,'Active ID not found'
- pick_obj = self.pool.get('stock.picking')
- pick = pick_obj.browse(cr, uid, record_id, context=context)
- arch_lst = ['', '
', '']
- for m in [line for line in pick.move_lines]:
- quantity = m.product_qty
- arch_lst.append('\n' % (m.id,))
- res['fields']['move%s' % m.id] = {'string' : m.product_id.name, 'type' : 'float', 'required' : True}
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('')
- arch_lst.append('
')
- res['arch'] = '\n'.join(arch_lst)
- return res
-
- def split_lines(self, cr, uid, ids, context=None):
- """ Splits moves in quantity given in the wizard.
- @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 of fields with values.
- """
- if context is None:
- context = {}
- move_obj = self.pool.get('stock.move')
- record_id = context and context.get('active_id', False) or False
- pick_obj = self.pool.get('stock.picking')
- pick = pick_obj.browse(cr, uid, record_id, context=context)
- data = self.read(cr, uid, ids[0])
- for move in pick.move_lines:
- quantity = data['move%s' % move.id]
- if 0 < quantity < move.product_qty:
- new_qty = move.product_qty - quantity
- new_uos_qty = new_qty / move.product_qty * move.product_uos_qty
- new_obj = move_obj.copy(cr, uid, move.id, {'product_qty' : new_qty, 'product_uos_qty': new_uos_qty, 'state':move.state})
- uos_qty = quantity / move.product_qty * move.product_uos_qty
- move_obj.write(cr, uid, [move.id], {'product_qty' : quantity, 'product_uos_qty': uos_qty})
- return {'type': 'ir.actions.act_window_close'}
-
-stock_split_move_line()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/stock_split_move_view.xml b/addons/stock/wizard/stock_split_move_view.xml
deleted file mode 100644
index de89f83cb32..00000000000
--- a/addons/stock/wizard/stock_split_move_view.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
- Split Moves
- ir.actions.act_window
- stock.move.line.split
- form
- form
- new
-
-
-
-