[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>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user