diff --git a/complaint.py b/complaint.py index deaca12cae..a48b1af178 100644 --- a/complaint.py +++ b/complaint.py @@ -150,13 +150,13 @@ class Complaint(Workflow, ModelSQL, ModelView): 'account.invoice': [ ('party', '=', Eval('customer')), ('company', '=', Eval('company')), - ('type', '=', 'out_invoice'), + ('type', '=', 'out'), ('state', 'in', ['posted', 'paid']), ], 'account.invoice.line': [ ('invoice.party', '=', Eval('customer')), ('invoice.company', '=', Eval('company')), - ('invoice.type', '=', 'out_invoice'), + ('invoice.type', '=', 'out'), ('invoice.state', 'in', ['posted', 'paid']), ], } @@ -434,7 +434,7 @@ class Action(ModelSQL, ModelView): credit_line['origin'] = str(self.complaint) if isinstance(self.complaint.origin, Line): if self.quantity is not None: - lines_values[0]['quantity'] = self.quantity + lines_values[0]['quantity'] = -self.quantity if self.unit_price is not None: lines_values[0]['unit_price'] = self.unit_price values['lines'] = [('create', lines_values)] diff --git a/tests/scenario_sale_complaint.rst b/tests/scenario_sale_complaint.rst index 807fea27bc..119bbc6e27 100644 --- a/tests/scenario_sale_complaint.rst +++ b/tests/scenario_sale_complaint.rst @@ -186,11 +186,11 @@ Create a complaint to credit the invoice:: >>> action, = complaint.actions >>> credit_note = action.result >>> credit_note.type - u'out_credit_note' + u'out' >>> len(credit_note.lines) 2 >>> sum(l.quantity for l in credit_note.lines) - 5.0 + -5.0 Create a complaint to credit a invoice line:: @@ -209,7 +209,7 @@ Create a complaint to credit a invoice line:: >>> action, = complaint.actions >>> credit_note = action.result >>> credit_note.type - u'out_credit_note' + u'out' >>> credit_note_line, = credit_note.lines >>> credit_note_line.quantity - 1.0 + -1.0