mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Add field default_date_prefered on payment mode
This commit is contained in:
committed by
Enric Tobella
parent
ece8f9fa73
commit
441c1339c2
@@ -34,6 +34,8 @@ class AccountInvoice(models.Model):
|
||||
def _prepare_new_payment_order(self):
|
||||
self.ensure_one()
|
||||
vals = {'payment_mode_id': self.payment_mode_id.id}
|
||||
# other important fields are set by the inherit of create
|
||||
# in account_payment_order.py
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -40,6 +40,12 @@ class AccountPaymentMode(models.Model):
|
||||
('due', 'Due'),
|
||||
('move', 'Move'),
|
||||
], default='due', string="Type of Date Filter")
|
||||
# default option for account.payment.order
|
||||
default_date_prefered = fields.Selection([
|
||||
('now', 'Immediately'),
|
||||
('due', 'Due Date'),
|
||||
('fixed', 'Fixed Date'),
|
||||
], string='Default Payment Execution Date')
|
||||
group_lines = fields.Boolean(
|
||||
string="Group Transactions in Payment Orders", default=True,
|
||||
help="If this mark is checked, the transaction lines of the "
|
||||
|
||||
@@ -141,6 +141,10 @@ class AccountPaymentOrder(models.Model):
|
||||
vals['payment_type'] = payment_mode.payment_type
|
||||
if payment_mode.bank_account_link == 'fixed':
|
||||
vals['journal_id'] = payment_mode.fixed_journal_id.id
|
||||
if (
|
||||
'date_prefered' not in vals and
|
||||
payment_mode.default_date_prefered):
|
||||
vals['date_prefered'] = payment_mode.default_date_prefered
|
||||
return super(AccountPaymentOrder, self).create(vals)
|
||||
|
||||
@api.onchange('payment_mode_id')
|
||||
@@ -157,6 +161,8 @@ class AccountPaymentOrder(models.Model):
|
||||
jrl_ids = self.payment_mode_id.variable_journal_ids.ids
|
||||
res['domain']['journal_id'] = "[('id', 'in', %s)]" % jrl_ids
|
||||
self.journal_id = journal_id
|
||||
if self.payment_mode_id.default_date_prefered:
|
||||
self.date_prefered = self.payment_mode_id.default_date_prefered
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
attrs="{'invisible': [('payment_order_ok', '=', False)]}">
|
||||
<field name="no_debit_before_maturity"
|
||||
attrs="{'invisible': ['|', ('payment_type', '!=', 'inbound'), ('payment_order_ok', '!=', True)]}"/>
|
||||
<field name="default_date_prefered"/>
|
||||
<field name="group_lines"/>
|
||||
</group>
|
||||
<group name="payment_order_create_defaults"
|
||||
|
||||
Reference in New Issue
Block a user