예제 #1
0
     continue
 res = raw_input('Press RET to restore status ..')
 if action[0] == 'P':
     print ">> Draft"
     clodoo.upd_payments_2_draft(oerp, rec_ids, ctx)
 elif action[0] == 'U':
     print ">> Posted"
     clodoo.upd_payments_2_posted(oerp, rec_ids, ctx)
 else:
     for inv_id in rec_ids:
         try:
             oerp.execute('account.invoice', "button_reset_taxes", [inv_id])
         except BaseException:
             pass
     print ">> Posted"
     clodoo.upd_invoices_2_posted(oerp, move_dict, ctx)
     if action[0] != 'V':
         print ">> Reconcile "
         for inv_id in rec_ids:
             reconciles = reconcile_dict[inv_id]
             if len(reconciles):
                 try:
                     cur_reconciles, cur_reconcile_dict = \
                         clodoo.refresh_reconcile_from_inv(oerp,
                                                           inv_id,
                                                           reconciles,
                                                           ctx)
                     clodoo.reconcile_invoices(oerp, cur_reconcile_dict,
                                               ctx)
                 except BaseException:
                     print "**** Warning invoice %d ****" % inv_id
예제 #2
0
def upd_invoice(ctx, tmp_num=False, cur_num=False, cur_dt=False):
    if not tmp_num and not cur_num:
        print ">> Missing parameters"
        return
    company_id = ctx['company_id']
    tmp_inv_id = False
    cur_inv_id = False
    if tmp_num:
        inv = oerp.search('account.invoice',
                          [('company_id', '=', company_id),
                           ('internal_number', '=', tmp_num)])
        if len(inv):
            tmp_inv_id = inv[0]
        else:
            return
        print ">>> tmp_inv=%d" % tmp_inv_id
    if cur_num:
        inv = oerp.search('account.invoice',
                          [('company_id', '=', company_id),
                           ('internal_number', '=', cur_num)])
        if len(inv):
            cur_inv_id = inv[0]
        else:
            return
        print ">>> cur_inv=%d" % cur_inv_id
    if not tmp_inv_id and not cur_inv_id:
        print ">> No invoice found ", tmp_num, cur_num
        return
    if tmp_inv_id:
        rec_ids = [tmp_inv_id]
        tag = tmp_num
    else:
        rec_ids = [cur_inv_id]
        tag = cur_num
    print ">> Get info tmp invoice %s (%s)" % (str(rec_ids), tag)
    reconcile_dict, move_dict = clodoo.get_reconcile_from_invoices(
        oerp, rec_ids, ctx)
    print ">> Unreconcile tmp invoice"
    clodoo.unreconcile_invoices(oerp, reconcile_dict, ctx)
    if tmp_inv_id and cur_inv_id and tmp_inv_id != cur_inv_id:
        print ">> Delete tmp invoice"
        try:
            oerp.write('account.invoice', tmp_inv_id, {
                'state': 'cancel',
                'number': '',
                'internal_number': ''
            })
            pass
        except BaseException:
            pass
        oerp.unlink('account.invoice', [tmp_inv_id])
    if cur_inv_id:
        rec_ids = [cur_inv_id]
        tag = cur_num
    else:
        rec_ids = [tmp_inv_id]
        tag = tmp_num
    if cur_inv_id and tmp_inv_id and tmp_inv_id != cur_inv_id:
        print ">> Get info cur invoice %s (%s)" % (str(rec_ids), tag)
        reconcile_dict, move_dict = clodoo.get_reconcile_from_invoices(
            oerp, rec_ids, ctx)
        print ">> Unreconcile cur invoices"
        clodoo.unreconcile_invoices(oerp, reconcile_dict, ctx)
    print ">> Draft cur invoices"
    clodoo.upd_invoices_2_draft(oerp, move_dict, ctx)
    inv_id = rec_ids[0]
    vals = {}
    if cur_dt:
        dt_s = str(cur_dt)
        period_ids = oerp.execute('account.period', 'find', dt_s)
        period_id = period_ids and period_ids[0] or False
        vals['date_invoice'] = dt_s
        vals['registration_date'] = dt_s
        vals['period_id'] = period_id
    if cur_num and tmp_num and tmp_num != cur_num:
        vals['internal_number'] = tmp_num
    if len(vals):
        print ">> Update values ", inv_id, vals
        oerp.write('account.invoice', inv_id, vals)
    print ">> Posted"
    clodoo.upd_invoices_2_posted(oerp, move_dict, ctx)
    reconciles = reconcile_dict[inv_id]
    if len(reconciles):
        print ">> Reconcile "
        cur_reconciles, cur_reconcile_dict = clodoo.refresh_reconcile_from_inv(
            oerp, inv_id, reconciles, ctx)
        clodoo.reconcile_invoices(oerp, cur_reconcile_dict, ctx)
    return
예제 #3
0
left_ctx['db_name'] = left_ctx['left_db_name']
left_ctx['conf_fn'] = left_ctx['left_conf_fn']
right_ctx['db_name'] = right_ctx['right_db_name']
right_ctx['conf_fn'] = right_ctx['right_conf_fn']
uid, right_ctx = clodoo.oerp_set_env(ctx=right_ctx)
uid, left_ctx = clodoo.oerp_set_env(ctx=left_ctx)
transodoo.read_stored_dict(right_ctx)
left_ctx['mindroot'] = right_ctx['mindroot']

for model in ('res.country.state', 'res.city', 'res.partner.bank'):
    copy_table(left_ctx, right_ctx, model)
for model in ('account.fiscal.position', 'res.partner'):
    copy_table(left_ctx, right_ctx, model)
for model in ('res.company', 'account.account.type', 'account.account'):
    copy_table(left_ctx, right_ctx, model)
for model in ('product.uom.categ', 'product.uom', 'product.category'):
    copy_table(left_ctx, right_ctx, model)
for model in (
        'product.template',
        'product.product',
):
    copy_table(left_ctx, right_ctx, model)
for model in ('account.tax', 'account.journal'):
    copy_table(left_ctx, right_ctx, model)
for model in ('account.invoice', 'account.invoice.line'):
    copy_table(left_ctx, right_ctx, model)

raw_input('Press RET to validate invoices ...')
ids = clodoo.searchL8(left_ctx, 'account.invoice', [('state', '=', 'draft')])
clodoo.upd_invoices_2_posted(ids, left_ctx)