Skip to content

OLD 7.0 2015 01 15

Xavier Brochard edited this page Oct 29, 2021 · 1 revision

Conflict:

diff --cc addons/mrp/mrp.py
index 23863f4,aff1a51..0000000
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@@ -365,7 -367,10 +365,14 @@@ class mrp_bom(osv.osv)
                          'hour': float(wc_use.hour_nbr*mult + ((wc.time_start or 0.0)+(wc.time_stop or 0.0)+cycle*(wc.time_cycle or 0.0)) * (wc.time_efficiency or 1.0)),
                      })
              for bom2 in bom.bom_lines:
++<<<<<<< HEAD
 +                res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10, context=context)
++=======
+                 if (bom2.date_start and bom2.date_start > time.strftime(DEFAULT_SERVER_DATE_FORMAT)) or \
+                     (bom2.date_stop and bom2.date_stop < time.strftime(DEFAULT_SERVER_DATE_FORMAT)):
+                     continue
+                 res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10)
++>>>>>>> odoo/7.0
                  result = result + res[0]
                  result2 = result2 + res[1]
          return result, result2
@@@ -620,23 -643,8 +645,28 @@@ class mrp_production(osv.osv)
      
              #unlink workcenter_lines
              workcenter_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.workcenter_lines], context=context)
++<<<<<<< HEAD
 +    
 +            # search BoM structure and route
 +            bom_point = production.bom_id
 +            bom_id = production.bom_id.id
 +            if not bom_point:
 +                bom_id = bom_obj._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties)
 +                if bom_id:
 +                    bom_point = bom_obj.browse(cr, uid, bom_id)
 +                    routing_id = bom_point.routing_id.id or False
 +                    self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
 +    
 +            if not bom_id:
 +                raise osv.except_osv(_('Error!'), _("Cannot find a bill of material for this product."))
 +    
 +            # get components and workcenter_lines from BoM structure
 +            factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
 +            res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id, context=context)
++=======
+ 
+             res = self._prepare_lines(cr, uid, production, properties=properties, context=context)
++>>>>>>> odoo/7.0
              results = res[0] # product_lines
              results2 = res[1] # workcenter_lines
      

Resolved as:

diff --cc addons/mrp/mrp.py
index 23863f4,aff1a51..0000000
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@@ -365,7 -367,10 +365,10 @@@ class mrp_bom(osv.osv)
                          'hour': float(wc_use.hour_nbr*mult + ((wc.time_start or 0.0)+(wc.time_stop or 0.0)+cycle*(wc.time_cycle or 0.0)) * (wc.time_efficiency or 1.0)),
                      })
              for bom2 in bom.bom_lines:
+                 if (bom2.date_start and bom2.date_start > time.strftime(DEFAULT_SERVER_DATE_FORMAT)) or \
+                     (bom2.date_stop and bom2.date_stop < time.strftime(DEFAULT_SERVER_DATE_FORMAT)):
+                     continue
 -                res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10)
 +                res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10, context=context)
                  result = result + res[0]
                  result2 = result2 + res[1]
          return result, result2
@@@ -601,6 -606,26 +604,26 @@@ class mrp_production(osv.osv)
          self.write(cr, uid, ids, {'state': 'picking_except'})
          return True
      
+     def _prepare_lines(self, cr, uid, production, properties=None, context=None):
+         # search BoM structure and route
+         bom_obj = self.pool.get('mrp.bom')
+         uom_obj = self.pool.get('product.uom')
+         bom_point = production.bom_id
+         bom_id = production.bom_id.id
+         if not bom_point:
+             bom_id = bom_obj._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties)
+             if bom_id:
+                 bom_point = bom_obj.browse(cr, uid, bom_id)
+                 routing_id = bom_point.routing_id.id or False
+                 self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
+ 
+         if not bom_id:
+             raise osv.except_osv(_('Error!'), _("Cannot find a bill of material for this product."))
+ 
+         # get components and workcenter_lines from BoM structure
+         factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
 -        return bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id)
++        return bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id, context=context)
+ 
      def _action_compute_lines(self, cr, uid, ids, properties=None, context=None):
          """ Compute product_lines and workcenter_lines from BoM structure
          @return: product_lines

The resolution consists of preserving the OCB-specific context argument to the calls to _bom_explode() in addons/mrp/mrp.py:

https://github.com/odoo/odoo/commit/70a51cd7610111d840ea8b2e8f7b609a1d983769#diff-200a0bd9e95f58f31b37039e65f28d69R373

https://github.com/odoo/odoo/commit/30a7bea024195367a0d24ea2343e08edc36b3b3a#diff-200a0bd9e95f58f31b37039e65f28d69R627

Committed as https://github.com/OCA/OCB/commit/b8617a2d1167920a08a1ec9306be1e1fd4b9f947 by @StefanRijnhart