[FIX] account: fix type of journals in account.payment.

This commit is contained in:
qdp-odoo
2017-09-21 10:12:38 +02:00
parent 0b5a743641
commit 234cfcdc89
2 changed files with 9 additions and 7 deletions
+4 -2
View File
@@ -323,15 +323,17 @@ class account_payment(models.Model):
if self.currency_id.is_zero(self.amount):
# In case of payment with 0 amount, allow to select a journal of type 'general' like
# 'Miscellaneous Operations' and set this journal by default.
journal_type.append('general')
journal_type = ['general']
self.payment_difference_handling = 'reconcile'
self.journal_id = self.env['account.journal'].search([('type', '=', 'general')], limit=1)
else:
if self.payment_type == 'inbound':
domain.append(('at_least_one_inbound', '=', True))
else:
domain.append(('at_least_one_outbound', '=', True))
domain.append(('type', 'in', journal_type))
if self.journal_id.type not in journal_type:
self.journal_id = self.env['account.journal'].search([('type', 'in', journal_type)], limit=1)
return {'domain': {'journal_id': domain}}
@api.one
@@ -146,16 +146,16 @@
<field name="payment_type" widget="radio" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="partner_type" widget="selection" attrs="{'required': [('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="partner_id" attrs="{'required': [('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))], 'readonly': [('state', '!=', 'draft')]}" context="{'default_is_company': True, 'default_supplier': payment_type == 'outbound', 'default_customer': payment_type == 'inbound'}"/>
<field name="journal_id" widget="selection" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="destination_journal_id" widget="selection" attrs="{'required': [('payment_type', '=', 'transfer')], 'invisible': [('payment_type', '!=', 'transfer')], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="hide_payment_method" invisible="1"/>
<field name="payment_method_id" string=" " widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="payment_method_code" invisible="1"/>
<label for="amount"/>
<div name="amount_div" class="o_row">
<field name="amount" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="currency_id" options="{'no_create': True, 'no_open': True}" groups="base.group_multi_currency" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
</div>
<field name="journal_id" widget="selection" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="destination_journal_id" widget="selection" attrs="{'required': [('payment_type', '=', 'transfer')], 'invisible': [('payment_type', '!=', 'transfer')], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="hide_payment_method" invisible="1"/>
<field name="payment_method_id" string=" " widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="payment_method_code" invisible="1"/>
</group>
<group>
<field name="payment_date" attrs="{'readonly': [('state', '!=', 'draft')]}"/>