[IMP] account: some minor usability improvements

* when refunding an invoice/bill with the option 'modify', it now opens the draft document in form view (chatter reworked for more clarity)
* payments list views are now using filters instead of domain, so that user can easily find back any payments (also transfer that haven't their dedicated menuitem)
* when clicking on a ling to create a new payment from the dashboard, the form view is directly open instead of the list view

Was PR #23402. Was task 58392
This commit is contained in:
Hiral Bhavsar
2018-04-27 14:02:05 +02:00
committed by qdp-odoo
parent d6a9a9bf4c
commit 42b7d7489a
6 changed files with 79 additions and 39 deletions
+1 -1
View File
@@ -1368,7 +1368,7 @@ class AccountInvoice(models.Model):
refund_invoice = self.create(values)
invoice_type = {'out_invoice': ('customer invoices credit note'),
'in_invoice': ('vendor bill credit note')}
message = _("This %s has been created from: <a href=# data-oe-model=account.invoice data-oe-id=%d>%s</a>") % (invoice_type[invoice.type], invoice.id, invoice.number)
message = _("This %s has been created from: <a href=# data-oe-model=account.invoice data-oe-id=%d>%s</a><br>Reason: %s") % (invoice_type[invoice.type], invoice.id, invoice.number, description)
refund_invoice.message_post(body=message)
new_invoices += refund_invoice
return new_invoices
@@ -5,7 +5,7 @@ from babel.dates import format_datetime, format_date
from odoo import models, api, _, fields
from odoo.release import version
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF, safe_eval
from odoo.tools.misc import formatLang
class account_journal(models.Model):
@@ -374,19 +374,18 @@ class account_journal(models.Model):
return self.open_payments_action('transfer')
@api.multi
def open_payments_action(self, payment_type):
ctx = self._context.copy()
ctx.update({
'default_payment_type': payment_type,
'default_journal_id': self.id
})
ctx.pop('group_by', None)
action_rec = self.env['ir.model.data'].xmlid_to_object('account.action_account_payments')
if action_rec:
action = action_rec.read([])[0]
action['context'] = ctx
action['domain'] = [('journal_id','=',self.id),('payment_type','=',payment_type)]
return action
def open_payments_action(self, payment_type, mode='tree'):
if payment_type == 'outbound':
action_ref = 'account.action_account_payments_payable'
elif payment_type == 'transfer':
action_ref = 'account.action_account_payments_transfer'
else:
action_ref = 'account.action_account_payments'
[action] = self.env.ref(action_ref).read()
action['context'] = dict(safe_eval(action.get('context')), default_journal_id=self.id, search_default_journal_id=self.id)
if mode == 'form':
action['views'] = [[False, 'form']]
return action
@api.multi
def open_action_with_context(self):
@@ -417,6 +416,21 @@ class account_journal(models.Model):
})
return action
@api.multi
def create_customer_payment(self):
"""return action to create a customer payment"""
return self.open_payments_action('inbound', mode='form')
@api.multi
def create_supplier_payment(self):
"""return action to create a supplier payment"""
return self.open_payments_action('outbound', mode='form')
@api.multi
def create_internal_transfer(self):
"""return action to create a internal transfer"""
return self.open_payments_action('transfer', mode='form')
#####################
# Setup Steps Stuff #
#####################
@@ -60,13 +60,19 @@
<span>View</span>
</div>
<div>
<a type="object" name="open_action">
<t t-if="journal_type == 'bank'">Bank Statements</t>
<t t-if="journal_type == 'cash'">Cash Statements</t>
</a>
<a type="object" name="open_action">Statements</a>
</div>
<div>
<a type="object" name="open_action_with_context" context="{'action_name': 'action_bank_statement_line', 'search_default_journal': True}">Search Operations</a>
<a type="object" name="open_action_with_context" context="{'action_name': 'action_bank_statement_line', 'search_default_journal': True}">Operations</a>
</div>
<div>
<a type="object" name="open_collect_money">Customer Payments</a>
</div>
<div>
<a type="object" name="open_spend_money">Vendor Payments</a>
</div>
<div>
<a type="object" name="open_transfer_money">Internal Transfers</a>
</div>
<div>
<a type="object" name="open_action" context="{'action_name': 'action_account_moves_all_a'}" groups="base.group_no_one">Journal Items</a>
@@ -79,20 +85,20 @@
</div>
<div name="bank_cash_commands">
<t t-if="journal_type == 'bank'">
<a type="object" name="create_bank_statement">Transaction</a>
<a type="object" name="create_bank_statement">Statement</a>
</t>
<t t-if="journal_type == 'cash'">
<a type="object" name="create_cash_statement">Transaction</a>
<a type="object" name="create_cash_statement">Statement</a>
</t>
</div>
<div>
<a type="object" name="open_spend_money">Send Money</a>
<a type="object" name="create_customer_payment">Customer Payment</a>
</div>
<div>
<a type="object" name="open_collect_money">Receive Money</a>
<a type="object" name="create_supplier_payment">Vendor Payment</a>
</div>
<div>
<a type="object" name="open_transfer_money">Internal Transfer</a>
<a type="object" name="create_internal_transfer">Internal Transfer</a>
</div>
</div>
@@ -100,10 +106,6 @@
<div class="o_kanban_card_manage_title">
<span>Reconciliation</span>
</div>
<div>
<a t-if="dashboard.number_to_reconcile > 0" type="object" name="action_open_reconcile">Reconcile</a>
<span t-if="dashboard.number_to_reconcile == 0" class="text-muted">Nothing to Reconcile</span>
</div>
<div>
<a type="object" name="open_action_with_context" context="{'action_name': 'action_account_reconcile_model', 'use_domain': True}" groups="account.group_account_manager">Reconciliation Models</a>
</div>
+19 -2
View File
@@ -92,8 +92,8 @@
<field name="partner_id" />
<field name="journal_id" />
<field name="company_id" groups="base.group_multi_company" />
<filter string="Outgoing Payments" domain="[('payment_type','=','outbound')]" name="outbound_filter"/>
<filter string="Incoming Payments" domain="[('payment_type','=','inbound')]" name="inbound_filter"/>
<filter string="Vendor Payments" domain="[('payment_type','=','outbound')]" name="outbound_filter"/>
<filter string="Customer Payments" domain="[('payment_type','=','inbound')]" name="inbound_filter"/>
<filter string="Transfers" domain="[('payment_type','=','transfer')]" name="transfers_filter"/>
<separator/>
<filter string="Draft" domain="[('state','=','draft')]" name='state_draft'/>
@@ -217,6 +217,23 @@
</field>
</record>
<record id="action_account_payments_transfer" model="ir.actions.act_window">
<field name="name">Internal Transfers</field>
<field name="res_model">account.payment</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,form,graph</field>
<field name="context">{'default_payment_type': 'transfer', 'search_default_transfers_filter': 1}</field>
<field name="domain">[]</field>
<field name="view_id" ref="view_account_supplier_payment_tree"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Register a payment
</p><p>
Payments are used to register liquidity movements. You can process those payments by your own means or by using installed facilities.
</p>
</field>
</record>
<menuitem action="action_account_payments" id="menu_action_account_payments_receivable" parent="menu_finance_receivables_documents" sequence="20"/>
<menuitem action="action_account_payments_payable" id="menu_action_account_payments_payable" parent="menu_finance_payables_documents" sequence="20"/>
@@ -100,6 +100,8 @@ class AccountInvoiceRefund(models.TransientModel):
else:
invoice[field] = invoice[field] or False
inv_refund = inv_obj.create(invoice)
body = _('Correction of <a href=# data-oe-model=account.invoice data-oe-id=%d>%s</a><br>Reason: %s') % (inv.id, inv.number, description)
inv_refund.message_post(body=body)
if inv_refund.payment_term_id.id:
inv_refund._onchange_payment_term_date_invoice()
created_inv.append(inv_refund.id)
@@ -107,15 +109,20 @@ class AccountInvoiceRefund(models.TransientModel):
inv.type == 'out_refund' and 'action_invoice_tree1' or \
inv.type == 'in_invoice' and 'action_invoice_in_refund' or \
inv.type == 'in_refund' and 'action_invoice_tree2'
# Put the reason in the chatter
subject = _("Credit Note")
body = description
refund.message_post(body=body, subject=subject)
if xml_id:
result = self.env.ref('account.%s' % (xml_id)).read()[0]
invoice_domain = safe_eval(result['domain'])
invoice_domain.append(('id', 'in', created_inv))
result['domain'] = invoice_domain
if mode == 'modify':
# When refund method is `modify` then it will directly open the new draft bill/invoice in form view
if inv_refund.type == 'in_invoice':
view_ref = self.env.ref('account.invoice_supplier_form')
else:
view_ref = self.env.ref('account.invoice_form')
result['views'] = [(view_ref.id, 'form')]
result['res_id'] = inv_refund.id
else:
invoice_domain = safe_eval(result['domain'])
invoice_domain.append(('id', 'in', created_inv))
result['domain'] = invoice_domain
return result
return True
@@ -45,7 +45,7 @@
<button t-if="dashboard.bank_statements_source == 'file_import' &amp;&amp; dashboard.number_to_reconcile == 0" type="object" name="import_statement" class="btn btn-primary btn-sm">Import Statement</button>
<a t-if="dashboard.bank_statements_source == 'file_import' &amp;&amp; dashboard.number_to_reconcile > 0" type="object" name="import_statement" class="oe_inline">Import Statement</a>
</xpath>
<xpath expr='//div[@name="bank_cash_commands"]' position="after">
<xpath expr='//div[@name="bank_cash_commands"]' position="before">
<t t-if="journal_type == 'bank'">
<a type="object" name="import_statement">Import Statement</a>
</t>