change_production_qty.py 816 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, models
  4. class ChangeProductionQty(models.TransientModel):
  5. _inherit = 'change.production.qty'
  6. @api.model
  7. def _need_quantity_propagation(self, move, qty):
  8. res = super()._need_quantity_propagation(move, qty)
  9. return res and not any(m.is_subcontract for m in move.move_dest_ids)
  10. @api.model
  11. def _update_product_qty(self, move, qty):
  12. res = super()._update_product_qty(move, qty)
  13. subcontract_moves = move.move_dest_ids.filtered(lambda m: m.is_subcontract)
  14. if subcontract_moves:
  15. subcontract_moves[0].with_context(cancel_backorder=False).write({'product_uom_qty': subcontract_moves[0].product_uom_qty + qty})
  16. return res