Esempio n. 1
0
def mk_date_range(ctx, company_id):
    model = 'date.range.type'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs.sort()
    for xref in xrefs:
        store_xref(ctx, xref, model, company_id)
    model = 'date.range'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs.sort()
    for xref in xrefs:
        store_xref(ctx, xref, model, company_id)
Esempio n. 2
0
def mk_sale_order(ctx, company_id):
    model = 'sale.order'
    model2 = 'sale.order.line'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs = xrefs + z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model2)
    xrefs.sort()
    parent_id = False
    for xref in xrefs:
        if len(xref) == 21:
            parent_id = store_xref(ctx, xref, model, company_id)
        else:
            store_xref(ctx, xref, model2, company_id,
                       parent_id=parent_id, parent_model=model)
Esempio n. 3
0
def mk_account_invoice(ctx, company_id):
    model = 'account.invoice'
    model2 = 'account.invoice.line'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs = xrefs + z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model2)
    xrefs.sort()
    parent_id = False
    for xref in xrefs:
        if len(xref) <= 19:
            parent_id = store_xref(ctx, xref, model, company_id)
        else:
            store_xref(ctx, xref, model2, company_id,
                       parent_id=parent_id, parent_model=model)
 def test_01(self, z0ctx):
     # sts = TEST_SUCCESS
     res = {}
     if not z0ctx['dry_run']:
         # Build Odoo enviroment
         self.root = Z0BUG.build_os_tree(z0ctx, [])
         remote = 'OCA'
         reponame = 'OCB'
         branch = '10.0'
         odoo_path = os.path.join(self.root, branch)
         Z0testOdoo.git_clone(remote, reponame, branch, odoo_path)
         sys.path.append(odoo_path)
         from z0bug_odoo import z0bug_odoo_lib
         res = z0bug_odoo_lib.Z0bugOdoo().get_test_values(
             'res.partner', 'z0bug.res_partner_1')
     sts = self.Z.test_result(z0ctx, 'get_test_values()', bool(res), True)
     TEST = {
         'customer': 'True',
         'name': 'Prima Distribuzione S.p.A.',
         'street': 'Via I Maggio, 11',
         'zip': '20022',
         'city': 'Castano Primo',
         'email': '*****@*****.**',
         'website': 'www.prima-distribuzione.it',
         'phone': '+39 0255582285',
         'vat': 'IT00115719999'
     }
     for nm in TEST:
         sts += self.Z.test_result(z0ctx, 'partner.%s' % nm, res.get(nm),
                                   TEST[nm])
     return sts
Esempio n. 5
0
def store_xref(ctx, xref, model, company_id,
               parent_id=None, parent_model=None):
    if parent_id and parent_model:
        print('%s->%s %s' % (parent_model, model, xref))
        xid = False
    else:
        xid = env_ref(ctx, xref)
        print(model, xref, xid)
    if ctx['dry_run']:
        return
    if not xid or ctx['force_test_values']:
        vals = unicodes(
            z0bug_odoo_lib.Z0bugOdoo().get_test_values(model, xref))
        vals, parent_name = bind_fields(ctx, model, vals, company_id,
                                        parent_id=parent_id,
                                        parent_model=parent_model)
        if xid:
            write_diff(ctx, model, xid, vals)
        else:
            if vals.get('id') and isinstance(vals['id'], int):
                xid = vals['id']
            else:
                xid = get_domain_field(ctx, model, vals, company_id,
                                       parent_id=parent_id,
                                       parent_model=parent_model)
            if xid:
                write_diff(ctx, model, xid, vals)
            else:
                if 'id' in vals:
                    del vals['id']
                xid = clodoo.createL8(ctx, model, vals)
            if not parent_id or not parent_model:
                add_xref(ctx, xref, model, xid)
    return xid
Esempio n. 6
0
def mk_partner(ctx, company_id):
    model = 'res.partner'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs.sort()
    parent_id = False
    for xref in xrefs:
        if len(xref) <= 20 or xref == 'z0bug.partner_mycompany':
            parent_id = store_xref(ctx, xref, model, company_id)
        else:
            store_xref(ctx, xref, model, company_id, parent_id=parent_id)
Esempio n. 7
0
def mk_payment(ctx, company_id):
    model = 'account.payment.term'
    model2 = 'account.payment.term.line'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs = xrefs + z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model2)
    xrefs.sort()
    parent_id = False
    for xref in xrefs:
        if len(xref) == 15:
            parent_id = store_xref(ctx, xref, model, company_id)
            seq = 10
            for id in clodoo.searchL8(
                    ctx, model2, [('payment_id', '=', parent_id)],
                    order='sequence,id'):
                clodoo.writeL8(ctx, model2, id, {'sequence': seq})
                seq += 10
        else:
            store_xref(ctx, xref, model2, company_id,
                       parent_id=parent_id, parent_model=model)
Esempio n. 8
0
def mk_account_account(ctx, company_id):
    model = 'account.account'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs.sort()
    for xref in xrefs:
        # Prima i mastri
        if len(xref) == 12:
            store_xref(ctx, xref, model, company_id)
    for xref in xrefs:
        # poi i capoconti
        if len(xref) == 13:
            store_xref(ctx, xref, model, company_id)
    for xref in xrefs:
        # infine i sottoconti
        if len(xref) > 13:
            store_xref(ctx, xref, model, company_id)
Esempio n. 9
0
def mk_fiscal_position(ctx, company_id):
    model = 'account.fiscal.position'
    xrefs = z0bug_odoo_lib.Z0bugOdoo().get_test_xrefs(model)
    xrefs.sort()
    for xref in xrefs:
        store_xref(ctx, xref, model, company_id)