← Back to team overview

openerp-dev-web team mailing list archive

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

 

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

Requested reviews:
  OpenERP R&D Team (openerp-dev)
Related bugs:
  #500931 No analytic entry is generated finishing one production order
  https://bugs.launchpad.net/bugs/500931
  #543979 product: check uos not necessary
  https://bugs.launchpad.net/bugs/543979
  #674551 "qunatity" in MRP
  https://bugs.launchpad.net/bugs/674551
  #675418 account moves with same account in debit and credit
  https://bugs.launchpad.net/bugs/675418


[1] Task 1773 - improve code when production lot and pack created
[2] https://bugs.launchpad.net/openobject-addons/+bug/500931 
[3] https://bugs.launchpad.net/openobject-addons/+bug/675418
[4] https://bugs.launchpad.net/openobject-addons/+bug/674551
[5] https://bugs.launchpad.net/openobject-addons/+bug/543979
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/ksa-addons2/+merge/41455
Your team OpenERP R&D Team is requested to review the proposed merge of lp:~openerp-dev/openobject-addons/ksa-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2.
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py	2010-11-19 06:10:09 +0000
+++ mrp/mrp.py	2010-11-22 12:48:21 +0000
@@ -53,11 +53,22 @@
         'costs_journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal'),
         'costs_general_account_id': fields.many2one('account.account', 'General Account', domain=[('type','<>','view')]),
         'resource_id': fields.many2one('resource.resource','Resource', ondelete='cascade', required=True),
+        'product_id': fields.many2one('product.product','Product'),
     }
     _defaults = {
         'capacity_per_cycle': 1.0,
         'resource_type': 'material',
      }
+
+    def on_change_product_cost(self, cr, uid, ids, product_id, context=None):
+        if context is None:
+            context = {}
+        res = {'value':{}}
+
+        if product_id:
+            cost = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
+            res = {'value' : {'costs_hour' :cost.standard_price }}
+        return res
 mrp_workcenter()
 
 
@@ -737,7 +748,10 @@
                         'account_id': account,
                         'general_account_id': wc.costs_general_account_id.id,
                         'journal_id': wc.costs_journal_id.id,
-                        'code': wc.code
+                        'ref': wc.code,
+                        'product_id': wc.product_id.id,
+                        'unit_amount': wc.costs_hour * wc.time_cycle,
+                        'product_uom_id': wc.product_id.uom_id.id
                     } )
             if wc.costs_journal_id and wc.costs_general_account_id:
                 value = wc_line.cycle * wc.costs_cycle
@@ -750,7 +764,10 @@
                         'account_id': account,
                         'general_account_id': wc.costs_general_account_id.id,
                         'journal_id': wc.costs_journal_id.id,
-                        'code': wc.code,
+                        'ref': wc.code,
+                        'product_id': wc.product_id.id,
+                        'unit_amount': wc.costs_hour * wc.time_cycle,
+                        'product_uom_id': wc.product_id.uom_id.id
                     } )
         return amount
 

=== modified file 'mrp/mrp_view.xml'
--- mrp/mrp_view.xml	2010-10-26 06:08:44 +0000
+++ mrp/mrp_view.xml	2010-11-22 12:48:21 +0000
@@ -160,12 +160,13 @@
                             </group>
                             <group col="2" colspan="2">
                             <separator colspan="2" string="Costing Information"/>
+                            <field name="product_id" on_change="on_change_product_cost(product_id)"/>
                             <field name="costs_hour"/>
                             <field name="costs_hour_account_id" groups="analytic.group_analytic_accounting"/>
                             <field name="costs_cycle"/>
                             <field name="costs_cycle_account_id" groups="analytic.group_analytic_accounting"/>
