← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/ron-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2

 

ron(openerp) has proposed merging lp:~openerp-dev/openobject-addons/ron-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  #606325 EAN code validation fails
  https://bugs.launchpad.net/bugs/606325
  #627936 mrp: procurement from orderpoints is generated for non-active, non-purchasable products (5.0)
  https://bugs.launchpad.net/bugs/627936
  #634856 [mrp] constraint needed for orderpoints (5.0)
  https://bugs.launchpad.net/bugs/634856
  #663890 Creating invoices and grouping multiplies services
  https://bugs.launchpad.net/bugs/663890
  #666362 [6.0RC1] sale Invoice Control "Not from Picking" is bad wording
  https://bugs.launchpad.net/bugs/666362
  #667246 Wrong Journals when creating an invoice from picking
  https://bugs.launchpad.net/bugs/667246
  #667324 invoicing control in purchase orders
  https://bugs.launchpad.net/bugs/667324
  #669210 [trunk][mrp] stock_move.action_consume raises exception
  https://bugs.launchpad.net/bugs/669210
  #670056 [6.0RC1] stock moves - missing search field "Reference"
  https://bugs.launchpad.net/bugs/670056
  #670652 Demo data of purchase order is not relevant in terms of supplier address
  https://bugs.launchpad.net/bugs/670652
  #670921 Purchase module : problems in group by in seach view
  https://bugs.launchpad.net/bugs/670921
  #671172 Return packingnumber hardcoded {'name':'%s (return)' % pick.name
  https://bugs.launchpad.net/bugs/671172
  #671386 PO Line description doesn't take Supplier Product Name or Code in Product's Suppliers Tab
  https://bugs.launchpad.net/bugs/671386
  #673572 [6.0 RC1] Stock move in done state add a pack and production lot
  https://bugs.launchpad.net/bugs/673572
  #677429 [6.0RC1][purchase]Invoice journal(s) not loaded properly
  https://bugs.launchpad.net/bugs/677429
  #690115 A "Purchase / Manager" does not have more rights than a "Purchase / User". Statistics report should not be allow for "Purchase/User" group.
  https://bugs.launchpad.net/bugs/690115
  #690228 shouldn't be able to change the company after have vaidated an inventory 
  https://bugs.launchpad.net/bugs/690228
  #690581 Stock_planning : Unable to create Forecasting periods.
  https://bugs.launchpad.net/bugs/690581
  #690763 PRODUCT V6 : the ean13 check is incorrect
  https://bugs.launchpad.net/bugs/690763
  #691012 [trunk][mrp] bugfix on consuming materials introduced two new bugs
  https://bugs.launchpad.net/bugs/691012
  #691709 procurement exception when there is stock
  https://bugs.launchpad.net/bugs/691709
  #692827 Procurement Module view arch missing some fields in tree
  https://bugs.launchpad.net/bugs/692827
  #692913 [6.0] PO - Button "Approved" shows approved AND done
  https://bugs.launchpad.net/bugs/692913
  #693056 price_multi_get() is comparing pricelist_ids to pricelist_version_ids
  https://bugs.launchpad.net/bugs/693056
  #693806 Invalid literal for int() in sequence with prefix
  https://bugs.launchpad.net/bugs/693806
  #697085 Backorder Cannot be create on Incoming Shipment
  https://bugs.launchpad.net/bugs/697085
  #697142 Unicode encoding problem on stock module
  https://bugs.launchpad.net/bugs/697142
  #697209 Belgium not defined as an Intrastat member by default
  https://bugs.launchpad.net/bugs/697209

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/ron-dev-addons2/+merge/45820

https://launchpad.net/bugs/697209
https://launchpad.net/bugs/697085
purchase:Add Yml file which has product price Costing Method is Average Price
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/ron-dev-addons2/+merge/45820
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/ron-dev-addons2.
=== modified file 'purchase/__openerp__.py'
--- purchase/__openerp__.py	2010-10-26 06:08:44 +0000
+++ purchase/__openerp__.py	2011-01-11 09:02:02 +0000
@@ -54,7 +54,7 @@
         'report/purchase_report_view.xml',
         'board_purchase_view.xml',
     ],
