clinic/netforce_clinic/migrations/repost_invoice.py

40 lines
1.3 KiB
Python
Raw Normal View History

2015-08-10 14:38:19 +00:00
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
_name="clinic.repos.invoice"
_version="2.10.0"
def migrate(self):
set_active_user(1)
set_active_company(1)
2015-08-11 04:35:46 +00:00
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,
})
2015-08-10 14:38:19 +00:00
for hdcase in get_model('clinic.hd.case').search_browse([]):
for inv in hdcase.invoices:
if inv.state=='waiting_payment':
2015-08-11 04:35:46 +00:00
print('hdcase:repost ---> ', inv.number)
2015-08-10 14:38:19 +00:00
inv.to_draft()
2015-08-11 04:35:46 +00:00
inv.write({
'hdcase_reconcile': True,
})
2015-08-10 14:38:19 +00:00
inv.post()
for shop in get_model('clinic.shop').search_browse([]):
for inv in shop.invoices:
2015-08-11 04:35:46 +00:00
print('shop:repost ---> ', inv.number)
2015-08-10 14:38:19 +00:00
inv.to_draft()
2015-08-11 04:35:46 +00:00
inv.write({
'hdcase_reconcile': True,
})
2015-08-10 14:38:19 +00:00
inv.post()
2015-08-11 04:35:46 +00:00
print("Done!")
2015-08-10 14:38:19 +00:00
return True
Migration.register()