clinic/netforce_clinic/models/account_move_line.py

30 lines
1008 B
Python

from netforce.model import Model, get_model
class AccountMoveLine(Model):
_inherit="account.move.line"
def reconcile(self,ids,context={}):
print("MoveLine.reconcile",ids)
rec_id=get_model("account.reconcile").create({})
all_ids=ids[:]
for line in self.browse(ids):
rec=line.reconcile_id
if not rec:
continue
for rline in rec.lines:
all_ids.append(rline.id)
all_ids=list(set(all_ids))
acc_id=None
# skip to check account
hdcase_reconcile=context.get("hdcase_reconcile")
if not hdcase_reconcile:
for obj in self.browse(all_ids):
if not acc_id:
acc_id=obj.account_id.id
else:
if obj.account_id.id!=acc_id:
raise Exception("Can only reconcile transactions of same account")
self.write(all_ids,{"reconcile_id":rec_id})
AccountMoveLine.register()