-    'test': [
+    'test': ['test/purchase_on_average_price.yml',
              'test/purchase_from_order.yml',
              'test/purchase_from_manual.yml',
              'test/purchase_from_picking.yml',

=== added file 'purchase/test/purchase_on_average_price.yml'
--- purchase/test/purchase_on_average_price.yml	1970-01-01 00:00:00 +0000
+++ purchase/test/purchase_on_average_price.yml	2011-01-11 09:02:02 +0000
@@ -0,0 +1,107 @@
+-
+  In order to test Checking of Cost price of product if the product price "Costing Method" 
+  is "Average Price" and we change value of product on incoming shipment
+  
+-        
+  I create  product.
+-
+  !record {model: product.product, id: product_product_pen0 }:
+    categ_id: product.product_category_3
+    cost_method: average
+    name: Pen drive
+    procure_method: make_to_stock
+    supply_method: buy
+    type: product
+    standard_price: 1500.0
+    list_price: 1500.0
+    supply_method: buy
+    uom_id: product.product_uom_unit
+    uom_po_id: product.product_uom_unit
+    volume: 0.0
+    warranty: 0.0
+    weight: 0.0
+
+-
+  Update Starting Real Stock And Virtual Stock threw Wizard
+-
+  !record {model: stock.change.product.qty , id: stock_change_product_id }:
+    product_id: product_product_pen0 
+    new_quantity: 2.0
+    location_id: stock.stock_location_stock
+-
+  Then, Click on "Update Price" button of this wizard.
+-
+  !python {model: stock.change.product.qty }: |
+    self.change_product_qty(cr, uid, [ref('stock_change_product_id')], {'active_id': ref('product_product_pen0')})
+-
+  I create purchase order for Pen drive.
+- 
+  !record {model: purchase.order, id: purchase_order_po11}:
+    company_id: base.main_company
+    date_order: '2010-05-11'
+    invoice_method: order
+    location_id: stock.stock_location_stock
+    order_line:
+      - date_planned: '2010-05-13'
+        name: Pen drive
+        price_unit: 1500.0
+        product_id: 'product_product_pen0'
+        product_qty: 2.0
+        product_uom: product.product_uom_unit
+        state: draft
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+    pricelist_id: purchase.list0
+-
+  PO Initially in Draft State .
+-
+  !assert {model: purchase.order, id: purchase_order_po11}:
+    - state == 'draft'  
+-  
+  PO Going to Draft To Confirm State
+-
+  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po11}
+-
+  I check that the Order has transit from draft state to confirm state.
+-
+  !assert {model: purchase.order, id: purchase_order_po11}:
+    - state == 'approved'  
+-   
+  I receive the order of the supplier the Incoming Shipments menu.
+-   
+  !python {model: stock.picking }: |
+    import time
+    procurement_obj = self.pool.get('procurement.order')
+    proc_ids = procurement_obj.browse(cr, uid, [ref('purchase_order_po11')])[0]
+    picking_ids = self.search(cr, uid, [('purchase_id', '=', proc_ids.id),('type','=','in')])
+    pickings = self.browse(cr, uid, picking_ids)
+    for picking in pickings:
+       move = picking.move_lines[0]
+       partial_datas = {
+            'partner_id': picking.address_id.partner_id.id,
+            'address_id': picking.address_id.id,
+            'delivery_date' : time.strftime('%Y-%m-%d')
+           }
+       partial_datas['move%s'%(move.id)]= {
+           'product_id': move.product_id,
+           'product_qty': move.product_qty,
+           'product_uom': move.product_uom.id,
+           'product_price' : 1000.0,
+       } 
+       self.do_partial(cr, uid, [picking.id], partial_datas)
+-
+  I confirm the Reservation.
+-
+  !python {model: stock.move }: |
+    procurement_obj = self.pool.get('procurement.order')
+    picking_obj = self.pool.get('stock.picking')
+    proc_ids = procurement_obj.browse(cr, uid, [ref('purchase_order_po11')])[0]
+    picking_ids = picking_obj.search(cr, uid, [('purchase_id', '=', proc_ids.id),('type','=','in')])
+    move_ids = self.search(cr, uid, [('picking_id', '=', picking_ids)])
+    self.action_done(cr,uid,move_ids)
+-
+  Compare With Avarage Price Has Been Updated that is Correct
+-
+  !assert {model: product.product, id: product_product_pen0 ,string: Updated Avarage Price Has not been Correct}:
+    - standard_price == 1250  
+

=== modified file 'report_intrastat/report_intrastat_data.xml'
--- report_intrastat/report_intrastat_data.xml	2008-09-10 17:56:00 +0000
+++ report_intrastat/report_intrastat_data.xml	2011-01-11 09:02:02 +0000
@@ -4,6 +4,9 @@
         <record id="base.de" model="res.country">
             <field eval="True" name="intrastat"/>
         </record>
+        <record id="base.be" model="res.country">
+            <field eval="True" name="intrastat"/>
+        </record>
         <record id="base.at" model="res.country">
             <field eval="True" name="intrastat"/>
         </record>

=== modified file 'stock/wizard/stock_partial_picking.py'
--- stock/wizard/stock_partial_picking.py	2011-01-10 15:43:57 +0000
+++ stock/wizard/stock_partial_picking.py	2011-01-11 09:02:02 +0000
@@ -28,54 +28,71 @@
     _name = "stock.partial.picking"
     _description = "Partial Picking"
     _columns = {
-        'date': fields.datetime('Date', required=True),
-        'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'),
-        'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'),
+        'date': fields.datetime('Date', required=True), 
+        'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'), 
+        'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'), 
      }
