Add submitted state to payment
This allow to process receivable payment without approval. issue11190 review370731002
This commit is contained in:
1 parent
c22952d9c9
commit
6d7a8b4a68
9 files changed
+77
-15
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Allow processing receivable payment without approval
|
||||
* Add submitted state to payment
|
||||
* Permit to edit amount for manual payment in processing
|
||||
* Use reference field for statement line relation
|
||||
* Do not create dunning for line with pending payment
|
||||
|
||||
+5
-1
@@ -31,7 +31,11 @@ The payment can be in one of this states:
|
||||
|
||||
* Draft
|
||||
|
||||
The payment is waiting for approval.
|
||||
The payment is in preparation.
|
||||
|
||||
* Submitted
|
||||
|
||||
The payment has been submitted and is waiting approval or to be processed.
|
||||
|
||||
* Approved
|
||||
|
||||
|
||||
+36
-5
@@ -351,6 +351,9 @@ 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')
|
||||
submitted_by = employee_field(
|
||||
"Submitted by",
|
||||
states=['submitted', 'processing', 'succeeded', 'failed'])
|
||||
approved_by = employee_field(
|
||||
"Approved by",
|
||||
states=['approved', 'processing', 'succeeded', 'failed'])
|
||||
@@ -361,11 +364,17 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
states=['failed', 'processing'])
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('submitted', "Submitted"),
|
||||
('approved', 'Approved'),
|
||||
('processing', 'Processing'),
|
||||
('succeeded', 'Succeeded'),
|
||||
('failed', 'Failed'),
|
||||
], "State", readonly=True, select=True, sort=False)
|
||||
], "State", readonly=True, select=True, sort=False,
|
||||
domain=[
|
||||
If(Eval('kind') == 'receivable',
|
||||
('state', '!=', 'approved'),
|
||||
()),
|
||||
])
|
||||
|
||||
@property
|
||||
def amount_line_paid(self):
|
||||
@@ -382,10 +391,13 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
super(Payment, cls).__setup__()
|
||||
cls._order.insert(0, ('date', 'DESC'))
|
||||
cls._transitions |= set((
|
||||
('draft', 'approved'),
|
||||
('draft', 'submitted'),
|
||||
('submitted', 'approved'),
|
||||
('submitted', 'processing'),
|
||||
('approved', 'processing'),
|
||||
('processing', 'succeeded'),
|
||||
('processing', 'failed'),
|
||||
('submitted', 'draft'),
|
||||
('approved', 'draft'),
|
||||
('succeeded', 'failed'),
|
||||
('succeeded', 'processing'),
|
||||
@@ -394,15 +406,22 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
))
|
||||
cls._buttons.update({
|
||||
'draft': {
|
||||
'invisible': Eval('state') != 'approved',
|
||||
'invisible': ~Eval('state').in_(['submitted', 'approved']),
|
||||
'icon': 'tryton-back',
|
||||
'depends': ['state'],
|
||||
},
|
||||
'approve': {
|
||||
'submit': {
|
||||
'invisible': Eval('state') != 'draft',
|
||||
'icon': 'tryton-forward',
|
||||
'depends': ['state'],
|
||||
},
|
||||
'approve': {
|
||||
'invisible': (
|
||||
(Eval('state') != 'submitted')
|
||||
| (Eval('kind') == 'receivable')),
|
||||
'icon': 'tryton-forward',
|
||||
'depends': ['state', 'kind'],
|
||||
},
|
||||
'proceed': {
|
||||
'invisible': (
|
||||
~Eval('state').in_(['succeeded', 'failed'])
|
||||
@@ -532,10 +551,17 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
@reset_employee('approved_by', 'succeeded_by', 'failed_by')
|
||||
@reset_employee('submitted_by', 'approved_by', 'succeeded_by', 'failed_by')
|
||||
def draft(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('submitted')
|
||||
@set_employee('submitted_by')
|
||||
def submit(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('approved')
|
||||
@@ -617,6 +643,11 @@ class ProcessPayment(Wizard):
|
||||
Warning = pool.get('res.user.warning')
|
||||
payments = self.records
|
||||
|
||||
payments = [
|
||||
p for p in payments
|
||||
if p.state == 'approved'
|
||||
or (p.state == 'submitted' and p.kind == 'receivable')]
|
||||
|
||||
for payment in payments:
|
||||
if payment.line and payment.line.payment_amount < 0:
|
||||
if Warning.check(str(payment)):
|
||||
|
||||
+23
-6
@@ -236,29 +236,36 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_approved">
|
||||
<field name="name">Approved</field>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_to_approve">
|
||||
<field name="name">To Approve</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain" eval="[('state', '=', 'approved')]" pyson="1"/>
|
||||
<field name="domain" eval="[('state', '=', 'submitted'), ('kind', '=', 'payable')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_to_process">
|
||||
<field name="name">To Process</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain" eval="['OR', ('state', '=', 'approved'), [('state', '=', 'submitted'), ('kind', '=', 'receivable')]]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_processing">
|
||||
<field name="name">Processing</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="sequence" eval="40"/>
|
||||
<field name="domain" eval="[('state', '=', 'processing')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_suceeded">
|
||||
<field name="name">Succeeded</field>
|
||||
<field name="sequence" eval="40"/>
|
||||
<field name="sequence" eval="50"/>
|
||||
<field name="domain" eval="[('state', '=', 'succeeded')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_payment_form_domain_failed">
|
||||
<field name="name">Failed</field>
|
||||
<field name="sequence" eval="50"/>
|
||||
<field name="sequence" eval="60"/>
|
||||
<field name="domain" eval="[('state', '=', 'failed')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_payment_form"/>
|
||||
</record>
|
||||
@@ -380,6 +387,16 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="group" ref="group_payment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="payment_submit_button">
|
||||
<field name="name">submit</field>
|
||||
<field name="string">Submit</field>
|
||||
<field name="model" search="[('model', '=', 'account.payment')]"/>
|
||||
</record>
|
||||
<record model="ir.model.button-res.group" id="payment_submit_button_group_payment">
|
||||
<field name="button" ref="payment_submit_button"/>
|
||||
<field name="group" ref="group_payment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="payment_approve_button">
|
||||
<field name="name">approve</field>
|
||||
<field name="string">Approve</field>
|
||||
|
||||
@@ -93,6 +93,9 @@ Partially pay line::
|
||||
>>> payment.amount
|
||||
Decimal('50.00')
|
||||
>>> payment.amount = Decimal('20.00')
|
||||
>>> payment.click('submit')
|
||||
>>> payment.submitted_by == employee
|
||||
True
|
||||
>>> payment.click('approve')
|
||||
>>> payment.approved_by == employee
|
||||
True
|
||||
@@ -149,6 +152,7 @@ Partially fail to pay the remaining::
|
||||
>>> payment, = Payment.find([('state', '=', 'draft')])
|
||||
>>> payment.amount
|
||||
Decimal('30.00')
|
||||
>>> payment.click('submit')
|
||||
>>> payment.click('approve')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
|
||||
@@ -98,7 +98,7 @@ Create no dunning::
|
||||
|
||||
Fail the payment::
|
||||
|
||||
>>> payment.click('approve')
|
||||
>>> payment.click('submit')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.click('fail')
|
||||
|
||||
@@ -80,7 +80,7 @@ Partially pay line::
|
||||
>>> pay_line.execute('next_')
|
||||
>>> payment, = Payment.find()
|
||||
>>> payment.amount = Decimal('20')
|
||||
>>> payment.click('approve')
|
||||
>>> payment.click('submit')
|
||||
|
||||
Check amount to pay::
|
||||
|
||||
@@ -121,7 +121,7 @@ Create multiple valid payments for one line::
|
||||
>>> payments = Payment.find([('state', '=', 'draft')])
|
||||
>>> for payment in payments:
|
||||
... payment.amount = Decimal('30')
|
||||
>>> Payment.click(payments, 'approve')
|
||||
>>> Payment.click(payments, 'submit')
|
||||
|
||||
Check amount to pay::
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
<newline/>
|
||||
<label name="submitted_by"/>
|
||||
<field name="submitted_by"/>
|
||||
<label name="approved_by"/>
|
||||
<field name="approved_by"/>
|
||||
<label name="succeeded_by"/>
|
||||
@@ -40,6 +42,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="state"/>
|
||||
<group col="-1" colspan="2" id="buttons">
|
||||
<button name="draft"/>
|
||||
<button name="submit"/>
|
||||
<button name="approve"/>
|
||||
<button name="proceed"/>
|
||||
<button name="fail"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
<button name="draft"/>
|
||||
<button name="submit"/>
|
||||
<button name="approve"/>
|
||||
<button name="fail"/>
|
||||
<button name="succeed"/>
|
||||
|
||||
Reference in new issue
Block a user