Reprocess purchase when deleting invoice lines
issue6131 review34571002
This commit is contained in:
1 parent
8f0bc4c623
commit
e7bc5cfcff
2 files changed
+36
No files matched your search
+13
@@ -151,3 +151,16 @@ class InvoiceLine:
|
||||
models = super(InvoiceLine, cls)._get_origin()
|
||||
models.append('purchase.line')
|
||||
return models
|
||||
|
||||
@classmethod
|
||||
def delete(cls, lines):
|
||||
pool = Pool()
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
with Transaction().set_context(_check_access=False):
|
||||
lines = cls.browse(lines)
|
||||
invoices = (l.invoice for l in lines
|
||||
if l.type == 'line' and l.invoice)
|
||||
purchases = [p for i in invoices for p in i.purchases]
|
||||
super(InvoiceLine, cls).delete(lines)
|
||||
with Transaction().set_context(_check_access=False):
|
||||
Purchase.process(purchases)
|
||||
@@ -573,3 +573,26 @@ linked to invoices::
|
||||
5.0
|
||||
>>> stock_move.state
|
||||
u'done'
|
||||
|
||||
Deleting a line from a invoice should recreate it::
|
||||
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = customer
|
||||
>>> line = purchase.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 10.0
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.click('process')
|
||||
>>> invoice, = purchase.invoices
|
||||
>>> config.user = account_user.id
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> invoice.lines.remove(invoice_line)
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.click('post')
|
||||
>>> config.user = purchase_user.id
|
||||
>>> purchase.reload()
|
||||
>>> new_invoice, = purchase.invoices
|
||||
>>> new_invoice.number
|
||||
>>> len(new_invoice.lines)
|
||||
1
|
||||
Reference in new issue
Block a user