account_usability: add name_search on account.incoterms
base_usability: Small improvement in script on res.users
This commit is contained in:
@@ -724,6 +724,16 @@ class AccountIncoterms(models.Model):
|
||||
res.append((rec.id, '[%s] %s' % (rec.code, rec.name)))
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=80):
|
||||
if args is None:
|
||||
args = []
|
||||
if name and operator == 'ilike':
|
||||
recs = self.search([('code', '=', name)] + args, limit=limit)
|
||||
if recs:
|
||||
return recs.name_get()
|
||||
return super().name_search(name=name, args=args, operator=operator, limit=limit)
|
||||
|
||||
|
||||
class AccountReconciliation(models.AbstractModel):
|
||||
_inherit = 'account.reconciliation.widget'
|
||||
|
||||
@@ -23,12 +23,9 @@ class ResUsers(models.Model):
|
||||
|
||||
@api.model
|
||||
def _script_partners_linked_to_users_no_company(self):
|
||||
if self.env.user.id != SUPERUSER_ID:
|
||||
raise UserError(_('You must run this script as admin user'))
|
||||
logger.info(
|
||||
'START to set company_id=False on partners related to users')
|
||||
users = self.search(
|
||||
['|', ('active', '=', True), ('active', '=', False)])
|
||||
users = self.sudo().with_context(active_test=False).search([])
|
||||
for user in users:
|
||||
if user.partner_id.company_id:
|
||||
user.partner_id.company_id = False
|
||||
@@ -37,4 +34,3 @@ class ResUsers(models.Model):
|
||||
user.login, user.id)
|
||||
logger.info(
|
||||
'END setting company_id=False on partners related to users')
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user