Пример #1
0
    def test_on_record_unlink(self):
        """
        Unlink a record and check if the event is called
        """
        @on_record_unlink(model_names='res.partner')
        def event(session, model_name, record_id):
            if model_name == 'res.partner':
                self.recipient.record_id = record_id

        self.partner.unlink()
        self.assertEqual(self.recipient.record_id, self.partner.id)
        on_record_write.unsubscribe(event)
    def test_on_record_unlink(self):
        """
        Unlink a record and check if the event is called
        """
        @on_record_unlink(model_names='res.partner')
        def event(session, model_name, record_id):
            if model_name == 'res.partner':
                self.recipient.record_id = record_id

        self.partner.unlink()
        self.assertEqual(self.recipient.record_id, self.partner.id)
        on_record_write.unsubscribe(event)
Пример #3
0
    def test_on_record_write(self):
        """
        Write on a record and check if the event is called
        """
        @on_record_write(model_names='res.partner')
        def event(session, model_name, record_id, vals=None):
            self.recipient.record_id = record_id
            self.recipient.vals = vals

        vals = {'name': 'Lrrr', 'city': 'Omicron Persei 8'}
        self.partner.write(vals)
        self.assertEqual(self.recipient.record_id, self.partner.id)
        self.assertDictEqual(self.recipient.vals, vals)
        on_record_write.unsubscribe(event)
    def test_on_record_write(self):
        """
        Write on a record and check if the event is called
        """
        @on_record_write(model_names='res.partner')
        def event(session, model_name, record_id, vals=None):
            self.recipient.record_id = record_id
            self.recipient.vals = vals

        vals = {'name': 'Lrrr',
                'city': 'Omicron Persei 8'}
        self.partner.write(vals)
        self.assertEqual(self.recipient.record_id, self.partner.id)
        self.assertDictEqual(self.recipient.vals, vals)
        on_record_write.unsubscribe(event)
    def test_on_record_write(self):
        """
        Write on a record and check if the event is called
        """
        @on_record_write(model_names='res.partner')
        def event(session, model_name, record_id, fields=None):
            self.recipient.record_id = record_id
            self.recipient.fields = fields

        self.model.write(self.cr,
                         self.uid,
                         self.partner_id,
                         {'name': 'Lrrr',
                          'city': 'Omicron Persei 8'})
        self.assertEqual(self.recipient.record_id, self.partner_id)
        self.assertItemsEqual(self.recipient.fields, ['name', 'city'])
        on_record_write.unsubscribe(event)