-
-    def __is_in(self,cr, uid, pick_ids):
-        """
-            @return: True if one of the moves has as picking type 'in'
-        """
-        if not pick_ids:
-            return False
-
+    
+    def get_picking_type(self, cr, uid, picking, context=None):
+        picking_type = picking.type
+        for move in picking.move_lines:
+            if picking.type == 'in' and move.product_id.cost_method == 'average':
+                picking_type = 'in'
+        return picking_type
+    
+    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 = {}
+            
         pick_obj = self.pool.get('stock.picking')
-        pick_ids = pick_obj.search(cr, uid, [('id','in',pick_ids)])
-
-
-        for pick in pick_obj.browse(cr, uid, pick_ids):
-            for move in pick.move_lines:
-                if pick.type == 'in' and move.product_id.cost_method == 'average':
-                    return True
-        return False
-
-    def __get_picking_type(self, cr, uid, pick_ids):
-        if self.__is_in(cr, uid, pick_ids):
-            return "product_moves_in"
-        else:
-            return "product_moves_out"
-
-    def view_init(self, cr, uid, fields_list, context=None):
-        res = super(stock_partial_picking, self).view_init(cr, uid, fields_list, context=context)
+        res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
+        picking_ids = context.get('active_ids', [])
+        if not picking_ids:
+            return res
+
+        result = []
+        for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
+            pick_type = self.get_picking_type(cr, uid, pick, context=context)
+            for m in pick.move_lines:
+                if m.state in ('done', 'cancel'):
+                    continue
+                result.append(self.__create_partial_picking_memory(m, pick_type))
+
+        if 'product_moves_in' in fields:
+            res.update({'product_moves_in': result})
+        if 'product_moves_out' in fields:
+            res.update({'product_moves_out': result})
+        if 'date' in fields:
+            res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')})
         return res
-
-    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
-        result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
-
-
+    
+    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+        result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
+       
+        pick_obj = self.pool.get('stock.picking')
         picking_ids = context.get('active_ids', False)
-        picking_type = self.__get_picking_type(cr, uid, picking_ids)
 
+        for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
+            picking_type = self.get_picking_type(cr, uid, pick, context=context)
+        
         _moves_arch_lst = """<form string="%s">
                         <field name="date" invisible="1"/>
                         <separator colspan="4" string="%s"/>
                         <field name="%s" colspan="4" nolabel="1" mode="tree,form" width="550" height="200" ></field>
-                        """ % (_('Process Document'), _('Products'), picking_type)
+                        """ % (_('Process Document'), _('Products'), "product_moves_" + picking_type)
         _moves_fields = result['fields']
+
+        # add field related to picking type only
         _moves_fields.update({
-                            'product_moves_in' : {'relation': 'stock.move.memory.in', 'type' : 'one2many', 'string' : 'Product Moves'},
-                            'product_moves_out' : {'relation': 'stock.move.memory.out', 'type' : 'one2many', 'string' : 'Product Moves'}
+                            'product_moves_' + picking_type: {'relation': 'stock.move.memory.'+picking_type, 'type' : 'one2many', 'string' : 'Product Moves'}, 
                             })
 
         _moves_arch_lst += """
