migrate post invoice

conv_bal
watcha.h 2015-08-11 11:35:46 +07:00
parent e20d25029f
commit e26aa9de2c
6 changed files with 30 additions and 5 deletions

View File

@ -3,4 +3,8 @@
<field name="department_id" span="2"/> <field name="department_id" span="2"/>
<field name="patient_partner_id" span="2"/> <field name="patient_partner_id" span="2"/>
</field> </field>
<field name="memo" position="after">
<field name="account_id" span="2"/>
<field name="hdcase_reconcile" span="2"/>
</field>
</inherit> </inherit>

View File

@ -1,5 +1,7 @@
<inherit inherit="fin_settings"> <inherit inherit="fin_settings">
<!--
<field name="rounding_account_id" position="after"> <field name="rounding_account_id" position="after">
<field name="acc_prod_match"/> <field name="acc_prod_match"/>
</field> </field>
-->
</inherit> </inherit>

View File

@ -9,18 +9,31 @@ class Migration(migration.Migration):
def migrate(self): def migrate(self):
set_active_user(1) set_active_user(1)
set_active_company(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 hdcase in get_model('clinic.hd.case').search_browse([]):
for inv in hdcase.invoices: for inv in hdcase.invoices:
if inv.state=='waiting_payment': if inv.state=='waiting_payment':
print('repost ---> ', inv.number) print('hdcase:repost ---> ', inv.number)
inv.to_draft() inv.to_draft()
inv.write({
'hdcase_reconcile': True,
})
inv.post() inv.post()
print("Done!")
for shop in get_model('clinic.shop').search_browse([]): for shop in get_model('clinic.shop').search_browse([]):
for inv in shop.invoices: for inv in shop.invoices:
print('repost ---> ', inv.number) print('shop:repost ---> ', inv.number)
inv.to_draft() inv.to_draft()
inv.write({
'hdcase_reconcile': True,
})
inv.post() inv.post()
print("Done!")
return True return True
Migration.register() Migration.register()

View File

@ -9,6 +9,7 @@ class AccountInvoice(Model):
'department_id': fields.Many2One("clinic.department","Department",search=True), 'department_id': fields.Many2One("clinic.department","Department",search=True),
'patient_partner_id': fields.Many2One("partner","Patient",search=True), 'patient_partner_id': fields.Many2One("partner","Patient",search=True),
'hdcase_credit': fields.Boolean("HD Case Credit"), 'hdcase_credit': fields.Boolean("HD Case Credit"),
'hdcase_reconcile': fields.Boolean("HD Case Reconcile"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -240,13 +241,16 @@ class AccountInvoice(Model):
line["credit"]=-amt line["credit"]=-amt
is_match=False is_match=False
if settings.acc_prod_match and obj.type=='out': if obj.hdcase_reconcile and obj.type=='out':
print("#POST: clinic customize") print("#POST: clinic customize")
cst=get_model('clinic.setting').browse(1) cst=get_model('clinic.setting').browse(1)
prod_acc=cst.get_product_account prod_acc=cst.get_product_account
move_vals["lines"]=[] move_vals["lines"]=[]
for line in group_lines: for line in group_lines:
desc=line['description'] desc=line['description']
if not desc:
print("skip no description ", obj.number)
continue
ar_debit_id=None ar_debit_id=None
#ar_credit_id=None #ar_credit_id=None
# search from patient_type # search from patient_type
@ -266,7 +270,6 @@ class AccountInvoice(Model):
if ar_debit_id: if ar_debit_id:
break break
if not ar_debit_id: if not ar_debit_id:
import pdb; pdb.set_trace()
raise Exception("Missing AR Debit Account for product %s"%(desc), partner.id, partner.name) raise Exception("Missing AR Debit Account for product %s"%(desc), partner.id, partner.name)
line_vals={ line_vals={
"description": desc, "description": desc,

View File

@ -681,6 +681,7 @@ class HDCase(Model):
"lines": [], "lines": [],
"company_id": company_id, "company_id": company_id,
'hdcase_credit': False, 'hdcase_credit': False,
'hdcase_reconcile': True,
} }
vals["partner_id"]=partner.id vals["partner_id"]=partner.id
vals['lines']=rmb_lines vals['lines']=rmb_lines
@ -710,6 +711,7 @@ class HDCase(Model):
"company_id": company_id, "company_id": company_id,
'partner_id':partner.id, 'partner_id':partner.id,
'hdcase_credit': True, 'hdcase_credit': True,
'hdcase_reconcile': True,
} }
vals['lines']=normb_lines vals['lines']=normb_lines
if patient_partner: if patient_partner:

View File

@ -333,6 +333,7 @@ class Shop(Model):
"currency_id": currency_id, "currency_id": currency_id,
"company_id": company_id, "company_id": company_id,
'partner_id': partner.id, 'partner_id': partner.id,
'hdcase_reconcile': True,
"lines": [], "lines": [],
} }
track_id=obj.branch_id.track_id.id track_id=obj.branch_id.track_id.id