Add approving employee on refunds
issue11297 review356071002
This commit is contained in:
1 parent
d162abbd9e
commit
cb83dc5820
3 files changed
+26
-7
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add approving employee on refunds
|
||||
* Add setup intent expire delay
|
||||
* Add support for Python 3.10
|
||||
* Remove support for Python 3.6
|
||||
|
||||
+16
@@ -18,6 +18,8 @@ from trytond.model import (
|
||||
DeactivableMixin, ModelSQL, ModelView, Workflow, dualmethod, 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 Eval
|
||||
@@ -688,6 +690,10 @@ class Refund(Workflow, ModelSQL, ModelView):
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
depends=['state'])
|
||||
approved_by = employee_field(
|
||||
"Approved by",
|
||||
states=['approved', 'processing', 'succeeded', 'failed'])
|
||||
|
||||
state = fields.Selection([
|
||||
('draft', "Draft"),
|
||||
('approved', "Approved"),
|
||||
@@ -715,6 +721,9 @@ class Refund(Workflow, ModelSQL, ModelView):
|
||||
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):
|
||||
@@ -752,6 +761,11 @@ class Refund(Workflow, ModelSQL, ModelView):
|
||||
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 default_state(cls):
|
||||
return 'draft'
|
||||
@@ -781,12 +795,14 @@ class Refund(Workflow, ModelSQL, ModelView):
|
||||
@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
|
||||
|
||||
|
||||
@@ -19,12 +19,14 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="stripe_error_param"/>
|
||||
<field name="stripe_error_param"/>
|
||||
|
||||
<group col="4" colspan="4" id="state_buttons">
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<group col="-1" colspan="2" id="buttons">
|
||||
<button name="draft"/>
|
||||
<button name="approve"/>
|
||||
</group>
|
||||
<label name="approved_by"/>
|
||||
<field name="approved_by"/>
|
||||
<newline/>
|
||||
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<group col="-1" colspan="2" id="buttons">
|
||||
<button name="draft"/>
|
||||
<button name="approve"/>
|
||||
</group>
|
||||
</form>
|
||||
Reference in new issue
Block a user