changeset b291768f3a5e in modules/account_payment_braintree:default
details:
https://hg.tryton.org/modules/account_payment_braintree?cmd=changeset&node=b291768f3a5e
description:
Add approving employee on refunds
issue11297
review356071002
diffstat:
CHANGELOG | 1 +
account.py | 15 +++++++++++++++
view/refund_form.xml | 4 ++++
3 files changed, 20 insertions(+), 0 deletions(-)
diffs (81 lines):
diff -r a753b03fbbab -r b291768f3a5e CHANGELOG
--- a/CHANGELOG Wed Mar 09 00:57:17 2022 +0100
+++ b/CHANGELOG Sat Mar 26 12:17:01 2022 +0100
@@ -1,3 +1,4 @@
+* Add approving employee on refunds
* Add support for Python 3.10
* Remove support for Python 3.6
diff -r a753b03fbbab -r b291768f3a5e account.py
--- a/account.py Wed Mar 09 00:57:17 2022 +0100
+++ b/account.py Sat Mar 26 12:17:01 2022 +0100
@@ -15,6 +15,8 @@
DeactivableMixin, ModelSQL, ModelView, Workflow, fields)
from trytond.modules.account_payment.exceptions import (
PaymentValidationError, ProcessError)
+from trytond.modules.company.model import (
+ employee_field, reset_employee, set_employee)
from trytond.modules.currency.fields import Monetary
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Bool, Eval
@@ -539,6 +541,9 @@
'readonly': Eval('state') != 'draft',
},
depends=['state'])
+ approved_by = employee_field(
+ "Approved by",
+ states=['approved', 'processing', 'succeeded', 'failed'])
state = fields.Selection([
('draft', "Draft"),
@@ -560,6 +565,9 @@
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"),
'on_change_with_currency')
+ company = fields.Function(
+ fields.Many2One('company.company', "Company"),
+ 'on_change_with_company')
@classmethod
def __setup__(cls):
@@ -594,6 +602,11 @@
if self.payment and self.payment.currency:
return self.payment.currency.id
+ @fields.depends('payment', '_parent_payment.company')
+ def on_change_with_company(self, name=None):
+ if self.payment and self.payment.company:
+ return self.payment.company.id
+
@classmethod
def copy(cls, refunds, default=None):
if default is None:
@@ -607,12 +620,14 @@
@classmethod
@ModelView.button
@Workflow.transition('draft')
+ @reset_employee('approved_by')
def draft(cls, refunds):
pass
@classmethod
@ModelView.button
@Workflow.transition('approved')
+ @set_employee('approved_by')
def approve(cls, refunds):
pass
diff -r a753b03fbbab -r b291768f3a5e view/refund_form.xml
--- a/view/refund_form.xml Wed Mar 09 00:57:17 2022 +0100
+++ b/view/refund_form.xml Sat Mar 26 12:17:01 2022 +0100
@@ -10,6 +10,10 @@
<label name="braintree_error_message"/>
<field name="braintree_error_message" colspan="3" yexpand="0" height="80"/>
+ <label name="approved_by"/>
+ <field name="approved_by"/>
+ <newline/>
+
<label name="state"/>
<field name="state"/>
<group col="-1" colspan="2" id="buttons">