-                            <field name="costs_journal_id" groups="analytic.group_analytic_accounting"/>
-                            <field name="costs_general_account_id" groups="analytic.group_analytic_accounting"/>
+                            <field name="costs_journal_id" attrs="{'required':['|',('costs_hour_account_id', '=', True),('costs_cycle_account_id', '=', True)]}" groups="analytic.group_analytic_accounting"/>
+                            <field name="costs_general_account_id" attrs="{ 'required':['|',('costs_cycle_account_id', '=', True),('costs_hour_account_id', '=', True)]}" groups="analytic.group_analytic_accounting"/>
                             </group>
                             <separator colspan="4" string="Description"/>
                             <field colspan="4" name="note" nolabel="1"/>
@@ -649,9 +650,9 @@
                                     <field name="product_uom"  string="UOM" widget="selection"/>
                                     <field name="location_id"  string="Source Loc." widget="selection"/>
                                     <field name="state" invisible="1"/>
-                                    <button name="%(stock.action_partial_move)d" 
-                                        string="Partial" 
-                                        type="action" states="confirmed,assigned" 
+                                    <button name="%(stock.action_partial_move)d"
+                                        string="Partial"
+                                        type="action" states="confirmed,assigned"
                                         icon="gtk-justify-fill"/>
                                     <button name="%(stock.move_scrap)d"
                                         string="Scrap Products" type="action"
@@ -926,9 +927,9 @@
         <menuitem action="mrp_workcenter_action" id="menu_view_resource_search_mrp" parent="menu_pm_resources_config" sequence="1"/>
         <menuitem action="resource.action_resource_calendar_form" id="menu_view_resource_calendar_search_mrp" parent="menu_pm_resources_config" sequence="1"/>
         <menuitem action="resource.action_resource_calendar_leave_tree" id="menu_view_resource_calendar_leaves_search_mrp" parent="menu_pm_resources_config" sequence="1"/>
-        
+
         <!-- Planning -->
-        
+
         <menuitem id="menu_mrp_planning" name="Planning"
 		        parent="base.menu_mrp_root" sequence="2"
 		        groups="base.group_extended"/>

