clinic/netforce_clinic/models/account_move_line.py

30 lines
1008 B
Python
Raw Normal View History

2015-08-13 06:27:46 +00:00
from netforce.model import Model, get_model
2015-08-11 05:13:04 +00:00
class AccountMoveLine(Model):
_inherit="account.move.line"
2015-08-13 06:27:46 +00:00
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})
2015-08-11 05:13:04 +00:00
AccountMoveLine.register()