Add employee on payments for some states
issue9677 review359451002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Add employee on payments for some states
|
||||
|
||||
Version 5.8.0 - 2020-11-02
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Remove support for Python 3.5
|
||||
|
||||
+17
-1
@@ -17,7 +17,8 @@ from trytond.transaction import Transaction
|
||||
from trytond.tools import sortable_values
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||||
from trytond.pool import Pool
|
||||
|
||||
from trytond.modules.company.model import (
|
||||
employee_field, set_employee, reset_employee)
|
||||
from .exceptions import OverpayWarning
|
||||
|
||||
KINDS = [
|
||||
@@ -311,6 +312,14 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
process_method = fields.Function(
|
||||
fields.Selection('get_process_methods', "Process Method"),
|
||||
'on_change_with_process_method', searcher='search_process_method')
|
||||
approved_by = employee_field(
|
||||
"Approved by",
|
||||
states=['approved', 'processing', 'succeeded', 'failed'])
|
||||
succeeded_by = employee_field(
|
||||
"Success Noted by", states=['succeeded', 'processing'])
|
||||
failed_by = employee_field(
|
||||
"Failure Noted by",
|
||||
states=['failed', 'processing'])
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('approved', 'Approved'),
|
||||
@@ -446,6 +455,9 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
else:
|
||||
default = default.copy()
|
||||
default.setdefault('group', None)
|
||||
default.setdefault('approved_by')
|
||||
default.setdefault('succeeded_by')
|
||||
default.setdefault('failed_by')
|
||||
return super().copy(payments, default=default)
|
||||
|
||||
@classmethod
|
||||
@@ -460,12 +472,14 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
@reset_employee('approved_by', 'succeeded_by', 'failed_by')
|
||||
def draft(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('approved')
|
||||
@set_employee('approved_by')
|
||||
def approve(cls, payments):
|
||||
pass
|
||||
|
||||
@@ -497,12 +511,14 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('succeeded')
|
||||
@set_employee('succeeded_by')
|
||||
def succeed(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('failed')
|
||||
@set_employee('failed_by')
|
||||
def fail(cls, payments):
|
||||
pass
|
||||
|
||||
|
||||
@@ -22,6 +22,20 @@ Create company::
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Set employee::
|
||||
|
||||
>>> User = Model.get('res.user')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Employee = Model.get('company.employee')
|
||||
>>> employee_party = Party(name="Employee")
|
||||
>>> employee_party.save()
|
||||
>>> employee = Employee(party=employee_party)
|
||||
>>> employee.save()
|
||||
>>> user = User(config.user)
|
||||
>>> user.employees.append(employee)
|
||||
>>> user.employee = employee
|
||||
>>> user.save()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = create_fiscalyear(company)
|
||||
@@ -46,7 +60,6 @@ Create payment journal::
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
>>> supplier = Party(name='Supplier')
|
||||
@@ -81,6 +94,8 @@ Partially pay line::
|
||||
Decimal('50.00')
|
||||
>>> payment.amount = Decimal('20.00')
|
||||
>>> payment.click('approve')
|
||||
>>> payment.approved_by == employee
|
||||
True
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
@@ -106,6 +121,8 @@ Check the properties of the payment group::
|
||||
Success the payment and recheck the payment group::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> payment.succeeded_by == employee
|
||||
True
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> group.reload()
|
||||
@@ -139,6 +156,8 @@ Partially fail to pay the remaining::
|
||||
Decimal('0.00')
|
||||
>>> payment.reload()
|
||||
>>> payment.click('fail')
|
||||
>>> payment.failed_by == employee
|
||||
True
|
||||
>>> payment.state
|
||||
'failed'
|
||||
>>> payment.group.payment_complete
|
||||
|
||||
@@ -28,6 +28,13 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="group"/>
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
<newline/>
|
||||
<label name="approved_by"/>
|
||||
<field name="approved_by"/>
|
||||
<label name="succeeded_by"/>
|
||||
<field name="succeeded_by"/>
|
||||
<label name="failed_by"/>
|
||||
<field name="failed_by"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="4" colspan="4" id="state_buttons">
|
||||
|
||||
Reference in New Issue
Block a user