diff --git a/account_usability/models/account_move.py b/account_usability/models/account_move.py
index ca94292..5f3e9e6 100644
--- a/account_usability/models/account_move.py
+++ b/account_usability/models/account_move.py
@@ -40,6 +40,34 @@ class AccountMove(models.Model):
compute="_compute_sales_dates", readonly=True,
help="This information appear on invoice qweb report "
"(you may use it for your own report)")
+ # There is a native "blocked" field (bool) on account.move.line
+ # We want to have that field on invoices to improve usability
+ # while keeping compatibility with the standard Odoo datamodel
+ blocked = fields.Boolean(
+ compute="_compute_blocked",
+ inverse="_inverse_blocked",
+ store=True,
+ string="Dispute",
+ tracking=True,
+ )
+
+ @api.depends("line_ids", "line_ids.blocked")
+ def _compute_blocked(self):
+ for move in self:
+ move.blocked = any(
+ [
+ l.blocked
+ for l in move.line_ids
+ if l.account_id.internal_type in ("payable", "receivable")
+ ]
+ )
+
+ def _inverse_blocked(self):
+ for move in self:
+ for line in move.line_ids.filtered(
+ lambda l: l.account_id.internal_type in ("payable", "receivable")
+ ):
+ line.blocked = move.blocked
def _compute_has_discount(self):
prec = self.env['decimal.precision'].precision_get('Discount')
diff --git a/account_usability/views/account_move.xml b/account_usability/views/account_move.xml
index 70954ef..d7cf746 100644
--- a/account_usability/views/account_move.xml
+++ b/account_usability/views/account_move.xml
@@ -47,6 +47,9 @@
+
+
+
@@ -81,6 +84,23 @@
+
+ account.move.line
+
+
+
+
+ {'invisible': [('account_internal_type', 'not in', ('payable', 'receivable'))]}
+
+
+
+
+
+
+
account.move.line