[REV] mrp_subcontracting: avoid setting done qty on subcontracted SM

This reverts commit a32778d2b24af2774057f5428c53291653ddc6d3, as it was
a temporary fix in wait of the larger one included in this PR.

Task-3383596

Part-of: odoo/odoo#142513
This commit is contained in:
clesgow
2023-11-22 23:58:13 +00:00
parent 3005e7ac5e
commit 7023769d64
2 changed files with 0 additions and 61 deletions
@@ -16,11 +16,6 @@ class StockMove(models.Model):
compute='_compute_show_subcontracting_details_visible'
)
@api.depends('is_subcontract', 'move_orig_ids.production_id')
def _compute_is_quantity_done_editable(self):
super()._compute_is_quantity_done_editable()
self.filtered(lambda m: m.is_subcontract).is_quantity_done_editable = False
def _compute_display_assign_serial(self):
super(StockMove, self)._compute_display_assign_serial()
for move in self:
@@ -670,62 +670,6 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
self.assertEqual(self.env['mrp.production'].search_count([('bom_id', '=', bom.id)]), 3)
def test_several_backorders02(self):
"""
Receipt for 5 subcontracted products
Process three of them with backorder, then the remaining qty. The user
should never be able to define the produced qty directly on the
picking's SM.
"""
finished, component = self.env['product.product'].create([{
'name': 'Finished Product',
'type': 'product',
}, {
'name': 'Component',
'type': 'product',
}])
self.env['mrp.bom'].create({
'product_tmpl_id': finished.product_tmpl_id.id,
'product_qty': 1.0,
'type': 'subcontract',
'subcontractor_ids': [(4, self.subcontractor_partner1.id)],
'bom_line_ids': [(0, 0, {'product_id': component.id, 'product_qty': 1.0})],
})
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = finished
move.product_uom_qty = 5
picking = picking_form.save()
picking.action_confirm()
for done_qty in [2, 3]:
with self.assertRaises(AssertionError):
with Form(picking) as picking_form:
with picking_form.move_ids_without_package.edit(0) as line:
line.quantity = done_qty
line.picked = True
action = picking.action_record_components()
mo = self.env['mrp.production'].browse(action['res_id'])
mo_form = Form(mo.with_context(**action['context']), view=action['view_id'])
mo_form.qty_producing = done_qty
mo = mo_form.save()
mo.subcontracting_record_component()
res = picking.button_validate()
if res is not True:
wizard = Form(self.env[res['res_model']].with_context(res['context'])).save()
wizard.process()
picking = picking.backorder_ids
productions = self.env['mrp.production'].search([('product_id', '=', finished.id)], order='id')
self.assertEqual(productions.mapped('state'), ['done', 'done'])
self.assertEqual(productions.move_raw_ids.mapped('quantity'), [2.0, 3.0])
def test_subcontracting_rules_replication(self):
""" Test activate/archive subcontracting location rules."""
reference_location_rules = self.env['stock.rule'].search(['|', ('location_src_id', '=', self.env.company.subcontracting_location_id.id), ('location_dest_id', '=', self.env.company.subcontracting_location_id.id)])