diff --git a/account_payment_order/models/account_invoice.py b/account_payment_order/models/account_invoice.py
index 9da340809..847df3604 100644
--- a/account_payment_order/models/account_invoice.py
+++ b/account_payment_order/models/account_invoice.py
@@ -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
diff --git a/account_payment_order/models/account_payment_mode.py b/account_payment_order/models/account_payment_mode.py
index 570028dbf..df34540b8 100644
--- a/account_payment_order/models/account_payment_mode.py
+++ b/account_payment_order/models/account_payment_mode.py
@@ -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 "
diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py
index f95aceb47..0d696f61d 100644
--- a/account_payment_order/models/account_payment_order.py
+++ b/account_payment_order/models/account_payment_order.py
@@ -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
diff --git a/account_payment_order/views/account_payment_mode.xml b/account_payment_order/views/account_payment_mode.xml
index 3d43f876d..5be3a6025 100644
--- a/account_payment_order/views/account_payment_mode.xml
+++ b/account_payment_order/views/account_payment_mode.xml
@@ -16,6 +16,7 @@
attrs="{'invisible': [('payment_order_ok', '=', False)]}">
+