diff --git a/fieldservice_sale/tests/test_fsm_sale_autofill_location.py b/fieldservice_sale/tests/test_fsm_sale_autofill_location.py index 8bf0bf5ae0..3bd3c35470 100644 --- a/fieldservice_sale/tests/test_fsm_sale_autofill_location.py +++ b/fieldservice_sale/tests/test_fsm_sale_autofill_location.py @@ -49,56 +49,60 @@ def test_00_autofill_so_fsm_location(self): self.location2.partner_id = self.partner self.location3.partner_id = self.shipping_partner - self.location1.flush_model() - self.location2.flush_model() - self.location3.flush_model() + self.location1.flush() + self.location2.flush() + self.location3.flush() + self.env.cr.commit() with Form(self.env["sale.order"]) as so_form: so_form.partner_id = self.partner so = so_form.save() self.assertEqual(so.fsm_location_id, self.location2) - def test_01_autofill_so_fsm_location(self): - """Check location autofill from SO partner - SO partner is not an FSM location defined, but location1 is linked to - its commercial partner => expect location 1 (because of ordering) - """ - self.partner.fsm_location = False - self.location1.partner_id = self.commercial_partner - self.location2.partner_id = self.partner - self.location3.partner_id = self.shipping_partner - with Form(self.env["sale.order"]) as so_form: - so_form.partner_id = self.partner - so = so_form.save() - self.assertEqual(so.fsm_location_id, self.location1) +def test_01_autofill_so_fsm_location(self): + """Check location autofill from SO partner - def test_02_autofill_so_fsm_location(self): - """Check location autofill from SO partner + SO partner is not an FSM location defined, but location1 is linked to + its commercial partner => expect location 1 (because of ordering) + """ + self.partner.fsm_location = False + self.location1.partner_id = self.commercial_partner + self.location2.partner_id = self.partner + self.location3.partner_id = self.shipping_partner + with Form(self.env["sale.order"]) as so_form: + so_form.partner_id = self.partner + so = so_form.save() + self.assertEqual(so.fsm_location_id, self.location1) - SO partner is not an FSM location defined, but location1 is linked to - the partner itself => expect location 1 (because of ordering) - """ - self.partner.fsm_location = False - self.location1.partner_id = self.partner - self.location2.partner_id = self.shipping_partner - self.location3.partner_id = self.commercial_partner - with Form(self.env["sale.order"]) as so_form: - so_form.partner_id = self.partner - so = so_form.save() - self.assertEqual(so.fsm_location_id, self.location1) - def test_03_autofill_so_fsm_location(self): - """Check location autofill from SO partner +def test_02_autofill_so_fsm_location(self): + """Check location autofill from SO partner - SO partner is not an FSM location defined, but location1 is linked to - its shipping partner => expect location 1 (because of ordering) - """ - self.partner.fsm_location = False - self.location1.partner_id = self.shipping_partner - self.location2.partner_id = self.commercial_partner - self.location3.partner_id = self.partner - with Form(self.env["sale.order"]) as so_form: - so_form.partner_id = self.partner - so = so_form.save() - self.assertEqual(so.fsm_location_id, self.location1) + SO partner is not an FSM location defined, but location1 is linked to + the partner itself => expect location 1 (because of ordering) + """ + self.partner.fsm_location = False + self.location1.partner_id = self.partner + self.location2.partner_id = self.shipping_partner + self.location3.partner_id = self.commercial_partner + with Form(self.env["sale.order"]) as so_form: + so_form.partner_id = self.partner + so = so_form.save() + self.assertEqual(so.fsm_location_id, self.location1) + + +def test_03_autofill_so_fsm_location(self): + """Check location autofill from SO partner + + SO partner is not an FSM location defined, but location1 is linked to + its shipping partner => expect location 1 (because of ordering) + """ + self.partner.fsm_location = False + self.location1.partner_id = self.shipping_partner + self.location2.partner_id = self.commercial_partner + self.location3.partner_id = self.partner + with Form(self.env["sale.order"]) as so_form: + so_form.partner_id = self.partner + so = so_form.save() + self.assertEqual(so.fsm_location_id, self.location1)