
from openerp import api, models


class ProcurementOrder(models.Model):
    _inherit = 'procurement.order'

    @api.model
    def _prepare_mo_vals(self, procurement):
        result = super(ProcurementOrder, self)._prepare_mo_vals(procurement)
        product_id = result.get('product_id')
        product = self.env['product.product'].browse(product_id)
        result['product_tmpl_id'] = product.product_tmpl_id.id
        result['product_attribute_ids'] = (
            (0, 0, x) for x in product._get_product_attributes_values_dict())
        for val in result['product_attribute_ids']:
            val = val[2]
            val['product_tmpl_id'] = product.product_tmpl_id.id
            val['owner_model'] = 'mrp.production'
        return result


from openerp import api, models


class ProcurementOrder(models.Model):
    _inherit = 'procurement.order'

    @api.model
    def _prepare_mo_vals(self, procurement):
        result = super(ProcurementOrder, self)._prepare_mo_vals(procurement)
        product_id = result.get('product_id')
        product = self.env['product.product'].browse(product_id)
        result['product_tmpl_id'] = product.product_tmpl_id.id
        product_attribute_ids = product._get_product_attributes_values_dict()
        result['product_attribute_ids'] = map(
            lambda x: (0, 0, x), product_attribute_ids)
        for val in result['product_attribute_ids']:
            val = val[2]
            val['product_tmpl_id'] = product.product_tmpl_id.id
            val['owner_model'] = 'mrp.production'
        return result

Fix MTO configurator not filled
[FIX] mrp_product_variants: Fix MTO configurator not filled

  
  from openerp import api, models
  
  
  class ProcurementOrder(models.Model):
      _inherit = 'procurement.order'
  
      @api.model
      def _prepare_mo_vals(self, procurement):
          result = super(ProcurementOrder, self)._prepare_mo_vals(procurement)
          product_id = result.get('product_id')
          product = self.env['product.product'].browse(product_id)
          result['product_tmpl_id'] = product.product_tmpl_id.id
+         product_attribute_ids = product._get_product_attributes_values_dict()
-         result['product_attribute_ids'] = (
+         result['product_attribute_ids'] = map(
-             (0, 0, x) for x in product._get_product_attributes_values_dict())
+             lambda x: (0, 0, x), product_attribute_ids)
          for val in result['product_attribute_ids']:
              val = val[2]
              val['product_tmpl_id'] = product.product_tmpl_id.id
              val['owner_model'] = 'mrp.production'
          return result
  
Fix MTO configurator not filled
## Code Before:

from openerp import api, models


class ProcurementOrder(models.Model):
    _inherit = 'procurement.order'

    @api.model
    def _prepare_mo_vals(self, procurement):
        result = super(ProcurementOrder, self)._prepare_mo_vals(procurement)
        product_id = result.get('product_id')
        product = self.env['product.product'].browse(product_id)
        result['product_tmpl_id'] = product.product_tmpl_id.id
        result['product_attribute_ids'] = (
            (0, 0, x) for x in product._get_product_attributes_values_dict())
        for val in result['product_attribute_ids']:
            val = val[2]
            val['product_tmpl_id'] = product.product_tmpl_id.id
            val['owner_model'] = 'mrp.production'
        return result

## Instruction:
Fix MTO configurator not filled
## Code After:

from openerp import api, models


class ProcurementOrder(models.Model):
    _inherit = 'procurement.order'

    @api.model
    def _prepare_mo_vals(self, procurement):
        result = super(ProcurementOrder, self)._prepare_mo_vals(procurement)
        product_id = result.get('product_id')
        product = self.env['product.product'].browse(product_id)
        result['product_tmpl_id'] = product.product_tmpl_id.id
        product_attribute_ids = product._get_product_attributes_values_dict()
        result['product_attribute_ids'] = map(
            lambda x: (0, 0, x), product_attribute_ids)
        for val in result['product_attribute_ids']:
            val = val[2]
            val['product_tmpl_id'] = product.product_tmpl_id.id
            val['owner_model'] = 'mrp.production'
        return result
