migrate post invoice
parent
e20d25029f
commit
e26aa9de2c
|
@ -3,4 +3,8 @@
|
|||
<field name="department_id" span="2"/>
|
||||
<field name="patient_partner_id" span="2"/>
|
||||
</field>
|
||||
<field name="memo" position="after">
|
||||
<field name="account_id" span="2"/>
|
||||
<field name="hdcase_reconcile" span="2"/>
|
||||
</field>
|
||||
</inherit>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<inherit inherit="fin_settings">
|
||||
<!--
|
||||
<field name="rounding_account_id" position="after">
|
||||
<field name="acc_prod_match"/>
|
||||
</field>
|
||||
-->
|
||||
</inherit>
|
||||
|
|
|
@ -9,18 +9,31 @@ class Migration(migration.Migration):
|
|||
def migrate(self):
|
||||
set_active_user(1)
|
||||
set_active_company(1)
|
||||
for hdcase_line in get_model('clinic.hd.case.line').search_browse([['description','=',None]]):
|
||||
prod=hdcase_line.product_id
|
||||
if prod:
|
||||
hdcase_line.write({
|
||||
'description': prod.name,
|
||||
})
|
||||
|
||||
for hdcase in get_model('clinic.hd.case').search_browse([]):
|
||||
for inv in hdcase.invoices:
|
||||
if inv.state=='waiting_payment':
|
||||
print('repost ---> ', inv.number)
|
||||
print('hdcase:repost ---> ', inv.number)
|
||||
inv.to_draft()
|
||||
inv.write({
|
||||
'hdcase_reconcile': True,
|
||||
})
|
||||
inv.post()
|
||||
print("Done!")
|
||||
for shop in get_model('clinic.shop').search_browse([]):
|
||||
for inv in shop.invoices:
|
||||
print('repost ---> ', inv.number)
|
||||
print('shop:repost ---> ', inv.number)
|
||||
inv.to_draft()
|
||||
inv.write({
|
||||
'hdcase_reconcile': True,
|
||||
})
|
||||
inv.post()
|
||||
print("Done!")
|
||||
return True
|
||||
|
||||
Migration.register()
|
||||
|
|
|
@ -9,6 +9,7 @@ class AccountInvoice(Model):
|
|||
'department_id': fields.Many2One("clinic.department","Department",search=True),
|
||||
'patient_partner_id': fields.Many2One("partner","Patient",search=True),
|
||||
'hdcase_credit': fields.Boolean("HD Case Credit"),
|
||||
'hdcase_reconcile': fields.Boolean("HD Case Reconcile"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -240,13 +241,16 @@ class AccountInvoice(Model):
|
|||
line["credit"]=-amt
|
||||
|
||||
is_match=False
|
||||
if settings.acc_prod_match and obj.type=='out':
|
||||
if obj.hdcase_reconcile and obj.type=='out':
|
||||
print("#POST: clinic customize")
|
||||
cst=get_model('clinic.setting').browse(1)
|
||||
prod_acc=cst.get_product_account
|
||||
move_vals["lines"]=[]
|
||||
for line in group_lines:
|
||||
desc=line['description']
|
||||
if not desc:
|
||||
print("skip no description ", obj.number)
|
||||
continue
|
||||
ar_debit_id=None
|
||||
#ar_credit_id=None
|
||||
# search from patient_type
|
||||
|
@ -266,7 +270,6 @@ class AccountInvoice(Model):
|
|||
if ar_debit_id:
|
||||
break
|
||||
if not ar_debit_id:
|
||||
import pdb; pdb.set_trace()
|
||||
raise Exception("Missing AR Debit Account for product %s"%(desc), partner.id, partner.name)
|
||||
line_vals={
|
||||
"description": desc,
|
||||
|
|
|
@ -681,6 +681,7 @@ class HDCase(Model):
|
|||
"lines": [],
|
||||
"company_id": company_id,
|
||||
'hdcase_credit': False,
|
||||
'hdcase_reconcile': True,
|
||||
}
|
||||
vals["partner_id"]=partner.id
|
||||
vals['lines']=rmb_lines
|
||||
|
@ -710,6 +711,7 @@ class HDCase(Model):
|
|||
"company_id": company_id,
|
||||
'partner_id':partner.id,
|
||||
'hdcase_credit': True,
|
||||
'hdcase_reconcile': True,
|
||||
}
|
||||
vals['lines']=normb_lines
|
||||
if patient_partner:
|
||||
|
|
|
@ -333,6 +333,7 @@ class Shop(Model):
|
|||
"currency_id": currency_id,
|
||||
"company_id": company_id,
|
||||
'partner_id': partner.id,
|
||||
'hdcase_reconcile': True,
|
||||
"lines": [],
|
||||
}
|
||||
track_id=obj.branch_id.track_id.id
|
||||
|
|
Loading…
Reference in New Issue