purchase_usability: up-port button "Delete lines qty=0" from v10
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
'data': [
|
||||
'views/purchase_order.xml',
|
||||
'views/purchase_report.xml',
|
||||
'views/account_move.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from . import purchase_order
|
||||
from . import product_template
|
||||
from . import res_partner
|
||||
from . import account_move
|
||||
|
||||
21
purchase_usability/models/account_move.py
Normal file
21
purchase_usability/models/account_move.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# 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()
|
||||
22
purchase_usability/views/account_move.xml
Normal file
22
purchase_usability/views/account_move.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="view_move_form" model="ir.ui.view">
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="purchase.view_move_form_inherit_purchase"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="button_draft" position="after">
|
||||
<button name="delete_lines_qty_zero" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('move_type', '!=', 'in_invoice')]}" string="Delete Lines Qty=0" type="object"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user