diff --git a/purchase_usability/__manifest__.py b/purchase_usability/__manifest__.py index e81aec9..84d197c 100644 --- a/purchase_usability/__manifest__.py +++ b/purchase_usability/__manifest__.py @@ -14,6 +14,7 @@ 'data': [ 'views/purchase_order.xml', 'views/purchase_report.xml', + 'views/account_move.xml', ], 'installable': True, } diff --git a/purchase_usability/models/__init__.py b/purchase_usability/models/__init__.py index c5a3b0e..6e2dfa0 100644 --- a/purchase_usability/models/__init__.py +++ b/purchase_usability/models/__init__.py @@ -1,3 +1,4 @@ from . import purchase_order from . import product_template from . import res_partner +from . import account_move diff --git a/purchase_usability/models/account_move.py b/purchase_usability/models/account_move.py new file mode 100644 index 0000000..55cc1c8 --- /dev/null +++ b/purchase_usability/models/account_move.py @@ -0,0 +1,21 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + def delete_lines_qty_zero(self): + # When a user pulls a PO from a supplier invoice, it creates + # all lines including lines that haven't been received. It can be time-consuming + # to delete all these lines with qty = 0 + self.ensure_one() + lines = self.env['account.move.line'].search([ + ('move_id', '=', self.id), + ('quantity', '=', 0), + ('display_type', '=', False), + ]) + lines.unlink() diff --git a/purchase_usability/views/account_move.xml b/purchase_usability/views/account_move.xml new file mode 100644 index 0000000..e0ff671 --- /dev/null +++ b/purchase_usability/views/account_move.xml @@ -0,0 +1,22 @@ + + + + + + + + account.move + + + + + + + +