diff options
| author | Joren Van Onder <jov@odoo.com> | 2019-08-12 13:43:20 -0700 |
|---|---|---|
| committer | Joren Van Onder <jov@odoo.com> | 2019-08-23 16:22:00 -0700 |
| commit | 69e071e1f3802083fd50afa271a147bd6ccea814 (patch) | |
| tree | b0ee4578ac2d1a228413ece3a60d4c23cdc3c688 | |
| parent | d661ed122fb96bdb28234a9b54b840c7e621b80b (diff) | |
[IMP] point_of_sale: allow custo of pos.payment.method write constraint
Allow another module to override this behavior for some fields.
| -rw-r--r-- | addons/point_of_sale/models/pos_payment_method.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/point_of_sale/models/pos_payment_method.py b/addons/point_of_sale/models/pos_payment_method.py index 997afa31541..87852afa5dc 100644 --- a/addons/point_of_sale/models/pos_payment_method.py +++ b/addons/point_of_sale/models/pos_payment_method.py @@ -59,8 +59,11 @@ class PosPaymentMethod(models.Model): if not self.is_cash_count: self.cash_journal_id = False + def _is_write_forbidden(self, fields): + return bool(fields and self.open_session_ids) + def write(self, vals): - if self.open_session_ids: + if self._is_write_forbidden(set(vals.keys())): raise UserError('Kindly close and validate the following open PoS Sessions before modifying this payment method.\n' 'Open sessions: %s' % (' '.join(self.open_session_ids.mapped('name')),)) return super(PosPaymentMethod, self).write(vals) |
