fix
parent
93ac2c222e
commit
57c5425e30
|
@ -10,7 +10,6 @@ class ConvBal(Model):
|
||||||
|
|
||||||
def create_sale_invoices(self,ids,context={}):
|
def create_sale_invoices(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
settings=get_model("settings").browse(1)
|
|
||||||
desc="Conversion balance %s"%obj.date
|
desc="Conversion balance %s"%obj.date
|
||||||
for inv in obj.sale_invoices:
|
for inv in obj.sale_invoices:
|
||||||
vals={
|
vals={
|
||||||
|
@ -44,12 +43,12 @@ class ConvBal(Model):
|
||||||
})
|
})
|
||||||
#if abs(inv2.amount_total)-abs(inv.amount_due)>0.001: # XXX
|
#if abs(inv2.amount_total)-abs(inv.amount_due)>0.001: # XXX
|
||||||
#raise Exception("Failed to update invoice %s: different amount"%inv.number)
|
#raise Exception("Failed to update invoice %s: different amount"%inv.number)
|
||||||
#if inv2.state=="draft":
|
if inv2.state=="draft":
|
||||||
#raise Exception("Failed to update invoice %s: invalid state"%inv.number)
|
raise Exception("Failed to update invoice %s: invalid state"%inv.number)
|
||||||
#inv2.write({
|
inv2.write({
|
||||||
#"move_id": obj.move_id.id,
|
"move_id": obj.move_id.id,
|
||||||
#"reconcile_move_line_id": inv.move_line_id.id,
|
"reconcile_move_line_id": inv.move_line_id.id,
|
||||||
#})
|
})
|
||||||
else:
|
else:
|
||||||
get_model("account.invoice").create(vals)
|
get_model("account.invoice").create(vals)
|
||||||
|
|
||||||
|
@ -63,10 +62,10 @@ class ConvBal(Model):
|
||||||
del_ids=get_model("conv.sale.invoice").search([["conv_id","=",obj.id]])
|
del_ids=get_model("conv.sale.invoice").search([["conv_id","=",obj.id]])
|
||||||
get_model("conv.sale.invoice").delete(del_ids)
|
get_model("conv.sale.invoice").delete(del_ids)
|
||||||
for row in rd:
|
for row in rd:
|
||||||
print("row",row)
|
#print("row",row)
|
||||||
row+="," #XXX append blank column for Amount Cur
|
row+="," #XXX append blank column for Amount Cur
|
||||||
line=dict(zip(headers,row))
|
line=dict(zip(headers,row))
|
||||||
print("line",line)
|
#print("line",line)
|
||||||
if not line.get("Number"):
|
if not line.get("Number"):
|
||||||
continue
|
continue
|
||||||
number=line["Number"].strip()
|
number=line["Number"].strip()
|
||||||
|
@ -84,9 +83,16 @@ class ConvBal(Model):
|
||||||
acc_code=line["Account"].strip()
|
acc_code=line["Account"].strip()
|
||||||
amount_cur=float(line["Amount Cur"].strip().replace(",","") or 0)
|
amount_cur=float(line["Amount Cur"].strip().replace(",","") or 0)
|
||||||
acc_codes=acc_code.split(",")
|
acc_codes=acc_code.split(",")
|
||||||
|
amts=[] #XXX
|
||||||
|
for m in line['Memo'].split(","):
|
||||||
|
amt=m.split(":")[1]
|
||||||
|
amt=amt.strip()
|
||||||
|
if amt:
|
||||||
|
amt=float(amt)
|
||||||
|
amts.append(amt)
|
||||||
if len(acc_codes) > 1:
|
if len(acc_codes) > 1:
|
||||||
count=0
|
count=0
|
||||||
amts=[m.split(":")[1] for m in line['Memo'].split(",")]
|
print("*"*80)
|
||||||
for acc_code in acc_codes:
|
for acc_code in acc_codes:
|
||||||
acc_code=acc_code.strip()
|
acc_code=acc_code.strip()
|
||||||
res=get_model("account.account").search([["code","=",acc_code]])
|
res=get_model("account.account").search([["code","=",acc_code]])
|
||||||
|
@ -94,6 +100,7 @@ class ConvBal(Model):
|
||||||
raise Exception("Account code not found: %s"%acc_code)
|
raise Exception("Account code not found: %s"%acc_code)
|
||||||
acc_id=res[0]
|
acc_id=res[0]
|
||||||
amount_due=amts[count]
|
amount_due=amts[count]
|
||||||
|
print(acc_code, acc_id, amount_due)
|
||||||
vals={
|
vals={
|
||||||
"conv_id": obj.id,
|
"conv_id": obj.id,
|
||||||
"number": number,
|
"number": number,
|
||||||
|
@ -103,10 +110,31 @@ class ConvBal(Model):
|
||||||
"due_date": due_date,
|
"due_date": due_date,
|
||||||
"amount_due": amount_due,
|
"amount_due": amount_due,
|
||||||
"account_id": acc_id,
|
"account_id": acc_id,
|
||||||
"amount_cur": amount_cur,
|
"amount_cur": amount_due, #XXX
|
||||||
}
|
}
|
||||||
get_model("conv.sale.invoice").create(vals)
|
get_model("conv.sale.invoice").create(vals)
|
||||||
count+=1
|
count+=1
|
||||||
|
print("*"*80)
|
||||||
|
elif len(amts) >= 1 and len(acc_codes)<=1:
|
||||||
|
acc_code=acc_codes[0].strip()
|
||||||
|
res=get_model("account.account").search([["code","=",acc_code]])
|
||||||
|
if not res:
|
||||||
|
raise Exception("Account code not found: %s"%acc_code)
|
||||||
|
acc_id=res[0]
|
||||||
|
for amt in amts:
|
||||||
|
amount_due=amt
|
||||||
|
vals={
|
||||||
|
"conv_id": obj.id,
|
||||||
|
"number": number,
|
||||||
|
"ref": ref,
|
||||||
|
"contact_id": contact_id,
|
||||||
|
"date": date,
|
||||||
|
"due_date": due_date,
|
||||||
|
"amount_due": amount_due,
|
||||||
|
"account_id": acc_id,
|
||||||
|
"amount_cur": amount_due, #XXX
|
||||||
|
}
|
||||||
|
get_model("conv.sale.invoice").create(vals)
|
||||||
else:
|
else:
|
||||||
res=get_model("account.account").search([["code","=",acc_code]])
|
res=get_model("account.account").search([["code","=",acc_code]])
|
||||||
if not res:
|
if not res:
|
||||||
|
|
Loading…
Reference in New Issue