[Fix] stock:remove the file name from terp
authormtr <mtr@mtr>
Fri, 26 Mar 2010 13:43:11 +0000 (19:13 +0530)
committermtr <mtr@mtr>
Fri, 26 Mar 2010 13:43:11 +0000 (19:13 +0530)
bzr revid: mtr@mtr-20100326134311-qbazgm07gjjbjwfx

19 files changed:
addons/mrp/mrp.py
addons/point_of_sale/__terp__.py
addons/point_of_sale/pos_wizard.xml
addons/point_of_sale/report/all_closed_cashbox_of_the_day.py
addons/point_of_sale/report/pos_receipt.rml
addons/point_of_sale/statement_report.xml
addons/point_of_sale/statement_view.xml
addons/point_of_sale/statement_wizard.xml
addons/point_of_sale/wizard/__init__.py
addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py [deleted file]
addons/point_of_sale/wizard/pos_receipt.py
addons/point_of_sale/wizard/pos_return.py [new file with mode: 0644]
addons/point_of_sale/wizard/wizard_return.py [deleted file]
addons/stock/__terp__.py
addons/stock/stock_wizard.xml
addons/stock/wizard/inventory_merge.py [deleted file]
addons/stock/wizard/stock_inventory_merge.py [new file with mode: 0644]
addons/stock/wizard/stock_picking_make.py [new file with mode: 0644]
addons/stock/wizard/wizard_picking_make.py [deleted file]

index b2817d0..6864b54 100644 (file)
@@ -134,6 +134,18 @@ class mrp_bom(osv.osv):
     _name = 'mrp.bom'
     _description = 'Bills of Material'
     def _child_compute(self, cr, uid, ids, name, arg, context={}):
+        """ 
+             @param self: The object pointer.
+             @param cr: A database cursor
+             @param uid: ID of the user currently logged in
+             @param ids: the ID of mrp.production object
+             @param name: 
+             @param arg: 
+
+             @return:  True
+        
+        """ 
+             
         result = {}
         for bom in self.browse(cr, uid, ids, context=context):
             result[bom.id] = map(lambda x: x.id, bom.bom_lines)
@@ -145,6 +157,9 @@ class mrp_bom(osv.osv):
                 if sids:
                     bom2 = self.pool.get('mrp.bom').browse(cr, uid, sids[0], context=context)
                     result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
+        print "name",name
+        print "arg",arg   
+        print "result",result            
         return result
     def _compute_type(self, cr, uid, ids, field_name, arg, context):
         res = dict(map(lambda x: (x,''), ids))
index 153584f..b1838a2 100644 (file)
@@ -41,7 +41,7 @@ Main features :
     'init_xml': [],
 
     'update_xml': [
-        'security/point_of_sale_security.xml',
+      'security/point_of_sale_security.xml',
         'security/ir.model.access.csv',
         'wizard/pos_details.xml',  
         'wizard/pos_add_product.xml',
@@ -72,7 +72,7 @@ Main features :
         'statement_view.xml',
         'statement_report.xml',
         'statement_data.xml',
-        'statement_wizard.xml',    
+        'statement_wizard.xml',   
     ],
     'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'],
     'installable': True,
index 50e3630..2e09b5c 100644 (file)
@@ -10,6 +10,7 @@
 
 
 
+
 <!--           <wizard string="Box Entries" model="account.bank.statement"
                                name="pos.entry" id="pos_entry" menu="False"/>-->
 
                string="Close Statements"/>-->
 
 
-       <wizard
+       <!--wizard
                id="wizard_all_closed_cashbox_of_the_day"
                model="account.bank.statement"
                menu="False"
                name="all.closed.cashbox.of.the.day"
-               string="All Cashboxes Of the day"/>
+               string="All Cashboxes Of the day"/-->
 
 
        </data>
index 2490d57..f3c21da 100644 (file)
@@ -138,4 +138,6 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
         res = self.cr.dictfetchall()
         return res[0]['net_total'] or 0.0
 
+
 report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day)
+
index 1d2e6ed..1d5e702 100644 (file)
         <para style="terp_default_Centre_9">E-mail : [[ address and address.email ]]</para>
         <para style="terp_default_Centre_9">Shop : [[ o.shop_id.name ]]</para>
         <para style="terp_default_Centre_9">Vendeur : [[ o.user_id1.name ]]</para>
+
         <para style="terp_default_Centre_9">Date : [[ formatLang(o.date_order,date = True) ]]</para>
+
         <para style="P4">
             <font color="white"> </font>
         </para>
index 8118d2e..7bdece3 100644 (file)
@@ -22,7 +22,7 @@
                        rml="point_of_sale/report/account_statement.rml"
                         />
 
-               <report
+               <!--report
                        id="all_closed_cashbox_of_the_day"
                        string="All Cloded CashBOx"
                        model="account.bank.statement"
                        auto="False"
                        multi="True"
                        menu = 'False'
+<<<<<<< TREE
+                       rml="point_of_sale/report/all_closed_cashbox_of_the_day.rml"
+                        /-->
+=======
                        rml="point_of_sale/report/all_closed_cashbox_of_the_day.rml"
                         />
+>>>>>>> MERGE-SOURCE
                <report
                        id="pos_users_product_re"
                        string="User's Product"
@@ -54,7 +59,7 @@
 
                <report
                        id="all_closed_cashbox_of_the_day"
-                       string="All Cloded CashBOx"
+                       string="All Closed CashBOx"
                        model="account.bank.statement"
                        name="all.closed.cashbox.of.the.day"
                        auto="False"
index 19e7bdc..7f241e5 100644 (file)
        <menuitem icon="STOCK_PRINT"
                                 action="action_report_all_closed_cashbox_of_the_day"
                                 id="menu_all_closed_cashbox_of_the_day"
-                                parent="menu_statement_tree_all"/>
+
+                                parent="menu_statement_tree_all"
+                               />
+
 
                <menuitem
             name="Close Register" parent="point_of_sale.menu_point_config"
index dd9715d..c4f4ddf 100644 (file)
 -->
 
 
-       
+
+     <!--  <wizard
+               id="action_report_all_closed_cashbox_of_the_day2"
+               model="account.bank.statement"
+               menu="False"
+               name="all.closed.cashbox.of.the.day"
+               string="All Cashboxes Of the day"/>-->
+
+
        <menuitem icon="STOCK_PRINT"
                                 action="action_report_all_closed_cashbox_of_the_day"
                                 id="menu_all_closed_cashbox_of_the_day"
-                                parent="menu_point_report_register"/>
+
+                                parent="menu_point_report_register"
+                               />
+
     </data>
 </openerp>
index 82d9ea9..1384fb8 100644 (file)
 #import wizard_pos_payment
 import wizard_default_journal
 import wizard_scan_product
-
 import wizard_return
-
-
-
-
-
 #import wizard_open_statement
