Add succeed button for payment groups

issue10809
review369811002
This commit is contained in:
Cédric Krier
2021-10-11 18:22:19 +02:00
parent 210b921bdd
commit 40c9904b26
5 changed files with 56 additions and 2 deletions
+2
View File
@@ -1,3 +1,5 @@
* Add succeed button for payment groups
Version 6.0.0 - 2021-05-03
* Bug fixes (see mercurial logs for details)
* Add employee on payments for some states
+40 -1
View File
@@ -75,8 +75,9 @@ class Group(ModelSQL, ModelView):
'account.payment', 'group', 'Payments', readonly=True,
domain=[
('company', '=', Eval('company', -1)),
('journal', '=', Eval('journal', -1)),
],
depends=['company'])
depends=['company', 'journal'])
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"),
'on_change_with_currency')
@@ -97,6 +98,20 @@ class Group(ModelSQL, ModelView):
help="All the payments in the group are complete."),
'get_payment_aggregated', searcher='search_complete')
process_method = fields.Function(
fields.Selection('get_process_methods', "Process Method"),
'on_change_with_process_method', searcher='search_process_method')
@classmethod
def __setup__(cls):
super().__setup__()
cls._buttons.update(
succeed={
'invisible': Eval('payment_complete', False),
'depends': ['payment_complete', 'process_method'],
},
)
@classmethod
def __register__(cls, module_name):
table_h = cls.__table_handler__(module_name)
@@ -110,6 +125,22 @@ class Group(ModelSQL, ModelView):
def default_company():
return Transaction().context.get('company')
@classmethod
def get_process_methods(cls):
pool = Pool()
Journal = pool.get('account.payment.journal')
field_name = 'process_method'
return Journal.fields_get([field_name])[field_name]['selection']
@fields.depends('journal')
def on_change_with_process_method(self, name=None):
if self.journal:
return self.journal.process_method
@classmethod
def search_process_method(cls, name, clause):
return [('journal.' + clause[0],) + tuple(clause[1:])]
@classmethod
def create(cls, vlist):
pool = Pool()
@@ -134,6 +165,14 @@ class Group(ModelSQL, ModelView):
default.setdefault('payments', None)
return super(Group, cls).copy(groups, default=default)
@classmethod
@ModelView.button
def succeed(cls, groups):
pool = Pool()
Payment = pool.get('account.payment')
payments = sum((g.payments for g in groups), ())
Payment.succeed(payments)
@classmethod
def _get_complete_states(cls):
return ['succeeded', 'failed']
+10
View File
@@ -171,6 +171,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.button" id="payment_group_succeed_button">
<field name="name">succeed</field>
<field name="string">Succeed</field>
<field name="model" search="[('model', '=', 'account.payment.group')]"/>
</record>
<record model="ir.model.button-res.group" id="payment_group_succeed_button_group_payment">
<field name="button" ref="payment_group_succeed_button"/>
<field name="group" ref="group_payment"/>
</record>
<record model="ir.sequence.type"
id="sequence_type_account_payment_group">
<field name="name">Account Payment Group</field>
+2 -1
View File
@@ -120,7 +120,8 @@ Check the properties of the payment group::
Success the payment and recheck the payment group::
>>> payment.click('succeed')
>>> group.click('succeed')
>>> payment.reload()
>>> payment.succeeded_by == employee
True
>>> payment.state
+2
View File
@@ -19,4 +19,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="payment_amount_succeeded"/>
<label name="payment_complete" string="Complete"/>
<field name="payment_complete"/>
<button name="succeed" colspan="4"/>
</form>