=== modified file 'mrp/wizard/mrp_price.py'
--- mrp/wizard/mrp_price.py	2010-08-13 12:20:05 +0000
+++ mrp/wizard/mrp_price.py	2010-11-22 12:48:21 +0000
@@ -25,7 +25,7 @@
     _name = 'mrp.product_price'
     _description = 'Product Price'
     _columns = {
-        'number': fields.integer('Quantity', required=True, help="Specify quantity of products to produce or buy. Report of Cost structure will be displayed base on this qunatity."),
+        'number': fields.integer('Quantity', required=True, help="Specify quantity of products to produce or buy. Report of Cost structure will be displayed base on this quantity."),
     }
     _defaults = {
         'number': 1,

=== modified file 'procurement/procurement.py'
--- procurement/procurement.py	2010-11-15 09:36:28 +0000
+++ procurement/procurement.py	2010-11-22 12:48:21 +0000
@@ -165,17 +165,13 @@
         """
         return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids))
 
-    def check_move_done(self, cr, uid, ids, context={}):
+    def check_move_done(self, cr, uid, ids, context=None):
         """ Checks if move is done or not.
         @return: True or False.
         """
-        res = True
-        for proc in self.browse(cr, uid, ids, context):
-             if proc.move_id:
-                 if not proc.move_id.state=='done':
-                      res = False
-        return res
-
+        if not context:
+            context = {}
+        return all(not procurement.move_id or procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context))
     #
     # This method may be overrided by objects that override procurement.order
     # for computing their own purpose

=== modified file 'product/product.py'
--- product/product.py	2010-11-18 08:42:54 +0000
+++ product/product.py	2010-11-22 12:48:21 +0000
@@ -327,7 +327,7 @@
         return True
 
     _constraints = [
-        (_check_uos, 'Error: UOS must be in a different category than the UOM', ['uos_id']),
+#        (_check_uos, 'Error: UOS must be in a different category than the UOM', ['uos_id']),
         (_check_uom, 'Error: The default UOM and the purchase UOM must be in the same category.', ['uom_id']),
     ]
 

=== modified file 'stock/stock.py'
--- stock/stock.py	2010-11-19 07:24:30 +0000
+++ stock/stock.py	2010-11-22 12:48:21 +0000
@@ -1904,6 +1904,12 @@
         acc_variation = accounts.get('property_stock_variation', False)
         journal_id = accounts['stock_journal']
 
+        if acc_dest == acc_variation:
+            raise osv.except_osv(_('Error!'),  _('Can not create Journal Entry, Output Account on defined on this product and Variant account on category of this product is same.'))
+
+        if acc_src == acc_variation:
+            raise osv.except_osv(_('Error!'),  _('Can not create Journal Entry, Input Account on defined on this product and Variant account on category of this product is same.'))
+
         if not acc_src:
             raise osv.except_osv(_('Error!'),  _('There is no stock input account defined for this product or its category: "%s" (id: %d)') % \
                                     (move.product_id.name, move.product_id.id,))
@@ -2416,6 +2422,11 @@
         return self.pool.get('stock.move').create(cr, uid, move_vals)
 
     def action_done(self, cr, uid, ids, context=None):
+        """ Finished the inventory
+        @return: True
+        """
+        if context is None:
+            context = {}
         move_obj = self.pool.get('stock.move')
         for inv in self.browse(cr, uid, ids, context=context):
             move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
@@ -2423,7 +2434,7 @@
         return True
 
     def action_confirm(self, cr, uid, ids, context=None):
-        """ Finishes the inventory and writes its finished date
+        """ Confirm the inventory and writes its finished date
         @return: True
         """
         if context is None:
@@ -2434,7 +2445,7 @@
         product_context = dict(context, compute_child=False)
 
         location_obj = self.pool.get('stock.location')
-        for inv in self.browse(cr, uid, ids):
+        for inv in self.browse(cr, uid, ids, context=context):
             move_ids = []
             for line in inv.inventory_line_id:
                 pid = line.product_id.id

=== modified file 'stock/stock_demo.xml'
--- stock/stock_demo.xml	2010-11-19 10:25:25 +0000
+++ stock/stock_demo.xml	2010-11-22 12:48:21 +0000
@@ -171,10 +171,15 @@
             <field name="location_id" ref="stock_location_components"/>
         </record>
 
+        <function model="stock.inventory" name="action_confirm">
+            <function eval="[[]]" model="stock.inventory" name="search"/>
+        </function>
+
         <function model="stock.inventory" name="action_done">
             <function eval="[[]]" model="stock.inventory" name="search"/>
         </function>
 
+
         <!--  Multi Company -->
 
         <record id="res_partner_tinyshop0" model="res.partner">

=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml	2010-11-22 12:39:34 +0000
+++ stock/stock_view.xml	2010-11-22 12:48:21 +0000
@@ -118,7 +118,7 @@
                             </form>
                         </field>
                     </page><page string="Posted Inventory" groups="base.group_extended">
-                             <field colspan="2" name="move_ids" nolabel="1" widget="one2many_list">
+                             <field colspan="2" name="move_ids" nolabel="1" widget="one2many_list" context="{'inventory_id':active_id}" >
                                 <tree string="Stock Moves">
                                     <field name="product_id"/>
                                     <field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
@@ -127,17 +127,14 @@
                                      <button name="%(track_line)d" string="Split in production lots" type="action"
                                         icon="terp-stock_effects-object-colorize"
                                         attrs="{'invisible': [('prodlot_id','&lt;&gt;',False)]}"
-                                        context="{'default_use_exist': picking_id.type=='in'}"
                                         states="draft,done,cancel"
+                                        context="{'inventory_id':parent.id}"
                                         groups="base.group_extended"/>
-                                    <field groups="base.group_extended" name="tracking_id"/>
-                                    <button name="setlast_tracking" string="Put in current pack" type="object"
-                                        groups="base.group_extended"
-                                        icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
-                                        states="draft,done,cancel"/>
+                                     <field groups="base.group_extended" name="tracking_id"/>
                                      <button name="%(split_into)d" string="Put in a new pack" type="action"
                                         groups="base.group_extended"
                                         icon="terp-stock_effects-object-colorize"
+                                        context="{'inventory_id':parent.id}"
                                         states="draft,done,cancel"/>
                                     <field name="location_id"/>
                                     <field name="location_dest_id"/>

=== modified file 'stock/wizard/stock_move.py'
--- stock/wizard/stock_move.py	2010-11-02 05:35:59 +0000
+++ stock/wizard/stock_move.py	2010-11-22 12:48:21 +0000
@@ -218,10 +218,14 @@
         @param context: A standard dictionary
         @return:
         """
+        if context is None:
+            context = {}
+        inventory_id = context.get('inventory_id', False)
         prodlot_obj = self.pool.get('stock.production.lot')
+        inventory_obj = self.pool.get('stock.inventory')
         move_obj = self.pool.get('stock.move')
         new_move = []
-        for data in self.browse(cr, uid, ids):
+        for data in self.browse(cr, uid, ids, context=context):
             for move in move_obj.browse(cr, uid, move_ids):
                 move_qty = move.product_qty
                 quantity_rest = move.product_qty
@@ -249,6 +253,10 @@
                     if quantity_rest > 0:
                         current_move = move_obj.copy(cr, uid, move.id, default_val)
                         new_move.append(current_move)
+
+                    if inventory_id:
+                        inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, new_move[0])]}, context=context)
+
                     if quantity_rest == 0:
                         current_move = move.id
                     prodlot_id = False
@@ -259,7 +267,7 @@
                             'name': line.name,
                             'product_id': move.product_id.id},
                         context=context)
-                    
+
                     move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state})
 
                     update_val = {}
@@ -268,6 +276,7 @@
                         update_val['product_uos_qty'] = uos_qty_rest
                         update_val['state'] = move.state
                         move_obj.write(cr, uid, [move.id], update_val)
+
         return new_move
 split_in_production_lot()
 

=== modified file 'stock/wizard/stock_splitinto.py'
--- stock/wizard/stock_splitinto.py	2010-10-12 09:37:45 +0000
+++ stock/wizard/stock_splitinto.py	2010-11-22 12:48:21 +0000
@@ -34,12 +34,17 @@
     }
 
     def split(self, cr, uid, data, context=None):
+        if context is None:
+            context = {}
+
+        inventory_id = context.get('inventory_id', False)
         rec_id = context and context.get('active_ids', False)
         move_obj = self.pool.get('stock.move')
         track_obj = self.pool.get('stock.tracking')
-
+        inventory_obj = self.pool.get('stock.inventory')
         quantity = self.browse(cr, uid, data[0], context).quantity or 0.0
         for move in move_obj.browse(cr, uid, rec_id):
+            new_move = []
             quantity_rest = move.product_qty - quantity
             #if move.tracking_id :
             #    raise osv.except_osv(_('Error!'),  _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \
@@ -56,12 +61,14 @@
                     'product_uos_qty': quantity,
                     'product_uos': move.product_uom.id,
                 })
+
+
             if quantity_rest>0:
                 quantity_rest = move.product_qty - quantity
-                tracking_id = track_obj.create(cr, uid, {})
+                tracking_id = track_obj.create(cr, uid, {}, context=context)
                 if quantity==0.0:
-                    move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id})
-                else:    
+                    move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id}, context=context)
+                else:
                     default_val = {
                         'product_qty': quantity_rest,
                         'product_uos_qty': quantity_rest,
@@ -69,7 +76,12 @@
                         'state': move.state,
                         'product_uos': move.product_uom.id
                     }
-                    move_obj.copy(cr, uid, move.id, default_val)
+                    current_move = move_obj.copy(cr, uid, move.id, default_val)
+                    new_move.append(current_move)
+
+            if inventory_id:
+                inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, new_move[0])]}, context=context)
+
         return {}
 stock_split_into()
 


Follow ups