-
 import pos_add_product
 import pos_confirm
 import pos_discount
diff --git a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py
deleted file mode 100644 (file)
index 0968c6c..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-import netsvc
-from osv import osv,fields
-from tools.translate import _
-from mx import DateTime
-import time
-
-class all_closed_cashbox_of_the_day(osv.osv_memory):
-    _name = 'all.closed.cashbox.of.the.day'
-    _description = 'All closed cashbox of the day'
-
-    _columns = {
-                
-    }
-    
-    def print_report(self, cr, uid, ids, context=None):
-
-        """ 
-             To get the date and print the report 
-                       
-             @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 report
-        """        
-        datas = {'ids' : context.get('active_ids',[])}
-        res =  {}        
-        datas['form'] = res
-        
-        return { 
-                'type' : 'ir.actions.report.xml',
-                'report_name':'all.closed.cashbox.of.the.day',
-                'datas' : datas,               
-       }
-
-all_closed_cashbox_of_the_day()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 27cdfd1..a812ad3 100644 (file)
@@ -22,6 +22,7 @@
 import netsvc
 from osv import osv,fields
 from tools.translate import _
+
 from mx import DateTime
 import time
 
@@ -62,3 +63,4 @@ pos_receipt()
 
 
 
+
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
new file mode 100644 (file)
index 0000000..1b5860c
--- /dev/null
@@ -0,0 +1,596 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+#    $Id$
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+#import wizard
+#import pooler
+#from tools.misc import UpdateableStr
+#
+#import netsvc
+#import time
+#
+#from tools.translate import _
+#from decimal import Decimal
+
+#arch=UpdateableStr()
+#fields={}
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
+
+
+class pos_return(osv.osv_memory):
+    _name = 'pos.return'
+    _description = 'Point of sale return'
+
+    _columns = {
+                
+    }
+pos_return()
+
+class pos_add_payment(osv.osv_memory):
+    _name = 'pos.add.payment'
+    _description = 'Add Payment'
+
+    _columns = {
+        'amount': fields.float('Amount', digits=(16,2),required=True),
+        'journal': fields.function(_get_journal, 'Journal', method=True, required=True),
+        'payment_date': fields.date('Payment date',required=True),
+        'payment_name': fields.char('Payment name', size=32,required=True),
+        'invoice_wanted': fields.boolean('Invoice'),
+        'num_sale': fields.char('Num.Cof', size=32)        
+    }
+    _defaults = {
+          'payment_name': lambda *a: 'Payment'
+        }
+
+pos_add_payment()
+
+class pos_add_product(osv.osv_memory):
+    _name = 'pos.add.product'
+    _description = 'Add Product'
+
+    _columns = {
+        'product': fields.many2one('product.product','Product', required=True),
+        'quantity': fields.integer( 'Quantity',required=True),
+             
+    }
+
+    _defaults = {
+          'product': lambda *a: 'False',
+          'quantity': lambda *a: 1
+        }
+
+pos_add_product()
+
+
+def _get_journal(self, cr, uid, context):
+    pool = pooler.get_pool(cr.dbname)
+    obj = pool.get('account.journal')
+    c=pool.get('res.users').browse(cr,uid,uid).company_id.id
+    ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id','=',c)])
+    res = obj.read(cr, uid, ids, ['id', 'name'], context)
+    res = [(r['id'], r['name']) for r in res]
+    return res
+
+
+payment_form = """<?xml version="1.0"?>
+<form string="Add payment :">
+    <field name="amount" />
+    <field name="journal"/>
+    <field name="payment_date" />
+    <field name="payment_name" />
+    <field name="invoice_wanted" />
+    <field name="num_sale" />
+</form>
+"""
+
+payment_fields = {
+    'amount': {'string': 'Amount', 'type': 'float', 'required': True},
+    'invoice_wanted': {'string': 'Invoice', 'type': 'boolean'},
+    'journal': {'string': 'Journal',
+            'type': 'selection',
+            'selection': _get_journal,
+            'required': True,
+        },
+    'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True},
+    'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32', 'required':True, 'default':'Payment'},
+    'num_sale': {'string': 'Num.Cof', 'type': 'char', 'size': '32'},
+    }
+
+
+def _pre_init(self, cr, uid, data, context):
+    def _get_journal(pool, order):
+        j_obj = pool.get('account.journal')
+
+        journal_to_fetch = 'DEFAULT'
+        if order.amount_total < 0:
+            journal_to_fetch = 'GIFT'
+        else:
+            if order.amount_paid > 0:
+                journal_to_fetch = 'REBATE'
+
+        pos_config_journal = pool.get('pos.config.journal')
+        ids = pos_config_journal.search(cr, uid, [('code', '=', journal_to_fetch)])
+        objs = pos_config_journal.browse(cr, uid, ids)
+        journal=''
+        if objs:
+            journal = objs[0].journal_id.id
+        else:
+            existing = [payment.journal_id.id for payment in order.payments]
+            ids = j_obj.search(cr, uid, [('type', '=', 'cash')])
+            for i in ids:
+                if i not in existing:
+                    journal = i
+                    break
+            if not journal:
+                journal = ids and ids[0]
+        return journal
+    pool = pooler.get_pool(cr.dbname)
+    order = pool.get('pos.order').browse(cr, uid, data['id'], context)
+    # get amount to pay:
+#    amount = Decimal(str(order.amount_total)) - Decimal(str(order.amount_paid))
+    amount = order.amount_total - order.amount_paid
+    if amount <= 0:
+        pool.get('pos.order').action_paid(cr, uid, data['ids'], context)
+
+    # get journal:
+    journal = _get_journal(pool, order)
+
+    # check if an invoice is wanted:
+    #invoice_wanted_checked = not not order.partner_id # not not -> boolean
+    invoice_wanted_checked = False
+
+    # select the current date
+    current_date = time.strftime('%Y-%m-%d')
+
+    return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date}
+
+
+def _add_pay(self, cr, uid, data, context):
+    pool = pooler.get_pool(cr.dbname)
+    order_obj = pool.get('pos.order')
+    jrnl_obj = pool.get('account.journal')
+    result = data['form']
+    invoice_wanted = data['form']['invoice_wanted']
+    jrnl_used=False
+    if data['form'] and data['form'].get('journal',False):
+        jrnl_used=jrnl_obj.browse(cr,uid,data['form']['journal'])
+
+    # add 'invoice_wanted' in 'pos.order'
+    order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted})
+
+    order_obj.add_payment(cr, uid, data['id'], result, context=context)
+    return {}
+
+
+def _check(self, cr, uid, data, context):
+    """Check the order:
+    if the order is not paid: continue payment,
+    if the order is paid print invoice (if wanted) or ticket.
+    """
+    pool = pooler.get_pool(cr.dbname)
+    order_obj = pool.get('pos.order')
+    order = order_obj.browse(cr, uid, data['id'], context)
+    order_obj.test_order_lines(cr, uid, order, context=context)
+
+    action = 'ask_pay'
+    if order.state == 'paid':
+        if order.partner_id:
+            if order.invoice_wanted:
+                action = 'invoice'
+            else:
+                action = 'paid'
+        elif order.date_payment:
+            action = 'receipt'
+        else:
+            action='paid'
+
+    if order.amount_total == order.amount_paid:
+        order_obj.write(cr,uid,data['ids'],{'state':'done'})
+        action = 'receipt'
+
+    return action
+
+
+def create_invoice(self, cr, uid, data, context):
+    wf_service = netsvc.LocalService("workflow")
+    for i in data['ids']:
+        wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr)
+    return {}
+
+
+
+_form = """<?xml version="1.0"?>
+<form string="Add product :">
+<field name="product"/>
+<field name="quantity"/>
+</form>
+"""
+_fields = {
+    'product': {
+        'string': 'Product',
+        'type': 'many2one',
+        'relation': 'product.product',
+        'required': True,
+        'default': False
+    },
+
+    'quantity': {
+        'string': 'Quantity',
+        'type': 'integer',
+        'required': True,
+        'default': 1},
+    }
+
+def make_default(val):
+    def fct(obj, cr, uid):
+        return val
+    return fct
+
+def _get_returns(self, cr, uid, data, context):
+
+    pool = pooler.get_pool(cr.dbname)
+    order_obj=pool.get('pos.order')
+    order=order_obj.browse(cr, uid, [data['id']])[0]
+    res={}
+    fields.clear()
+    arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Quantities you enter, match to products that will return to the stock.')]
+    for m in [line for line in order.lines]:
+        quantity=m.qty
+        arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
+        fields['return%s' % m.id]={'string':m.product_id.name, 'type':'float', 'required':True, 'default':quantity}
+        res.setdefault('returns', []).append(m.id)
+    arch_lst.append('</form>')
+    arch.string='\n'.join(arch_lst)
+    return res
+
+def _create_returns(self, cr, uid, data, context):
+    pool = pooler.get_pool(cr.dbname)
+    order_obj = pool.get('pos.order')
+    lines_obj = pool.get('pos.order.line')
+    picking_obj = pool.get('stock.picking')
+    stock_move_obj = pool.get('stock.move')
+    move_obj = pool.get('stock.move')
+    picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')])
+    clone_list = []
+    date_cur=time.strftime('%Y-%m-%d')
+    uom_obj = pool.get('product.uom')
+    wf_service = netsvc.LocalService("workflow")
+    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
+        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
+        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
+        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+        res=cr.fetchone()
+        location_id=res and res[0] or None
+        stock_dest_id = int(val.split(',')[1])
+
+        order_obj.write(cr,uid,[order_id.id],{'type_rec':'Exchange'})
+        if order_id.invoice_id:
+            pool.get('account.invoice').refund(cr, uid, [order_id.invoice_id.id],time.strftime('%Y-%m-%d'), False, order_id.name)
+        new_picking=picking_obj.create(cr,uid,{
+                                'name':'%s (return)' %order_id.name,
+                                'move_lines':[], 'state':'draft',
+                                'type':'in',
+                                'date':date_cur,   })
+        for line in order_id.lines:
+            for r in data['form'].get('returns',[]):
+                if line.id==r and (data['form']['return%s' %r]!=0.0):
+                    new_move=stock_move_obj.create(cr, uid,{
+                        'product_qty': data['form']['return%s' %r],
+                        'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id),
+                        'picking_id':new_picking,
+                        'product_uom':line.product_id.uom_id.id,
+                        'location_id':location_id,
+                        'product_id':line.product_id.id,
+                        'location_dest_id':stock_dest_id,
+                        'name':'%s (return)' %order_id.name,
+                        'date':date_cur,
+                        'date_planned':date_cur,})
+                    lines_obj.write(cr,uid,[line.id],{'qty_rfd':(line.qty or 0.0) + data['form']['return%s' %r],
+                                                    'qty':line.qty-(data['form']['return%s' %r] or 0.0)
+                    })
+        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
+        picking_obj.force_assign(cr, uid, [new_picking], context)
+    return res
+
+def _create_returns2(self, cr, uid, data, context):
+    pool = pooler.get_pool(cr.dbname)
+    order_obj = pool.get('pos.order')
+    line_obj = pool.get('pos.order.line')
+    picking_obj = pool.get('stock.picking')
+    stock_move_obj = pool.get('stock.move')
+    picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')])
+    clone_list = []
+    date_cur=time.strftime('%Y-%m-%d')
+    uom_obj = pool.get('product.uom')
+    wf_service = netsvc.LocalService("workflow")
+    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
+        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
+        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
+        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+        res=cr.fetchone()
+        location_id=res and res[0] or None
+        stock_dest_id = int(val.split(',')[1])
+
+        new_picking=picking_obj.copy(cr, uid, order_id.last_out_picking.id, {'name':'%s (return)' % order_id.name,
+                                                                            'move_lines':[], 'state':'draft', 'type':'in',
+                                                                            'type':'in',
+                                                                            'date':date_cur,   })
+        new_order=order_obj.copy(cr,uid,order_id.id, {'name': 'Refund %s'%order_id.name,
+                                                      'lines':[],
+                                                      'statement_ids':[],
+                                                      'last_out_picking':[]})
+        for line in order_id.lines:
+            for r in data['form'].get('returns',[]):
+                if line.id==r and (data['form']['return%s' %r]!=0.0):
+                    new_move=stock_move_obj.create(cr, uid,{
+                        'product_qty': data['form']['return%s' %r],
+                        'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id),
+                        'picking_id':new_picking,
+                        'product_uom':line.product_id.uom_id.id,
+                        'location_id':location_id,
+                        'product_id':line.product_id.id,
+                        'location_dest_id':stock_dest_id,
+                        'name':'%s (return)' %order_id.name,
+                        'date':date_cur,
+                        'date_planned':date_cur,})
+                    line_obj.copy(cr,uid,line.id,{'qty':-data['form']['return%s' %r],
+                                                'order_id': new_order,
+                    })
+        order_obj.write(cr,uid, new_order, {'state':'done'})
+        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
+        picking_obj.force_assign(cr, uid, [new_picking], context)
+    act = {
+        'domain': "[('id', 'in', ["+str(new_order)+"])]",
+        'name': 'Refunded Orders',
+        'view_type': 'form',
+        'view_mode': 'form,tree',
+        'res_model': 'pos.order',
+        'auto_refresh':0,
+        'res_id':new_order,
+        'view_id': False,
+        'type': 'ir.actions.act_window'
+    }
+    return act
+def test(self,cr,uid,data,context={}):
+  #  import pdb; pdb.set_trace()
+    data['id']=data['res_id']
+    return {'id':data['res_id']}
+
+#def _raise(self,cr,uid,data,context={}):
+#    return datas
+#    raise wizard.except_wizard(_('Message'),_('You can not exchange products more than total paid amount.'))
+
+
+#def _test_exist1(self,cr,uid,data,context={}):
+#    return 'choice'
+
+def _test_exist(self,cr,uid,data,context={}):
+#    order_obj= pooler.get_pool(cr.dbname).get('pos.order')
+#    order_line_obj= pooler.get_pool(cr.dbname).get('pos.order.line')
+#    obj=order_obj.browse(cr,uid, data['ids'])[0]
+#    am_tot=obj._amount_total(cr, uid, data['ids'])
+#    order_obj.write(cr,uid,data['ids'],{'state':'done'})
+#    if obj.amount_total == obj.amount_paid:
+#        return 'receipt'
+#    elif obj.amount_total > obj.amount_paid:
+#        sql = """select max(id) from pos_order_line where order_id = %d """%(obj.id)
+#        cr.execute(sql)
+#        res = cr.fetchone()
+#        cr.execute("delete from pos_order_line where id = %d"%(res[0]))
+#        cr.commit()
+#        return 'choice_raise'
+#    else:
+    return 'add_p'
+
+def _close(self,cr,uid,data,context={}):
+    order_obj= pooler.get_pool(cr.dbname).get('pos.order')
+    order_line_obj= pooler.get_pool(cr.dbname).get('pos.order.line')
+    obj=order_obj.browse(cr,uid, data['ids'])[0]
+    order_obj.write(cr,uid,data['ids'],{'state':'done'})
+    if obj.amount_total != obj.amount_paid:
+        return 'ask_pay'
+    else :
+        return 'receipt'
+
+
+
+
+def _add_pdct(self, cr, uid, data, context):
+    pool = pooler.get_pool(cr.dbname)
+    order_obj = pool.get('pos.order')
+    line_obj = pool.get('pos.order.line')
+    picking_obj = pool.get('stock.picking')
+    wf_service = netsvc.LocalService("workflow")
+    prod_obj = pool.get('product.product')
+    stock_move_obj = pool.get('stock.move')
+    uom_obj = pool.get('product.uom')
+    date_cur=time.strftime('%Y-%m-%d')
+    order_obj.add_product(cr, uid, data['id'], data['form']['product'],
+                            data['form']['quantity'], context=context)
+    cr.commit()
+    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
+        prod=data['form']['product']
+        qty=data['form']['quantity']
+        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
+        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
+        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+        res=cr.fetchone()
+        location_id=res and res[0] or None
+        stock_dest_id = int(val.split(',')[1])
+
+        prod_id=prod_obj.browse(cr,uid,prod)
+        new_picking=picking_obj.create(cr,uid,{
+                                'name':'%s (Added)' %order_id.name,
+                                'move_lines':[],
+                                'state':'draft',
+                                'type':'out',
+                                'date':date_cur,   })
+        new_move=stock_move_obj.create(cr, uid,{
+                        'product_qty': qty,
+                        'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id),
+                        'picking_id':new_picking,
+                        'product_uom':prod_id.uom_id.id,
+                        'location_id':location_id,
+                        'product_id':prod_id.id,
+                        'location_dest_id':stock_dest_id,
+                        'name':'%s (return)' %order_id.name,
+                        'date':date_cur,
+                        'date_planned':date_cur,})
+
+        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
+        picking_obj.force_assign(cr, uid, [new_picking], context)
+       # order_obj.write(cr,uid,data['id'],{'state':'done','last_out_picking':new_picking})
+        order_obj.write(cr,uid,data['id'],{'last_out_picking':new_picking})
+    return {}
+
+
+
+
+class wizard_return_picking(wizard.interface):
+    states={
+        'init':{
+            'actions':[_get_returns],
+            'result':{'type':'form',
+                    'arch':arch,
+                    'fields':fields,
+                    'state':[('end','Cancel', 'gtk-cancel'),('return','Return goods and Exchange', 'gtk-ok'),('return_w','Return without Refund','gtk-ok')]
+                    }
+        },
+        'return':{
+            'actions':[],
+            'result':{ 'type': 'action',
+                       'action' : _create_returns,
+                       'state':'prod'}
+        },
+        'prod':{
+            'actions':[],
+            'result': {
+                'type': 'form',
+                'arch': _form,
+                'fields':_fields,
+                'state': [('close','Close'),('choice','Continue')]
+            }
+        },
+#        'choice1' : {
+#            'actions' : [_add_pdct],
+#            'result' : {'type' : 'choice', 'next_state': _test_exist1 }
+#        },
+        'choice' : {
+            'actions' : [],
+            'result' : {'type' : 'choice', 'next_state': _test_exist }
+        },
+#        'choice_raise':{
+#                        'actions':[],
+#            'result':{ 'type': 'action',
+#                       'action' : _raise,
+#                       'state':'end'}
+#        },
+        'add_p' :{
+            'actions':[],
+            'result':{
+            'type':'action',
+            'action': _add_pdct,
+            'state': 'prod'}
+        },
+#        'add_pp' :{
+#            'actions':[],
+#            'result':{
+#            'type':'action',
+#            'action': _add_pdct,
+#            'state': 'end'}
+#        },
+        'receipt':{
+            'result': {
+                'type': 'print',
+                'report': 'pos.receipt',
+                'state': 'end'
+            }
+        },
+        'return_w':{
+            'actions':[],
+            'result':{'type':'action', 'action':_create_returns2, 'state':'end'}
+        },
+
+        'close':{
+            'actions' : [],
+            'result' : {'type' : 'choice', 'next_state': _close }
+        },
+
+       'check': {
+            'actions': [],
+            'result': {
+                'type': 'choice',
+                'next_state': _check,
+            }
+        },
+
+        'ask_pay': {
+            'actions': [_pre_init],
+            'result': {
+                'type': 'form',
+                'arch': payment_form,
+                'fields': payment_fields,
+                'state': (('end', 'Cancel'), ('add_pay', 'Ma_ke payment', 'gtk-ok', True)
+                         )
+            }
+        },
+        'add_pay': {
+            'actions': [_add_pay],
+            'result': {
+                'type': 'state',
+                'state': "check",
+            }
+        },
+
+
+        'invoice': {
+            'actions': [create_invoice],
+            'result': {
+                'type': 'print',
+                'report': 'pos.invoice',
+                'state': 'end'
+            }
+        },
+        'receipt': {
+            'actions': [],
+            'result': {
+                'type': 'print',
+                'report': 'pos.receipt',
+                'state': 'end'
+            }
+        },
+        'paid': {
+            'actions': [],
+            'result': {
+                'type': 'state',
+                'state': 'end'
+            }
+        },
+
+    }
+wizard_return_picking('pos.return.picking')
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/wizard_return.py b/addons/point_of_sale/wizard/wizard_return.py
deleted file mode 100644 (file)
index 591fd00..0000000
+++ /dev/null
@@ -1,546 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-import wizard
-import pooler
-from tools.misc import UpdateableStr
-
-import netsvc
-import time
-
-from tools.translate import _
-from decimal import Decimal
-
-
-arch=UpdateableStr()
-fields={}
-
-
-def _get_journal(self, cr, uid, context):
-    pool = pooler.get_pool(cr.dbname)
-    obj = pool.get('account.journal')
-    c=pool.get('res.users').browse(cr,uid,uid).company_id.id
-    ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id','=',c)])
-    res = obj.read(cr, uid, ids, ['id', 'name'], context)
-    res = [(r['id'], r['name']) for r in res]
-    return res
-
-
-payment_form = """<?xml version="1.0"?>
-<form string="Add payment :">
-    <field name="amount" />
-    <field name="journal"/>
-    <field name="payment_date" />
-    <field name="payment_name" />
-    <field name="invoice_wanted" />
-    <field name="num_sale" />
-</form>
-"""
-
-payment_fields = {
-    'amount': {'string': 'Amount', 'type': 'float', 'required': True},
-    'invoice_wanted': {'string': 'Invoice', 'type': 'boolean'},
-    'journal': {'string': 'Journal',
-            'type': 'selection',
-            'selection': _get_journal,
-            'required': True,
-        },
-    'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True},
-    'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32', 'required':True, 'default':'Payment'},
-    'num_sale': {'string': 'Num.Cof', 'type': 'char', 'size': '32'},
-    }
-
-
-def _pre_init(self, cr, uid, data, context):
-    def _get_journal(pool, order):
-        j_obj = pool.get('account.journal')
-
-        journal_to_fetch = 'DEFAULT'
-        if order.amount_total < 0:
-            journal_to_fetch = 'GIFT'
-        else:
-            if order.amount_paid > 0:
-                journal_to_fetch = 'REBATE'
-
-        pos_config_journal = pool.get('pos.config.journal')
-        ids = pos_config_journal.search(cr, uid, [('code', '=', journal_to_fetch)])
-        objs = pos_config_journal.browse(cr, uid, ids)
-        journal=''
-        if objs:
-            journal = objs[0].journal_id.id
-        else:
-            existing = [payment.journal_id.id for payment in order.payments]
-            ids = j_obj.search(cr, uid, [('type', '=', 'cash')])
-            for i in ids:
-                if i not in existing:
-                    journal = i
-                    break
-            if not journal:
-                journal = ids and ids[0]
-        return journal
-    pool = pooler.get_pool(cr.dbname)
-    order = pool.get('pos.order').browse(cr, uid, data['id'], context)
-    # get amount to pay:
-#    amount = Decimal(str(order.amount_total)) - Decimal(str(order.amount_paid))
-    amount = order.amount_total - order.amount_paid
-    if amount <= 0:
-        pool.get('pos.order').action_paid(cr, uid, data['ids'], context)
-
-    # get journal:
-    journal = _get_journal(pool, order)
-
-    # check if an invoice is wanted:
-    #invoice_wanted_checked = not not order.partner_id # not not -> boolean
-    invoice_wanted_checked = False
-
-    # select the current date
-    current_date = time.strftime('%Y-%m-%d')
-
-    return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date}
-
-
-def _add_pay(self, cr, uid, data, context):
-    pool = pooler.get_pool(cr.dbname)
-    order_obj = pool.get('pos.order')
-    jrnl_obj = pool.get('account.journal')
-    result = data['form']
-    invoice_wanted = data['form']['invoice_wanted']
-    jrnl_used=False
-    if data['form'] and data['form'].get('journal',False):
-        jrnl_used=jrnl_obj.browse(cr,uid,data['form']['journal'])
-
-    # add 'invoice_wanted' in 'pos.order'
-    order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted})
-
-    order_obj.add_payment(cr, uid, data['id'], result, context=context)
-    return {}
-
-
-def _check(self, cr, uid, data, context):
-    """Check the order:
-    if the order is not paid: continue payment,
-    if the order is paid print invoice (if wanted) or ticket.
-    """
-    pool = pooler.get_pool(cr.dbname)
-    order_obj = pool.get('pos.order')
-    order = order_obj.browse(cr, uid, data['id'], context)
-    order_obj.test_order_lines(cr, uid, order, context=context)
-
-    action = 'ask_pay'
-    if order.state == 'paid':
-        if order.partner_id:
-            if order.invoice_wanted:
-                action = 'invoice'
-            else:
-                action = 'paid'
-        elif order.date_payment:
-            action = 'receipt'
-        else:
-            action='paid'
-
-    if order.amount_total == order.amount_paid:
-        order_obj.write(cr,uid,data['ids'],{'state':'done'})
-        action = 'receipt'
-
-    return action
-
-
-def create_invoice(self, cr, uid, data, context):
-    wf_service = netsvc.LocalService("workflow")
-    for i in data['ids']:
-        wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr)
-    return {}
-
-
-
-_form = """<?xml version="1.0"?>
-<form string="Add product :">
-<field name="product"/>
-<field name="quantity"/>
-</form>
-"""
-_fields = {
-    'product': {
-        'string': 'Product',
-        'type': 'many2one',
-        'relation': 'product.product',
-        'required': True,
-        'default': False
-    },
-
-    'quantity': {
-        'string': 'Quantity',
-        'type': 'integer',
-        'required': True,
-        'default': 1},
-    }
-
-def make_default(val):
-    def fct(obj, cr, uid):
-        return val
-    return fct
-
-def _get_returns(self, cr, uid, data, context):
-
-    pool = pooler.get_pool(cr.dbname)
-    order_obj=pool.get('pos.order')
-    order=order_obj.browse(cr, uid, [data['id']])[0]
-    res={}
-    fields.clear()
-    arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Quantities you enter, match to products that will return to the stock.')]
-    for m in [line for line in order.lines]:
-        quantity=m.qty
-        arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
-        fields['return%s' % m.id]={'string':m.product_id.name, 'type':'float', 'required':True, 'default':quantity}
-        res.setdefault('returns', []).append(m.id)
-    arch_lst.append('</form>')
-    arch.string='\n'.join(arch_lst)
-    return res
-
-def _create_returns(self, cr, uid, data, context):
-    pool = pooler.get_pool(cr.dbname)
-    order_obj = pool.get('pos.order')
-    lines_obj = pool.get('pos.order.line')
-    picking_obj = pool.get('stock.picking')
-    stock_move_obj = pool.get('stock.move')
-    move_obj = pool.get('stock.move')
-    picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')])
-    clone_list = []
-    date_cur=time.strftime('%Y-%m-%d')
-    uom_obj = pool.get('product.uom')
-    wf_service = netsvc.LocalService("workflow")
-    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
-        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
-        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
-        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
-        res=cr.fetchone()
-        location_id=res and res[0] or None
-        stock_dest_id = int(val.split(',')[1])
-
-        order_obj.write(cr,uid,[order_id.id],{'type_rec':'Exchange'})
-        if order_id.invoice_id:
-            pool.get('account.invoice').refund(cr, uid, [order_id.invoice_id.id],time.strftime('%Y-%m-%d'), False, order_id.name)
-        new_picking=picking_obj.create(cr,uid,{
-                                'name':'%s (return)' %order_id.name,
-                                'move_lines':[], 'state':'draft',
-                                'type':'in',
-                                'date':date_cur,   })
-        for line in order_id.lines:
-            for r in data['form'].get('returns',[]):
-                if line.id==r and (data['form']['return%s' %r]!=0.0):
-                    new_move=stock_move_obj.create(cr, uid,{
-                        'product_qty': data['form']['return%s' %r],
-                        'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id),
-                        'picking_id':new_picking,
-                        'product_uom':line.product_id.uom_id.id,
-                        'location_id':location_id,
-                        'product_id':line.product_id.id,
-                        'location_dest_id':stock_dest_id,
-                        'name':'%s (return)' %order_id.name,
-                        'date':date_cur,
-                        'date_planned':date_cur,})
-                    lines_obj.write(cr,uid,[line.id],{'qty_rfd':(line.qty or 0.0) + data['form']['return%s' %r],
-                                                    'qty':line.qty-(data['form']['return%s' %r] or 0.0)
-                    })
-        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
-        picking_obj.force_assign(cr, uid, [new_picking], context)
-    return res
-
-def _create_returns2(self, cr, uid, data, context):
-    pool = pooler.get_pool(cr.dbname)
-    order_obj = pool.get('pos.order')
-    line_obj = pool.get('pos.order.line')
-    picking_obj = pool.get('stock.picking')
-    stock_move_obj = pool.get('stock.move')
-    picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')])
-    clone_list = []
-    date_cur=time.strftime('%Y-%m-%d')
-    uom_obj = pool.get('product.uom')
-    wf_service = netsvc.LocalService("workflow")
-    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
-        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
-        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
-        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
-        res=cr.fetchone()
-        location_id=res and res[0] or None
-        stock_dest_id = int(val.split(',')[1])
-
-        new_picking=picking_obj.copy(cr, uid, order_id.last_out_picking.id, {'name':'%s (return)' % order_id.name,
-                                                                            'move_lines':[], 'state':'draft', 'type':'in',
-                                                                            'type':'in',
-                                                                            'date':date_cur,   })
-        new_order=order_obj.copy(cr,uid,order_id.id, {'name': 'Refund %s'%order_id.name,
-                                                      'lines':[],
-                                                      'statement_ids':[],
-                                                      'last_out_picking':[]})
-        for line in order_id.lines:
-            for r in data['form'].get('returns',[]):
-                if line.id==r and (data['form']['return%s' %r]!=0.0):
-                    new_move=stock_move_obj.create(cr, uid,{
-                        'product_qty': data['form']['return%s' %r],
-                        'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id),
-                        'picking_id':new_picking,
-                        'product_uom':line.product_id.uom_id.id,
-                        'location_id':location_id,
-                        'product_id':line.product_id.id,
-                        'location_dest_id':stock_dest_id,
-                        'name':'%s (return)' %order_id.name,
-                        'date':date_cur,
-                        'date_planned':date_cur,})
-                    line_obj.copy(cr,uid,line.id,{'qty':-data['form']['return%s' %r],
-                                                'order_id': new_order,
-                    })
-        order_obj.write(cr,uid, new_order, {'state':'done'})
-        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
-        picking_obj.force_assign(cr, uid, [new_picking], context)
-    act = {
-        'domain': "[('id', 'in', ["+str(new_order)+"])]",
-        'name': 'Refunded Orders',
-        'view_type': 'form',
-        'view_mode': 'form,tree',
-        'res_model': 'pos.order',
-        'auto_refresh':0,
-        'res_id':new_order,
-        'view_id': False,
-        'type': 'ir.actions.act_window'
-    }
-    return act
-def test(self,cr,uid,data,context={}):
-  #  import pdb; pdb.set_trace()
-    data['id']=data['res_id']
-    return {'id':data['res_id']}
-
-#def _raise(self,cr,uid,data,context={}):
-#    return datas
-#    raise wizard.except_wizard(_('Message'),_('You can not exchange products more than total paid amount.'))
-
-
-#def _test_exist1(self,cr,uid,data,context={}):
-#    return 'choice'
-
-def _test_exist(self,cr,uid,data,context={}):
-#    order_obj= pooler.get_pool(cr.dbname).get('pos.order')
-#    order_line_obj= pooler.get_pool(cr.dbname).get('pos.order.line')
-#    obj=order_obj.browse(cr,uid, data['ids'])[0]
-#    am_tot=obj._amount_total(cr, uid, data['ids'])
-#    order_obj.write(cr,uid,data['ids'],{'state':'done'})
-#    if obj.amount_total == obj.amount_paid:
-#        return 'receipt'
-#    elif obj.amount_total > obj.amount_paid:
-#        sql = """select max(id) from pos_order_line where order_id = %d """%(obj.id)
-#        cr.execute(sql)
-#        res = cr.fetchone()
-#        cr.execute("delete from pos_order_line where id = %d"%(res[0]))
-#        cr.commit()
-#        return 'choice_raise'
-#    else:
-    return 'add_p'
-
-def _close(self,cr,uid,data,context={}):
-    order_obj= pooler.get_pool(cr.dbname).get('pos.order')
-    order_line_obj= pooler.get_pool(cr.dbname).get('pos.order.line')
-    obj=order_obj.browse(cr,uid, data['ids'])[0]
-    order_obj.write(cr,uid,data['ids'],{'state':'done'})
-    if obj.amount_total != obj.amount_paid:
-        return 'ask_pay'
-    else :
-        return 'receipt'
-
-
-
-
-def _add_pdct(self, cr, uid, data, context):
-    pool = pooler.get_pool(cr.dbname)
-    order_obj = pool.get('pos.order')
-    line_obj = pool.get('pos.order.line')
-    picking_obj = pool.get('stock.picking')
-    wf_service = netsvc.LocalService("workflow")
-    prod_obj = pool.get('product.product')
-    stock_move_obj = pool.get('stock.move')
-    uom_obj = pool.get('product.uom')
-    date_cur=time.strftime('%Y-%m-%d')
-    order_obj.add_product(cr, uid, data['id'], data['form']['product'],
-                            data['form']['quantity'], context=context)
-    cr.commit()
-    for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
-        prod=data['form']['product']
-        qty=data['form']['quantity']
-        prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')])
-        val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value
-        cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
-        res=cr.fetchone()
-        location_id=res and res[0] or None
-        stock_dest_id = int(val.split(',')[1])
-
-        prod_id=prod_obj.browse(cr,uid,prod)
-        new_picking=picking_obj.create(cr,uid,{
-                                'name':'%s (Added)' %order_id.name,
-                                'move_lines':[],
-                                'state':'draft',
-                                'type':'out',
-                                'date':date_cur,   })
-        new_move=stock_move_obj.create(cr, uid,{
-                        'product_qty': qty,
-                        'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id),
-                        'picking_id':new_picking,
-                        'product_uom':prod_id.uom_id.id,
-                        'location_id':location_id,
-                        'product_id':prod_id.id,
-                        'location_dest_id':stock_dest_id,
-                        'name':'%s (return)' %order_id.name,
-                        'date':date_cur,
-                        'date_planned':date_cur,})
-
-        wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
-        picking_obj.force_assign(cr, uid, [new_picking], context)
-       # order_obj.write(cr,uid,data['id'],{'state':'done','last_out_picking':new_picking})
-        order_obj.write(cr,uid,data['id'],{'last_out_picking':new_picking})
-    return {}
-
-
-
-
-class wizard_return_picking(wizard.interface):
-    states={
-        'init':{
-            'actions':[_get_returns],
-            'result':{'type':'form',
-                    'arch':arch,
-                    'fields':fields,
-                    'state':[('end','Cancel', 'gtk-cancel'),('return','Return goods and Exchange', 'gtk-ok'),('return_w','Return without Refund','gtk-ok')]
-                    }
-        },
-        'return':{
-            'actions':[],
-            'result':{ 'type': 'action',
-                       'action' : _create_returns,
-                       'state':'prod'}
-        },
-        'prod':{
-            'actions':[],
-            'result': {
-                'type': 'form',
-                'arch': _form,
-                'fields':_fields,
-                'state': [('close','Close'),('choice','Continue')]
-            }
-        },
-#        'choice1' : {
-#            'actions' : [_add_pdct],
-#            'result' : {'type' : 'choice', 'next_state': _test_exist1 }
-#        },
-        'choice' : {
-            'actions' : [],
-            'result' : {'type' : 'choice', 'next_state': _test_exist }
-        },
-#        'choice_raise':{
-#                        'actions':[],
-#            'result':{ 'type': 'action',
-#                       'action' : _raise,
-#                       'state':'end'}
-#        },
-        'add_p' :{
-            'actions':[],
-            'result':{
-            'type':'action',
-            'action': _add_pdct,
-            'state': 'prod'}
-        },
-#        'add_pp' :{
-#            'actions':[],
-#            'result':{
-#            'type':'action',
-#            'action': _add_pdct,
-#            'state': 'end'}
-#        },
-        'receipt':{
-            'result': {
-                'type': 'print',
-                'report': 'pos.receipt',
-                'state': 'end'
-            }
-        },
-        'return_w':{
-            'actions':[],
-            'result':{'type':'action', 'action':_create_returns2, 'state':'end'}
-        },
-
-        'close':{
-            'actions' : [],
-            'result' : {'type' : 'choice', 'next_state': _close }
-        },
-
-       'check': {
-            'actions': [],
-            'result': {
-                'type': 'choice',
-                'next_state': _check,
-            }
-        },
-
-        'ask_pay': {
-            'actions': [_pre_init],
-            'result': {
-                'type': 'form',
-                'arch': payment_form,
-                'fields': payment_fields,
-                'state': (('end', 'Cancel'), ('add_pay', 'Ma_ke payment', 'gtk-ok', True)
-                         )
-            }
-        },
-        'add_pay': {
-            'actions': [_add_pay],
-            'result': {
-                'type': 'state',
-                'state': "check",
-            }
-        },
-
-
-        'invoice': {
-            'actions': [create_invoice],
-            'result': {
-                'type': 'print',
-                'report': 'pos.invoice',
-                'state': 'end'
-            }
-        },
-        'receipt': {
-            'actions': [],
-            'result': {
-                'type': 'print',
-                'report': 'pos.receipt',
-                'state': 'end'
-            }
-        },
-        'paid': {
-            'actions': [],
-            'result': {
-                'type': 'state',
-                'state': 'end'
-            }
-        },
-
-    }
-wizard_return_picking('pos.return.picking')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 1248794..4c379cc 100644 (file)
@@ -50,7 +50,7 @@ Thanks to the double entry management, the inventory controlling is powerful and
         "wizard/stock_location_product_view.xml",
         "wizard/stock_inventory_line_split_view.xml",
         "wizard/stock_change_standard_price_view.xml",
