stock_rule.py 612 B

123456789101112131415
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import models
  4. class StockRule(models.Model):
  5. _inherit = 'stock.rule'
  6. def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values, bom):
  7. res = super()._prepare_mo_vals(product_id, product_qty, product_uom, location_id, name, origin, company_id, values, bom)
  8. if not bom.analytic_account_id and values.get('analytic_account_id'):
  9. res['analytic_account_id'] = values.get('analytic_account_id').id
  10. return res