From 4d73bffaffeab591a8f6056a3c9fb2ef3303ca72 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 26 Aug 2015 22:01:45 +0700 Subject: [PATCH 1/4] migrate --- netforce_clinic/migrations/__init__.py | 2 +- netforce_clinic/migrations/conv_bal.py | 16 +++++++++++----- netforce_clinic/migrations/repost_invoice.py | 5 +++++ netforce_clinic/models/hd_case.py | 5 +++++ netforce_clinic/models/shop.py | 4 ++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index bde4b2c..d628d8f 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -1,3 +1,3 @@ -from . import clinic_setting +#from . import clinic_setting #from . import conv_bal from . import repost_invoice diff --git a/netforce_clinic/migrations/conv_bal.py b/netforce_clinic/migrations/conv_bal.py index 64cf82d..869303e 100644 --- a/netforce_clinic/migrations/conv_bal.py +++ b/netforce_clinic/migrations/conv_bal.py @@ -22,12 +22,18 @@ class Migration(migration.Migration): get_model("conv.bal").import_acc_file([cbv.id],context={}) get_model("conv.bal").import_acc([cbv.id],context={}) - cbv.write({ - 'date_fmt': '%d/%m/%Y', - 'file': 'ar.csv', - }) print("import sale file (step 2)running ...") - get_model("conv.bal").import_sale_file([cbv.id],context={}) + del_ids=get_model("conv.sale.invoice").search([["conv_id","=",cbv.id]]) + get_model('conv.sale.invoice').delete(del_ids) + for ar_file in ['ar_fee','ar_epo','ar_srv','ar_other']: + cbv.write({ + 'date_fmt': '%d/%m/%Y', + 'file': '%s.csv'%(ar_file), + }) + ctx={ + 'is_append': True, + } + get_model("conv.bal").import_sale_file([cbv.id],context=ctx) get_model("conv.bal").import_sale([cbv.id],context={}) print("import purch file (step 3) running ...") diff --git a/netforce_clinic/migrations/repost_invoice.py b/netforce_clinic/migrations/repost_invoice.py index c308fae..0822628 100644 --- a/netforce_clinic/migrations/repost_invoice.py +++ b/netforce_clinic/migrations/repost_invoice.py @@ -29,12 +29,17 @@ class Migration(migration.Migration): 'state': 'draft', }) ids=list(hdcase_ids) + for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]): + seq.write({ + 'running': [('delete_all'),], + }) for hdcase in get_model('clinic.hd.case').browse(ids): print('remake_invoice ---> ', hdcase.number) ctx={ 'is_migrate': True, } hdcase.make_invoices(context=ctx) + hdcase.post_invoices() print("Done!") return True diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 0f90687..9546245 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -559,6 +559,7 @@ class HDCase(Model): context={ 'type': 'in', 'branch_id': obj.branch_id.id, + 'date': obj.date, } payment_id=get_model("account.payment").create(vals,context=context) obj.write({ @@ -714,6 +715,7 @@ class HDCase(Model): 'account_id':account_receiveable_id , 'lines':lines, } + context['date']=obj.date inv_id=get_model("account.invoice").create(vals,context=context) inv=get_model("account.invoice").browse(inv_id) @@ -726,6 +728,7 @@ class HDCase(Model): invoices=group_invoice_line(normb_lines) for account_receiveable_id, lines in invoices.items(): + context['date']=obj.date number=self._get_number_invoice_noclaim(context=context) vals={ 'number': number, @@ -855,6 +858,7 @@ class HDCase(Model): context={ 'pick_type': 'out', 'journal_id': pick_vals['journal_id'], + 'date': obj.date } pick_id=picking_obj.create(pick_vals,context=context) pick=picking_obj.browse(pick_id) @@ -878,6 +882,7 @@ class HDCase(Model): } if obj.number=='/': context['branch_id']=obj.branch_id.id + context['date']=obj.date number=self._get_number(context=context) vals['number']=number diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index afc4a26..bd57718 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -345,6 +345,7 @@ class Shop(Model): return invoice_vals invoices=group_invoice_line(inv_lines) for account_receiveable_id, lines in invoices.items(): + context['date']=obj.date number=self._get_credit_number(context=context), vals={ 'number': number, @@ -445,6 +446,7 @@ class Shop(Model): 'pick_type': 'out', 'journal_id': pick_vals['journal_id'], 'branch_id': obj.branch_id.id, + 'date': obj.date, } pick_id=picking_obj.create(pick_vals,context=context) pick=picking_obj.browse(pick_id) @@ -463,6 +465,7 @@ class Shop(Model): raise Exception("No Income Account") company_id=get_active_company() context['branch_id']=obj.branch_id.id + context['date']=obj.date number=self._get_cash_number(context=context), vals={ 'number': number, @@ -500,6 +503,7 @@ class Shop(Model): context={ 'type': 'in', 'branch_id': obj.branch_id.id, + 'date': obj.date, } payment_id=get_model("account.payment").create(vals,context=context) payment=get_model('account.payment').browse(payment_id) From 38fad33d43e0bde41ca44ed3081ac434e6183d63 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 26 Aug 2015 22:56:02 +0700 Subject: [PATCH 2/4] delete invoice paid --- netforce_clinic/migrations/repost_invoice.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/migrations/repost_invoice.py b/netforce_clinic/migrations/repost_invoice.py index 0822628..90891e8 100644 --- a/netforce_clinic/migrations/repost_invoice.py +++ b/netforce_clinic/migrations/repost_invoice.py @@ -18,7 +18,17 @@ class Migration(migration.Migration): for hdcase in get_model('clinic.hd.case').search_browse(dom): reset=False for inv in hdcase.invoices: - if inv.state=='waiting_payment': + if inv.state=='paid': + inv.write({ + 'state': 'waiting_payment', + }) + for pm_line in get_model("account.payment.line").search_browse([['invoice_id','=',inv.id]]): + pm=pm_line.payment_id + pm.to_draft() + pm.delete() + inv.to_draft() + inv.delete() + elif inv.state=='waiting_payment': inv.to_draft() inv.delete() reset=True @@ -29,10 +39,10 @@ class Migration(migration.Migration): 'state': 'draft', }) ids=list(hdcase_ids) + for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]): - seq.write({ - 'running': [('delete_all'),], - }) + for run in seq.running: + run.delete() for hdcase in get_model('clinic.hd.case').browse(ids): print('remake_invoice ---> ', hdcase.number) ctx={ From 96b089ec8a8d54ec578950373c563fbcbbc75e86 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 27 Aug 2015 08:03:34 +0700 Subject: [PATCH 3/4] migrate --- netforce_clinic/migrations/repost_invoice.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netforce_clinic/migrations/repost_invoice.py b/netforce_clinic/migrations/repost_invoice.py index 90891e8..94fd6d9 100644 --- a/netforce_clinic/migrations/repost_invoice.py +++ b/netforce_clinic/migrations/repost_invoice.py @@ -43,7 +43,12 @@ class Migration(migration.Migration): for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]): for run in seq.running: run.delete() - for hdcase in get_model('clinic.hd.case').browse(ids): + dom2=[ + ['date','>=','2015-07-01'], + ['state','=','waiting_payment'], + ] + #for hdcase in get_model('clinic.hd.case').browse(ids): + for hdcase in get_model('clinic.hd.case').search_browse(dom2): print('remake_invoice ---> ', hdcase.number) ctx={ 'is_migrate': True, From 4870c1ab2b7232097e487e470fd2ca7a6826c195 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 27 Aug 2015 08:51:30 +0700 Subject: [PATCH 4/4] migrate #2 --- netforce_clinic/migrations/__init__.py | 4 ++-- netforce_clinic/models/conv_bal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index d628d8f..4647e40 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -1,3 +1,3 @@ #from . import clinic_setting -#from . import conv_bal -from . import repost_invoice +from . import conv_bal +#from . import repost_invoice diff --git a/netforce_clinic/models/conv_bal.py b/netforce_clinic/models/conv_bal.py index 6023d6e..0f12683 100644 --- a/netforce_clinic/models/conv_bal.py +++ b/netforce_clinic/models/conv_bal.py @@ -54,7 +54,7 @@ class ConvBal(Model): else: get_model("account.invoice").create(vals) - def import_sale_file(self,ids,context): + def _import_sale_file(self,ids,context): obj=self.browse(ids)[0] path=get_file_path(obj.file) data=open(path).read()