Ejemplo n.º 1
0
 def test_orderpoint_2(self):
     """As a user of Company A, check it is not possible to change the company on an existing
     orderpoint to Company B.
     """
     product = self.env['product.product'].create({
         'type': 'product',
         'name': 'shared product',
     })
     orderpoint = Form(self.env['stock.warehouse.orderpoint'].with_user(
         self.user_a))
     orderpoint.company_id = self.company_a
     orderpoint.warehouse_id = self.warehouse_a
     orderpoint.location_id = self.stock_location_a
     orderpoint.product_id = product
     orderpoint = orderpoint.save()
     self.assertEqual(orderpoint.company_id, self.company_a)
     with self.assertRaises(UserError):
         orderpoint.company_id = self.company_b.id
Ejemplo n.º 2
0
    def test_product_1(self):
        """ As an user of Company A, checks we can or cannot create new product
        depending of its `company_id`."""
        # Creates a new product with no company_id and set a responsible.
        # The product must be created as there is no company on the product.
        product_form = Form(self.env['product.template'].with_user(
            self.user_a))
        product_form.name = 'Paramite Pie'
        product_form.responsible_id = self.user_b
        product = product_form.save()

        self.assertEqual(product.company_id.id, False)
        self.assertEqual(product.responsible_id.id, self.user_b.id)

        # Creates a new product belong to Company A and set a responsible belong
        # to Company B. The product mustn't be created as the product and the
        # user don't belong of the same company.
        self.user_b.company_ids = [(6, 0, [self.company_b.id])]
        product_form = Form(self.env['product.template'].with_user(
            self.user_a))
        product_form.name = 'Meech Munchy'
        product_form.company_id = self.company_a
        product_form.responsible_id = self.user_b

        with self.assertRaises(UserError):
            # Raises an UserError for company incompatibility.
            product = product_form.save()

        # Creates a new product belong to Company A and set a responsible belong
        # to Company A & B (default B). The product must be created as the user
        # belongs to product's company.
        self.user_b.company_ids = [(6, 0,
                                    [self.company_a.id, self.company_b.id])]
        product_form = Form(self.env['product.template'].with_user(
            self.user_a))
        product_form.name = 'Scrab Cake'
        product_form.company_id = self.company_a
        product_form.responsible_id = self.user_b
        product = product_form.save()

        self.assertEqual(product.company_id.id, self.company_a.id)
        self.assertEqual(product.responsible_id.id, self.user_b.id)
Ejemplo n.º 3
0
 def test_putaway_1(self):
     """As a user of Company A, create a putaway rule with locations of Company A and set the
     company to Company B before saving. Check it is not possible.
     """
     stock_location_a_1 = self.env['stock.location'].with_user(
         self.user_a).create({
             'location_id': self.stock_location_a.id,
             'usage': 'internal',
             'name': 'A_1',
         })
     putaway_form = Form(self.env['stock.putaway.rule'])
     putaway_form.location_in_id = self.stock_location_a
     putaway_form.location_out_id = stock_location_a_1
     putaway_form.company_id = self.company_b
     with self.assertRaises(UserError):
         putaway_form.save()
Ejemplo n.º 4
0
 def test_orderpoint_1(self):
     """As a user of company A, create an orderpoint for company B. Check itsn't possible to
     use a warehouse of companny A"""
     product = self.env['product.product'].create({
         'type': 'product',
         'name': 'shared product',
     })
     orderpoint = Form(self.env['stock.warehouse.orderpoint'].with_user(
         self.user_a))
     orderpoint.company_id = self.company_b
     orderpoint.warehouse_id = self.warehouse_b
     orderpoint.location_id = self.stock_location_a
     orderpoint.product_id = product
     with self.assertRaises(UserError):
         orderpoint.save()
     orderpoint.location_id = self.stock_location_b
     orderpoint = orderpoint.save()
     self.assertEqual(orderpoint.company_id, self.company_b)