Skip to content

Commit

Permalink
account_invoice_line_default_account: search based on xmlid as name i…
Browse files Browse the repository at this point in the history
…s translatable
  • Loading branch information
jbaudoux authored and SirTakobi committed Apr 21, 2022
1 parent 0b66de3 commit 502a120
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions account_invoice_line_default_account/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,27 @@
# Copyright 2012 Therp BV (<http://therp.nl>)
# Copyright 2013-2018 BCIM SPRL (<http://www.bcim.be>)

from odoo import models, fields
from odoo import models, fields, api


class AccountAccountType(models.Model):
_inherit = 'account.account.type'

@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# Support xmlid in domain
res = []
if operator == '=':
try:
o = self.env.ref(name)
if o._name == self._name:
res += o.name_get()
except:
pass
if not res:
res = super(AccountAccountType, self).name_search(
name=name, args=args, operator=operator, limit=limit)
return res


class ResPartner(models.Model):
Expand All @@ -11,7 +31,7 @@ class ResPartner(models.Model):
property_account_income = fields.Many2one(
'account.account',
string='Default Income Account',
domain='''[('user_type_id', '=', 'Income')]''',
domain="[('user_type_id', '=', 'account.data_account_type_revenue')]",
help='Default counterpart account for sales on invoice lines',
company_dependent=True)
auto_update_account_income = fields.Boolean(
Expand All @@ -22,7 +42,7 @@ class ResPartner(models.Model):
property_account_expense = fields.Many2one(
'account.account',
string='Default Expense Account',
domain='''[('user_type_id', '=', 'Expenses')]''',
domain="[('user_type_id', '=', 'account.data_account_type_expenses')]",
help='Default counterpart account for purchases on invoice lines',
company_dependent=True)
auto_update_account_expense = fields.Boolean(
Expand Down

0 comments on commit 502a120

Please sign in to comment.