summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2019-03-28 11:19:05 +0000
committerwan <wan@odoo.com>2019-04-23 14:20:12 +0000
commitd5e2708f8e925b1aa8a2e2667cc5207f8181de87 (patch)
tree20f3a3948d570341ca06353d0356d55c5b32c03c
parenta45e843decefbb2fed3505bd2c9ce68f66f00d2e (diff)
[IMP] account: generic usability improvements
Task 1950665 1. Define a tax on an account should tell if it's a SALE or PURCHASE tax 2. Credit Note creation from an invoice, label improvement 3. Improve Payable/Receivable account detection from bank statement reconciliation closes odoo/odoo#32775 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
-rw-r--r--addons/account/models/account.py4
-rw-r--r--addons/account/models/reconciliation_widget.py6
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_model.js10
-rw-r--r--addons/account/wizard/account_invoice_refund.py2
4 files changed, 15 insertions, 7 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 2805c22e862..ba2615f946b 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -88,7 +88,7 @@ class AccountAccount(models.Model):
reconcile = fields.Boolean(string='Allow Reconciliation', default=False,
help="Check this box if this account allows invoices & payments matching of journal items.")
tax_ids = fields.Many2many('account.tax', 'account_account_tax_default_rel',
- 'account_id', 'tax_id', string='Default Taxes')
+ 'account_id', 'tax_id', string='Default Taxes', context={'append_type_to_tax_name': True})
note = fields.Text('Internal Notes')
company_id = fields.Many2one('res.company', string='Company', required=True,
default=lambda self: self.env['res.company']._company_default_get('account.account'))
@@ -962,7 +962,7 @@ class AccountTax(models.Model):
def name_get(self):
if not self._context.get('append_type_to_tax_name'):
return super(AccountTax, self).name_get()
- return [(tax.id, '%s (%s)' % (tax.name, tax.type_tax_use)) for tax in self]
+ return [(tax.id, '%s (%s)' % (tax.name, dict(self._fields['type_tax_use']._description_selection(self.env))[tax.type_tax_use])) for tax in self]
@api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
diff --git a/addons/account/models/reconciliation_widget.py b/addons/account/models/reconciliation_widget.py
index 4683afab86f..db3fb9437a1 100644
--- a/addons/account/models/reconciliation_widget.py
+++ b/addons/account/models/reconciliation_widget.py
@@ -689,10 +689,12 @@ class AccountReconciliation(models.AbstractModel):
'company_id': st_line.company_id.id,
}
if st_line.partner_id:
- if amount > 0:
+ if st_line.partner_id.supplier and not st_line.partner_id.customer:
+ data['open_balance_account_id'] = st_line.partner_id.property_account_payable_id.id
+ elif not st_line.partner_id.supplier and st_line.partner_id.customer:
data['open_balance_account_id'] = st_line.partner_id.property_account_receivable_id.id
else:
- data['open_balance_account_id'] = st_line.partner_id.property_account_payable_id.id
+ data['open_balance_account_id'] = amount > 0 and st_line.partner_id.property_account_receivable_id.id or st_line.partner_id.property_account_payable_id.id
return data
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js
index 601f4cec773..c28790796d2 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_model.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js
@@ -837,11 +837,17 @@ var StatementModel = BasicModel.extend({
return this._rpc({
model: 'res.partner',
method: 'read',
- args: [partner_id, ["property_account_receivable_id", "property_account_payable_id"]],
+ args: [partner_id, ["property_account_receivable_id", "property_account_payable_id", "customer", "supplier"]],
}).then(function (result) {
if (result.length > 0) {
var line = self.getLine(handle);
- self.lines[handle].st_line.open_balance_account_id = line.balance.amount < 0 ? result[0]['property_account_payable_id'][0] : result[0]['property_account_receivable_id'][0];
+ if (result[0]['supplier'] && !result[0]['customer']) {
+ self.lines[handle].st_line.open_balance_account_id = result[0]['property_account_payable_id'][0];
+ } else if (!result[0]['supplier'] && result[0]['customer']) {
+ self.lines[handle].st_line.open_balance_account_id = result[0]['property_account_receivable_id'][0];
+ } else {
+ self.lines[handle].st_line.open_balance_account_id = line.balance.amount < 0 ? result[0]['property_account_payable_id'][0] : result[0]['property_account_receivable_id'][0];
+ }
}
});
},
diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py
index 03c94b37d95..7f3ab878404 100644
--- a/addons/account/wizard/account_invoice_refund.py
+++ b/addons/account/wizard/account_invoice_refund.py
@@ -24,7 +24,7 @@ class AccountInvoiceRefund(models.TransientModel):
date = fields.Date(string='Accounting Date')
description = fields.Char(string='Reason', required=True, default=lambda self: self._get_reason())
refund_only = fields.Boolean(string='Technical field to hide filter_refund in case invoice is partially paid', compute='_get_refund_only')
- filter_refund = fields.Selection([('refund', 'Create a draft credit note'), ('cancel', 'Cancel: create credit note and reconcile'), ('modify', 'Modify: create credit note, reconcile and create a new draft invoice')],
+ filter_refund = fields.Selection([('refund', 'Create a draft credit note (partial refunding)'), ('cancel', 'Cancel: create credit note and reconcile (full refunding)'), ('modify', 'Modify: create credit note, reconcile and create a new draft invoice')],
default='refund', string='Credit Method', required=True, help='Choose how you want to credit this invoice. You cannot Modify and Cancel if the invoice is already reconciled')
@api.depends('date_invoice')