-        "wizard/stock_inventory_merge_view.xml",
+       
         "wizard/stock_traceability_view.xml",
         "stock_workflow.xml",
         "stock_incoterms.xml",
index 7e727eb..e966c27 100644 (file)
         name="stock.inventory.line.split"
         string="Split inventory lines"/>
 
-    <wizard
+    <!--wizard
         string="Merge inventories"
         model="stock.inventory"
         name="inventory.merge"
         keyword="client_action_multi"
         multi="True"
-        id="wizard_merge_inventory"/>
+        id="wizard_merge_inventory"/-->
 
    </data>
 </openerp>
diff --git a/addons/stock/wizard/inventory_merge.py b/addons/stock/wizard/inventory_merge.py
deleted file mode 100644 (file)
index 7be8eb2..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#    
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
-#
-##############################################################################
-
-
-import wizard
-import pooler
-from tools.translate import _
-
-
-_form = """<?xml version="1.0"?>
-<form string="Merge inventories">
-    <separator colspan="4" string="Merge inventories" />
-    <label string="Do you want to merge theses inventories ?"/>
-</form>
-"""
-
-
-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')
-
-    invent_lines = {}
-
-    if len(data['ids']) < 2:
-        raise wizard.except_wizard(_('Warning'),
-            _('Please select at least two inventories.'))
-
-
-
-    for inventory in invent_obj.browse(cr, uid, data['ids'], context=context):
-        if inventory.state == "done":
-            raise wizard.except_wizard(_('Warning'),
-                _('Merging is only allowed on draft inventories.'))
-
-        for line in inventory.inventory_line_id:
-            key = (line.location_id.id, line.product_id.id, line.product_uom.id)
-            if key in invent_lines:
-                invent_lines[key] += line.product_qty
-            else:
-                invent_lines[key] = line.product_qty
-
-
-    new_invent = invent_obj.create(cr, uid, {
-        'name': 'Merged inventory'
-        }, context=context)
-
-    for key, quantity in invent_lines.items():
-        invent_line_obj.create(cr, uid, {
-            'inventory_id': new_invent,
-            'location_id': key[0],
-            'product_id': key[1],
-            'product_uom': key[2],
-            'product_qty': quantity,
-            })
-
-    return {}
-
-
-class merge_inventory(wizard.interface):
-    states = {
-        'init' : {
-            'actions' : [],
-            'result' : {'type' : 'form',
-                    'arch' : _form,
-                    'fields' : {},
-                    'state' : [('end', 'Cancel', 'gtk-cancel'),
-                               ('merge', 'Yes', 'gtk-apply', True) ]}
-        },
-        'merge' : {
-            'actions' : [],
-            'result' : {'type' : 'action',
-                        'action': do_merge,
-                        'state' : 'end'}
-        },
-    }
-merge_inventory("inventory.merge")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/stock_inventory_merge.py b/addons/stock/wizard/stock_inventory_merge.py
new file mode 100644 (file)
index 0000000..6462005
--- /dev/null
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+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_merge(osv.osv_memory):
+    _name = "stock.inventory.merge"
+    _description = "Merge Inventory"
+    _columns = {
+           
+            }
+
+    def do_merge(self, cr, uid, ids, context):
+
+        invent_obj = self.pool.get('stock.inventory')
+        invent_line_obj = self.pool.get('stock.inventory.line')
+
+        invent_lines = {}
+
+        if len(context['active_ids']) < 2:
+            raise osv.except_osv(_('Warning'),
+            _('Please select at least two inventories.'))
+
+
+
+        for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context):
+            print"-------active-ids----",context['active_ids']
+            if inventory.state == "done":
+                raise osv.except_osv(_('Warning'),
+                _('Merging is only allowed on draft inventories.'))
+
+            for line in inventory.inventory_line_id:
+                key = (line.location_id.id, line.product_id.id, line.product_uom.id)
+                if key in invent_lines:
+                    invent_lines[key] += line.product_qty
+                else:
+                    invent_lines[key] = line.product_qty
+
+
+        new_invent = invent_obj.create(cr, uid, {
+            'name': 'Merged inventory'
+            }, context=context)
+
+        for key, quantity in invent_lines.items():
+            invent_line_obj.create(cr, uid, {
+                'inventory_id': new_invent,
+                'location_id': key[0],
+                'product_id': key[1],
+                'product_uom': key[2],
+                'product_qty': quantity,
+                })
+
+        return {}
+
+stock_inventory_merge()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_picking_make.py b/addons/stock/wizard/stock_picking_make.py
new file mode 100644 (file)
index 0000000..6ac54ee
--- /dev/null
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+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_picking_make(osv.osv_memory):
+    _name = "stock.picking.make"
+    _description = "Make picking"
+    _columns = {
+            'pickings': fields.many2many('stock.picking', 'Picking', required=True),
+            }
+
+ARCH = '''<?xml version="1.0"?>
+<form string="Make picking">
+    <field name="pickings" nolabel="1" colspan="4"
+        width="600" height="300"/>
+</form>'''
+
+FIELDS = {
+    'pickings': {
+        'string': 'Picking',
+        'type': 'many2many',
+        'relation': 'stock.picking',
+        'readonly': True,
+    },
+}
+
+def _get_value(obj, cursor, user, data, context):
+    pool = pooler.get_pool(cursor.dbname)
+    picking_obj = pool.get('stock.picking')
+
+    picking_ids = picking_obj.search(cursor, user, [
+        ('id', 'in', data['ids']),
+        ('state', '<>', 'done'),
+        ('state', '<>', 'cancel')], context=context)
+    return {'pickings': picking_ids}
+
+def _make_packing(obj, cursor, user, data, context):
+    wkf_service = netsvc.LocalService('workflow')
+    pool = pooler.get_pool(cursor.dbname)
+    picking_obj = pool.get('stock.picking')
+    ids = data['form']['pickings'][0][2]
+    print"-------ids--------",ids
+    picking_obj.force_assign(cursor, user, ids)
+    picking_obj.action_move(cursor, user, ids)
+    for picking_id in ids:
+        wkf_service.trg_validate(user, 'stock.picking', picking_id,
+                'button_done', cursor)
+    return {}
+
+class stock_picking_make(wizard.interface):
+    states = {
+        'init': {
+            'actions': [_get_value],
+            'result': {
+                'type': 'form',
+                'arch': ARCH,
+                'fields': FIELDS,
+                'state': [
+                    ('end', 'Cancel', 'gtk-cancel'),
+                    ('make', 'Ok', 'gtk-apply', True)
+                ],
+            },
+        },
+        'make': {
+            'actions': [_make_packing],
+            'result': {
+                'type': 'state',
+                'state':'end',
+            },
+        },
+    }
+
+stock_picking_make('stock.picking.make')
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/wizard_picking_make.py b/addons/stock/wizard/wizard_picking_make.py
deleted file mode 100644 (file)
index 287fb06..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-import wizard
-import pooler
-import netsvc
-
-ARCH = '''<?xml version="1.0"?>
-<form string="Make picking">
-    <field name="pickings" nolabel="1" colspan="4"
-        width="600" height="300"/>
-</form>'''
-
-FIELDS = {
-    'pickings': {
-        'string': 'Picking',
-        'type': 'many2many',
-        'relation': 'stock.picking',
-        'readonly': True,
-    },
-}
-
-def _get_value(obj, cursor, user, data, context):
-    pool = pooler.get_pool(cursor.dbname)
-    picking_obj = pool.get('stock.picking')
-
-    picking_ids = picking_obj.search(cursor, user, [
-        ('id', 'in', data['ids']),
-        ('state', '<>', 'done'),
-        ('state', '<>', 'cancel')], context=context)
-    return {'pickings': picking_ids}
-
-def _make_packing(obj, cursor, user, data, context):
-    wkf_service = netsvc.LocalService('workflow')
-    pool = pooler.get_pool(cursor.dbname)
-    picking_obj = pool.get('stock.picking')
-    ids = data['form']['pickings'][0][2]
-    picking_obj.force_assign(cursor, user, ids)
-    picking_obj.action_move(cursor, user, ids)
-    for picking_id in ids:
-        wkf_service.trg_validate(user, 'stock.picking', picking_id,
-                'button_done', cursor)
-    return {}
-
-class stock_picking_make(wizard.interface):
-    states = {
-        'init': {
-            'actions': [_get_value],
-            'result': {
-                'type': 'form',
-                'arch': ARCH,
-                'fields': FIELDS,
-                'state': [
-                    ('end', 'Cancel', 'gtk-cancel'),
-                    ('make', 'Ok', 'gtk-apply', True)
-                ],
-            },
-        },
-        'make': {
-            'actions': [_make_packing],
-            'result': {
-                'type': 'state',
-                'state':'end',
-            },
-        },
-    }
-
-stock_picking_make('stock.picking.make')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-