@@ -92,44 +109,22 @@
         result['fields'] = _moves_fields
         return result
 
-    def __create_partial_picking_memory(self, picking, is_in):
+    def __create_partial_picking_memory(self, picking, pick_type):
         move_memory = {
-            'product_id' : picking.product_id.id,
-            'quantity' : picking.product_qty,
-            'product_uom' : picking.product_uom.id,
-            'prodlot_id' : picking.prodlot_id.id,
-            'move_id' : picking.id,
+            'product_id' : picking.product_id.id, 
+            'quantity' : picking.product_qty, 
+            'product_uom' : picking.product_uom.id, 
+            'prodlot_id' : picking.prodlot_id.id, 
+            'move_id' : picking.id, 
         }
-
-        if is_in:
+    
+        if pick_type == 'in':
             move_memory.update({
-                'cost' : picking.product_id.standard_price,
-                'currency' : picking.product_id.company_id and picking.product_id.company_id.currency_id and  picking.product_id.company_id.currency_id.id or False,
+                'cost' : picking.product_id.standard_price, 
+                'currency' : picking.product_id.company_id.currency_id.id, 
             })
         return move_memory
 
-    def __get_active_stock_pickings(self, cr, uid, context=None):
-        pick_obj = self.pool.get('stock.picking')
-        if not context:
-            context = {}
-
-        res = []
-        for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context):
-            need_product_cost = (pick.type == 'in')
-            for m in pick.move_lines:
-                if m.state in ('done', 'cancel'):
-                    continue
-                res.append(self.__create_partial_picking_memory(m, need_product_cost))
-
-        return res
-
-    _defaults = {
-        'product_moves_in' : __get_active_stock_pickings,
-        'product_moves_out' : __get_active_stock_pickings,
-        'date' : lambda *a : time.strftime('%Y-%m-%d %H:%M:%S'),
-    }
-
-
     def do_partial(self, cr, uid, ids, context=None):
         """ Makes partial moves and pickings done.
         @param self: The object pointer.
@@ -140,6 +135,9 @@
         @return: A dictionary which of fields with values.
         """
         pick_obj = self.pool.get('stock.picking')
+        move_obj = self.pool.get('stock.move')
+        location_obj = self.pool.get('stock.location')
+        
         picking_ids = context.get('active_ids', False)
         partial = self.browse(cr, uid, ids[0], context=context)
         partial_datas = {
@@ -147,40 +145,24 @@
         }
 
         for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
-            need_product_cost = (pick.type == 'in')
-            moves_list = need_product_cost and partial.product_moves_in  or partial.product_moves_out
-            p_moves = {}
-            for product_move in moves_list:
-                p_moves[product_move.move_id.id] = product_move
-
-
-            for move in pick.move_lines:
-                if move.state in ('done', 'cancel'):
-                    continue
-                if not p_moves.get(move.id):
-                    continue
-
-                partial_datas['move%s' % (move.id)] = {
-                    'product_id' : p_moves[move.id].id,
-                    'product_qty' : p_moves[move.id].quantity,
-                    'product_uom' :p_moves[move.id].product_uom.id,
-                    'prodlot_id' : p_moves[move.id].prodlot_id.id,
+            picking_type = self.get_picking_type(cr, uid, pick, context=context)
+            moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
+
+            for move in moves_list:
+                partial_datas['move%s' % (move.move_id.id)] = {
+                    'product_id': move.id, 
+                    'product_qty': move.quantity, 
+                    'product_uom': move.product_uom.id, 
+                    'prodlot_id': move.prodlot_id.id, 
                 }
-
-
-                if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'):
+                if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
                     partial_datas['move%s' % (move.id)].update({
-                                                    'product_price' : p_moves[move.id].cost,
-                                                    'product_currency': p_moves[move.id].currency.id,
+                                                    'product_price' : move.cost, 
+                                                    'product_currency': move.currency.id, 
                                                     })
         pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
-        return {'type': 'ir.actions.act_window_close'}
-
-
-
+        return {}
 
 stock_partial_picking()
 
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file


Follow ups