migration: remake invoice
parent
387e5a567a
commit
8f6eea82aa
|
@ -9,30 +9,32 @@ 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]]):
|
dom=[
|
||||||
prod=hdcase_line.product_id
|
['department_id','=',2],
|
||||||
if prod:
|
['date','>=','2015-08-18'],
|
||||||
hdcase_line.write({
|
['date','<=','2015-08-18'],
|
||||||
'description': prod.name,
|
]
|
||||||
})
|
hdcase_ids=set()
|
||||||
|
for hdcase in get_model('clinic.hd.case').search_browse(dom):
|
||||||
for hdcase in get_model('clinic.hd.case').search_browse([]):
|
reset=False
|
||||||
for inv in hdcase.invoices:
|
for inv in hdcase.invoices:
|
||||||
if inv.state=='waiting_payment':
|
if inv.state=='waiting_payment':
|
||||||
print('hdcase:repost ---> ', inv.number)
|
|
||||||
inv.to_draft()
|
inv.to_draft()
|
||||||
inv.write({
|
inv.delete()
|
||||||
'hdcase_reconcile': True,
|
reset=True
|
||||||
|
hdcase_ids.update({hdcase.id})
|
||||||
|
if reset:
|
||||||
|
for line in hdcase.lines:
|
||||||
|
line.write({
|
||||||
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
inv.post()
|
ids=list(hdcase_ids)
|
||||||
for shop in get_model('clinic.shop').search_browse([]):
|
for hdcase in get_model('clinic.hd.case').browse(ids):
|
||||||
for inv in shop.invoices:
|
print('remake_invoice ---> ', hdcase.number)
|
||||||
print('shop:repost ---> ', inv.number)
|
ctx={
|
||||||
inv.to_draft()
|
'is_migrate': True,
|
||||||
inv.write({
|
}
|
||||||
'hdcase_reconcile': True,
|
hdcase.make_invoices(context=ctx)
|
||||||
})
|
|
||||||
inv.post()
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -741,8 +741,8 @@ class HDCase(Model):
|
||||||
vals['lines']=lines
|
vals['lines']=lines
|
||||||
get_model("account.invoice").create(vals,context)
|
get_model("account.invoice").create(vals,context)
|
||||||
|
|
||||||
obj.make_pickings()
|
if not context.get('is_migrate'):
|
||||||
# prevent douplicate create invoice & picking
|
obj.make_pickings()
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
line.write({
|
line.write({
|
||||||
'state': 'done',
|
'state': 'done',
|
||||||
|
|
Loading…
Reference in New Issue