[FIX] account, stock_account: clean anglo-saxon lines

- Configure a Product Category Automated + FIFO
- Create a product in this category
- Create a PO for 10 units, receive the units, bill the PO and pay
- Sell 1 unit of the product and deliver it
- Create an invoice for the order
- Without paying the invoice, create a credit note with the option
  'Full refund and draft invoice'
- Post new invoice

The anglo-saxon lines are counted twice.

This happens because the lines already exist in the newly created draft
invoice.

For the sake of simplicity of the fix, we clean-up the invoice after
creation.

opw-2300536

closes odoo/odoo#55158

X-original-commit: 02d857b8aa75962f535ab4cd69ff8e2a6ef3fb48
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-07-29 15:20:02 +00:00
parent 7d010ee8a5
commit 5eea4c014a
3 changed files with 17 additions and 0 deletions
@@ -71,6 +71,9 @@ class AccountMoveReversal(models.TransientModel):
'auto_post': True if reverse_date > fields.Date.context_today(self) else False,
}
def _reverse_moves_post_hook(self, moves):
return
def reverse_moves(self):
self.ensure_one()
moves = self.move_ids
@@ -100,6 +103,8 @@ class AccountMoveReversal(models.TransientModel):
return
self.new_move_ids = new_moves
if new_moves:
self._reverse_moves_post_hook(new_moves)
# Create action.
action = {
+1
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_move_reversal
from . import stock_quantity_history
from . import stock_picking_return
from . import stock_valuation_layer_revaluation
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from odoo import models
class AccountMoveReversal(models.TransientModel):
_inherit = "account.move.reversal"
def _reverse_moves_post_hook(self, moves):
if self.refund_method == "modify":
moves.mapped("line_ids").filtered(lambda line: line.is_anglo_saxon_line).unlink()
return super()._reverse_moves_post_hook(moves)