File: test_product_template.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (26 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from odoo.tests.common import TransactionCase


class TestProductTemplate(TransactionCase):
    def test_name_search(self):
      partner = self.env['res.partner'].create({
        'name': 'Azure Interior',
      })

      seller = self.env['product.supplierinfo'].create({
        'partner_id': partner.id,
        'price': 12.0,
        'delay': 1,
        'product_code': 'VOB2a',
      })

      product_tmpl = self.env['product.template'].create({
        'name': 'Rubber Duck',
        'is_storable': True,
        'default_code': 'VOB2A',
        'seller_ids': [seller.id],
        'purchase_ok': True,
      })
      ns = self.env['product.template'].with_context(partner_id=partner.id).name_search('VOB2', [['purchase_ok', '=', True]])
      self.assertEqual(len(ns), 1, "name_search should have 1 item")
      self.assertEqual(ns[0][1], '[VOB2A] Rubber Duck', "name_search should return the expected result")