[FIX] account: payment and related features usability
This commit is contained in:
committed by
Arthur Maniet
parent
66762d87b4
commit
9a6f414d13
@@ -221,7 +221,7 @@ class AccountJournal(models.Model):
|
||||
sequence = fields.Integer(help='Used to order Journals in the dashboard view')
|
||||
|
||||
#groups_id = fields.Many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', string='Groups')
|
||||
currency_id = fields.Many2one('res.currency', help='The currency used to enter statement', oldname='currency')
|
||||
currency_id = fields.Many2one('res.currency', help='The currency used to enter statement', string="Currency", oldname='currency')
|
||||
company_id = fields.Many2one('res.company', string='Company', required=True, index=1, default=lambda self: self.env.user.company_id,
|
||||
help="Company related to this journal")
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class account_abstract_payment(models.AbstractModel):
|
||||
_name = "account.abstract.payment"
|
||||
_description = "Contains the logic shared between models which allows to register payments"
|
||||
|
||||
payment_type = fields.Selection([('outbound', 'Send Money'), ('inbound', 'Receive Money')], default='outbound', required=True)
|
||||
payment_type = fields.Selection([('outbound', 'Send Money'), ('inbound', 'Receive Money')], default='outbound', string='Payment Type', required=True)
|
||||
payment_method = fields.Many2one('account.payment.method', string='Payment Method', required=True)
|
||||
payment_method_code = fields.Char(related='payment_method.code',
|
||||
help="Technical field used to adapt the interface to the payment method selected.")
|
||||
@@ -75,6 +75,7 @@ class account_abstract_payment(models.AbstractModel):
|
||||
return {'domain': {'payment_method': [('payment_type', '=', payment_type), ('id', 'in', payment_methods.ids)]}}
|
||||
return {}
|
||||
|
||||
# FIXME : If you change the currency_id, invoice_ids is mysteriously obliterated
|
||||
@api.onchange('currency_id')
|
||||
def _onchange_currency_id(self):
|
||||
self._set_total_invoices_amount()
|
||||
@@ -254,15 +255,19 @@ class account_payment(models.Model):
|
||||
res['domain']['journal_id'].append(('type', 'in', ('bank', 'cash')))
|
||||
return res
|
||||
|
||||
@api.onchange('invoice_ids')
|
||||
def _onchange_invoice(self):
|
||||
if len(self.invoice_ids) == 1:
|
||||
self.communication = self.invoice_ids[0].reference
|
||||
self.currency_id = self.invoice_ids[0].currency_id
|
||||
self.payment_type = self.invoice_ids[0].type in ('out_invoice', 'in_refund') and 'inbound' or 'outbound'
|
||||
self.partner_type = MAP_INVOICE_TYPE_PARTNER_TYPE[self.invoice_ids[0].type]
|
||||
self.partner_id = self.invoice_ids[0].partner_id
|
||||
self._set_total_invoices_amount()
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
rec = super(account_payment, self).default_get(fields)
|
||||
invoice_ids = rec.get('invoice_ids') and rec['invoice_ids'][0][2] or None
|
||||
if invoice_ids and len(invoice_ids) == 1:
|
||||
invoice = self.env['account.invoice'].browse(invoice_ids)
|
||||
rec['communication'] = rec.get('communication', invoice.reference)
|
||||
rec['currency_id'] = rec.get('currency_id', invoice.currency_id.id)
|
||||
rec['payment_type'] = rec.get('payment_type', invoice.type in ('out_invoice', 'in_refund') and 'inbound' or 'outbound')
|
||||
rec['partner_type'] = rec.get('partner_type', MAP_INVOICE_TYPE_PARTNER_TYPE[invoice.type])
|
||||
rec['partner_id'] = rec.get('partner_id', invoice.partner_id.id)
|
||||
rec['amount'] = rec.get('amount', invoice.residual_signed)
|
||||
return rec
|
||||
|
||||
def _get_invoices(self):
|
||||
return self.invoice_ids
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<group name="accounting" col="2" colspan="2" attrs="{'invisible': [('company_id','=', False)]}">
|
||||
<separator string="Accounting Information" colspan="2"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
@@ -28,7 +28,7 @@
|
||||
<field name="inherit_id" ref="base.view_partner_bank_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="acc_number" position="after">
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
<field name="date_invoice" string="Bill Date"/>
|
||||
<field name="date_due"/>
|
||||
<field name="move_name" invisible="1"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="check_total" groups="account.group_supplier_inv_check_total"/>
|
||||
</group>
|
||||
@@ -384,7 +384,7 @@
|
||||
<field name="user_id" groups="base.group_user" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
|
||||
<label for="currency_id" groups="base.group_multi_currency"/>
|
||||
<div groups="base.group_multi_currency">
|
||||
<field name="currency_id" class="oe_inline"/>
|
||||
<field name="currency_id" options="{'no_create': True}" class="oe_inline"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
<field name="payment_method"/>
|
||||
<field name="partner_id" string="Supplier"/>
|
||||
<field name="amount"/>
|
||||
<field name="state"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="state"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="partner_type" invisible="1"/>
|
||||
</tree>
|
||||
@@ -81,11 +81,11 @@
|
||||
<sheet>
|
||||
<div class="oe_right oe_button_box">
|
||||
<button class="oe_inline oe_stat_button" name="button_journal_entries"
|
||||
string="Journal Items" type="object"
|
||||
string="Journal Items" type="object" groups="account.group_account_manager"
|
||||
attrs="{'invisible':[('move_line_ids','=',[])]}" icon="fa-bars"/>
|
||||
<field name="move_line_ids" invisible="1"/>
|
||||
<button class="oe_inline oe_stat_button" name="button_invoices"
|
||||
string="Paid Invoices" type="object"
|
||||
string="Invoices" type="object"
|
||||
attrs="{'invisible':[('has_invoices','=',False)]}" icon="fa-bars"/>
|
||||
<field name="has_invoices" invisible="1"/>
|
||||
</div>
|
||||
@@ -101,12 +101,12 @@
|
||||
<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" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="payment_method" 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">
|
||||
<field name="amount" class="oe_inline" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency" class="oe_inline" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency" class="oe_inline" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
@@ -190,7 +190,7 @@
|
||||
<label for="amount"/>
|
||||
<div name="amount_div">
|
||||
<field name="amount" class="oe_inline"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency" class="oe_inline"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency" class="oe_inline" invisible="1"/><!-- FIXME see account_abstract_payment._onchange_currency_id -->
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<field name="user_type" widget="selection"/>
|
||||
<field name="tax_ids" widget="many2many_tags"/>
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tag_ids" widget="many2many_tags" domain="[('applicability', '!=', 'taxes')]" context="{'default_applicability': 'accounts'}"/>
|
||||
@@ -105,8 +105,8 @@
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="user_type"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -254,10 +254,10 @@
|
||||
<field name="type"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="default_debit_account_id" domain="[('deprecated', '=', False)]"/>
|
||||
<field name="default_credit_account_id" domain="[('deprecated', '=', False)]"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="default_debit_account_id" domain="[('deprecated', '=', False)]" attrs="{'invisible': [('default_debit_account_id', '=', False), ('type', 'in', ['bank', 'cash'])]}"/>
|
||||
<field name="default_credit_account_id" domain="[('deprecated', '=', False)]" attrs="{'invisible': [('default_credit_account_id', '=', False), ('type', 'in', ['bank', 'cash'])]}"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
@@ -496,7 +496,7 @@
|
||||
<field name="amount" attrs="{'readonly' : [('journal_entry_ids', '!=', [])] }"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="amount_currency" groups="base.group_multi_currency" attrs="{'readonly' : [('journal_entry_ids', '!=', [])] }"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency" attrs="{'readonly' : [('journal_entry_ids', '!=', [])] }"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency" attrs="{'readonly' : [('journal_entry_ids', '!=', [])] }"/>
|
||||
<field name="bank_account_id" groups="base.group_no_one" attrs="{'readonly' : [('journal_entry_ids', '!=', [])] }"
|
||||
domain="['|', ('partner_id', '=', partner_id), ('partner_id', '=', False)]"/>
|
||||
</tree>
|
||||
@@ -1233,7 +1233,7 @@
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
<field name="amount_currency" groups="base.group_multi_currency"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
<field name="reconciled"/>
|
||||
<field name="debit" sum="Total Debit"/>
|
||||
<field name="credit" sum="Total Credit"/>
|
||||
@@ -1412,7 +1412,7 @@
|
||||
<field name="code"/>
|
||||
<newline/>
|
||||
<field name="user_type" widget="selection"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
|
||||
<field name="tag_ids" domain="[('applicability', '!=', 'taxes')]" widget="many2many_tags" context="{'default_applicability': 'accounts'}"/>
|
||||
<field name="reconcile"/>
|
||||
<field name="chart_template_id"/>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<field name="anglo_saxon_accounting"/>
|
||||
</field>
|
||||
<xpath expr="//group[@name='account_grp']" position="inside">
|
||||
<field name="bank_account_code_char"/>
|
||||
<field name="accounts_code_digits"/>
|
||||
<field name="bank_account_code_char" groups="base.group_no_one"/>
|
||||
<field name="accounts_code_digits" groups="base.group_no_one"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<label for="currency_id"/>
|
||||
<field name="currency_id" class="oe_inline"/>
|
||||
<field name="currency_id" options="{'no_create': True}" class="oe_inline"/>
|
||||
</div>
|
||||
<div>
|
||||
<field name="tax_calculation_rounding_method" class="oe_inline" />
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<p>Just click OK to create the account/journal and finish the import. If this was a mistake, hit cancel to abort the import.</p>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="currency_id" options="{'no_create': True}"/>
|
||||
<field name="account_number"/>
|
||||
</group>
|
||||
<footer>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="account_payment_method_check_writing" model="account.payment.method">
|
||||
<field name="name">Check Writing</field>
|
||||
<field name="name">Check</field>
|
||||
<field name="code">check_writing</field>
|
||||
<field name="payment_type">outbound</field>
|
||||
</record>
|
||||
|
||||
@@ -48,5 +48,17 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_payment_check_writing_search" model="ir.ui.view">
|
||||
<field name="name">account.payment.check.writing.search</field>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="inherit_id" ref="account.view_account_payment_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='state_sent']" position="before">
|
||||
<filter string="Checks To Send" domain="[('payment_method.code', '=', 'check_writing'), ('state','=','posted')]" name="checks_to_send"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -189,7 +189,7 @@ class res_partner_bank(osv.osv):
|
||||
except Exception:
|
||||
raise UserError(_("Bank account name formating error") + ': ' + _("Check the format_layout field set on the Bank Account Type."))
|
||||
if data.get('currency_id'):
|
||||
currency_name = self.pool.get('res.currency').browse(cr, uid, data['currency_id'], context=context).name
|
||||
currency_name = self.pool.get('res.currency').browse(cr, uid, data['currency_id'][0], context=context).name
|
||||
name += ' (' + currency_name + ')'
|
||||
res.append((data.get('id', False), name))
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user