Skip to content
Permalink
Browse files

[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
  • Loading branch information...
william-andre committed Mar 28, 2019
1 parent da711b9 commit 0e98e38a6ce8e9e2f9509ef08db6e65b3d4326d4
@@ -88,7 +88,7 @@ def _check_user_type_id(self):
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'))
@@ -956,7 +956,7 @@ def copy(self, default=None):
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):
@@ -968,7 +968,11 @@ def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_ui
domain = []
else:
connector = '&' if operator in expression.NEGATIVE_TERM_OPERATORS else '|'
domain = [connector, ('description', operator, name), ('name', operator, name)]
regex = re.compile('^(?P<name>.+?)?\s*(?:\((?P<type>[^\)\(]+)\)?)?$')
names = regex.match(name).groupdict()
domain = [connector, ('description', operator, names['name']), ('name', operator, name['name'])]
if names['type']:
domain = [connector] + domain + [('type_tax_use', operator, names['type'])]
tax_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
return self.browse(tax_ids).name_get()

@@ -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 @@ def _get_reason(self):
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')

0 comments on commit 0e98e38

Please sign in to comment.
You can’t perform that action at this time.