[MIG] base_usability to v14
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from . import users
|
||||
from . import partner
|
||||
from . import company
|
||||
from . import mail
|
||||
from . import misc
|
||||
from . import res_users
|
||||
from . import res_partner
|
||||
from . import res_partner_bank
|
||||
from . import res_partner_category
|
||||
from . import res_company
|
||||
from . import ir_mail_server
|
||||
from . import ir_model
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api
|
||||
from odoo import api, models
|
||||
from odoo.addons.base.models.ir_mail_server import extract_rfc2822_addresses
|
||||
import logging
|
||||
|
||||
@@ -27,7 +28,7 @@ class IrMailServer(models.Model):
|
||||
"with subject '%s'",
|
||||
smtp_from, message.get('To'), message.get('Cc'),
|
||||
message.get('Bcc'), message.get('Subject'))
|
||||
return super(IrMailServer, self).send_email(
|
||||
return super().send_email(
|
||||
message, mail_server_id=mail_server_id,
|
||||
smtp_server=smtp_server, smtp_port=smtp_port,
|
||||
smtp_user=smtp_user, smtp_password=smtp_password,
|
||||
@@ -1,19 +0,0 @@
|
||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo.tools import misc
|
||||
from odoo.tools import float_compare
|
||||
|
||||
|
||||
class BaseLanguageExport(models.TransientModel):
|
||||
_inherit = 'base.language.export'
|
||||
|
||||
# Default format for language files = format used by OpenERP modules
|
||||
format = fields.Selection(default='po')
|
||||
|
||||
|
||||
class BaseLanguageInstall(models.TransientModel):
|
||||
_inherit = 'base.language.install'
|
||||
|
||||
overwrite = fields.Boolean(default=True)
|
||||
@@ -1,7 +1,8 @@
|
||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api, _
|
||||
from odoo import api, models, _
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
@@ -31,7 +32,6 @@ class ResCompany(models.Model):
|
||||
line = separator.join(content)
|
||||
return line
|
||||
|
||||
@api.multi
|
||||
def _prepare_header_options(self):
|
||||
self.ensure_one()
|
||||
options = {
|
||||
@@ -61,7 +61,6 @@ class ResCompany(models.Model):
|
||||
return self.name
|
||||
|
||||
# for reports
|
||||
@api.multi
|
||||
def _display_report_header(
|
||||
self, line_details=[['phone', 'website'], ['vat']],
|
||||
icon=True, line_separator=' - '):
|
||||
@@ -1,4 +1,5 @@
|
||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
@@ -10,30 +11,27 @@ class ResPartner(models.Model):
|
||||
# track_visibility is handled in the 'mail' module, and base_usability
|
||||
# doesn't depend on 'mail', but that doesn't hurt, it will just be
|
||||
# ignored if mail is not installed
|
||||
name = fields.Char(track_visibility='onchange')
|
||||
parent_id = fields.Many2one(track_visibility='onchange')
|
||||
ref = fields.Char(track_visibility='onchange', copy=False)
|
||||
lang = fields.Selection(track_visibility='onchange')
|
||||
user_id = fields.Many2one(track_visibility='onchange')
|
||||
vat = fields.Char(track_visibility='onchange')
|
||||
customer = fields.Boolean(track_visibility='onchange')
|
||||
supplier = fields.Boolean(track_visibility='onchange')
|
||||
type = fields.Selection(track_visibility='onchange')
|
||||
street = fields.Char(track_visibility='onchange')
|
||||
street2 = fields.Char(track_visibility='onchange')
|
||||
zip = fields.Char(track_visibility='onchange')
|
||||
city = fields.Char(track_visibility='onchange')
|
||||
state_id = fields.Many2one(track_visibility='onchange')
|
||||
country_id = fields.Many2one(track_visibility='onchange')
|
||||
email = fields.Char(track_visibility='onchange')
|
||||
is_company = fields.Boolean(track_visibility='onchange')
|
||||
active = fields.Boolean(track_visibility='onchange')
|
||||
company_id = fields.Many2one(track_visibility='onchange')
|
||||
# TODO move to mail module
|
||||
# name = fields.Char(tracking=True)
|
||||
# parent_id = fields.Many2one(tracking=True)
|
||||
# ref = fields.Char(tracking=True)
|
||||
# lang = fields.Selection(tracking=True)
|
||||
# user_id = fields.Many2one(tracking=True)
|
||||
# vat = fields.Char(tracking=True)
|
||||
# street = fields.Char(tracking=True)
|
||||
# street2 = fields.Char(tracking=True)
|
||||
# zip = fields.Char(tracking=True)
|
||||
# city = fields.Char(tracking=True)
|
||||
# state_id = fields.Many2one(tracking=True)
|
||||
# country_id = fields.Many2one(tracking=True)
|
||||
# is_company = fields.Boolean(tracking=True)
|
||||
# active = fields.Boolean(tracking=True)
|
||||
# company_id = fields.Many2one(tracking=True)
|
||||
ref = fields.Char(copy=False)
|
||||
# For reports
|
||||
name_title = fields.Char(
|
||||
compute='_compute_name_title', string='Name with Title')
|
||||
|
||||
@api.multi
|
||||
@api.depends('name', 'title')
|
||||
def _compute_name_title(self):
|
||||
for partner in self:
|
||||
@@ -49,17 +47,14 @@ class ResPartner(models.Model):
|
||||
name_title = ' '.join([title, name_title])
|
||||
partner.name_title = name_title
|
||||
|
||||
@api.multi
|
||||
def _display_address(self, without_company=False):
|
||||
'''Remove empty lines'''
|
||||
res = super(ResPartner, self)._display_address(
|
||||
without_company=without_company)
|
||||
res = super()._display_address(without_company=without_company)
|
||||
while "\n\n" in res:
|
||||
res = res.replace('\n\n', '\n')
|
||||
return res
|
||||
|
||||
# for reports
|
||||
@api.multi
|
||||
def _display_full_address(
|
||||
self, details=[
|
||||
'company', 'name', 'address', 'phone',
|
||||
@@ -72,10 +67,16 @@ class ResPartner(models.Model):
|
||||
if self.is_company:
|
||||
company = self.name
|
||||
name = False
|
||||
name_no_title = False
|
||||
title = False
|
||||
title_short = False
|
||||
else:
|
||||
name = self.name_title
|
||||
company = self.parent_id and self.parent_id.is_company and\
|
||||
self.parent_id.name or False
|
||||
name = self.name_title
|
||||
name_no_title = self.name
|
||||
title = self.title.name
|
||||
title_short = self.title.shortcut
|
||||
options = {
|
||||
'name': {
|
||||
'value': name,
|
||||
@@ -83,6 +84,15 @@ class ResPartner(models.Model):
|
||||
'company': {
|
||||
'value': company,
|
||||
},
|
||||
'title': {
|
||||
'value': title,
|
||||
},
|
||||
'title_short': {
|
||||
'value': title_short,
|
||||
},
|
||||
'name_no_title': {
|
||||
'value': name_no_title,
|
||||
},
|
||||
'phone': {
|
||||
'value': self.phone,
|
||||
# http://www.fileformat.info/info/unicode/char/1f4de/index.htm
|
||||
@@ -122,18 +132,3 @@ class ResPartner(models.Model):
|
||||
res.append('%s' % entry['value'])
|
||||
res = '\n'.join(res)
|
||||
return res
|
||||
|
||||
|
||||
class ResPartnerCategory(models.Model):
|
||||
_inherit = 'res.partner.category'
|
||||
|
||||
name = fields.Char(translate=False)
|
||||
|
||||
|
||||
class ResPartnerBank(models.Model):
|
||||
_inherit = 'res.partner.bank'
|
||||
|
||||
# In the 'base' module, they didn't put any string, so the bank name is
|
||||
# displayed as 'Name', which the string of the related field it
|
||||
# points to
|
||||
bank_name = fields.Char(string='Bank Name')
|
||||
14
base_usability/models/res_partner_bank.py
Normal file
14
base_usability/models/res_partner_bank.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartnerBank(models.Model):
|
||||
_inherit = 'res.partner.bank'
|
||||
|
||||
# In the 'base' module, they didn't put any string, so the bank name is
|
||||
# displayed as 'Name', which the string of the related field it
|
||||
# points to
|
||||
bank_name = fields.Char(string='Bank Name')
|
||||
11
base_usability/models/res_partner_category.py
Normal file
11
base_usability/models/res_partner_category.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartnerCategory(models.Model):
|
||||
_inherit = 'res.partner.category'
|
||||
|
||||
name = fields.Char(translate=False)
|
||||
27
base_usability/models/res_users.py
Normal file
27
base_usability/models/res_users.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright 2018-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, SUPERUSER_ID
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
@api.model
|
||||
def _script_partners_linked_to_users_no_company(self):
|
||||
if self.env.user.id != SUPERUSER_ID:
|
||||
self = self.sudo()
|
||||
logger.info(
|
||||
'START to set company_id=False on partners related to users')
|
||||
users = self.with_context(active_test=False).search([])
|
||||
for user in users:
|
||||
if user.partner_id.company_id:
|
||||
user.partner_id.write({'company_id': False})
|
||||
logger.info(
|
||||
'Wrote company_id=False on user %s ID %d',
|
||||
user.login, user.id)
|
||||
logger.info(
|
||||
'END setting company_id=False on partners related to users')
|
||||
@@ -1,40 +0,0 @@
|
||||
# Copyright 2018 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api, SUPERUSER_ID, _
|
||||
from odoo.exceptions import UserError
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(ResUsers, self).default_get(fields_list)
|
||||
# For a new partner auto-created when you create a new user, we prefer
|
||||
# customer=False and supplier=True by default
|
||||
res.update({
|
||||
'customer': False,
|
||||
'supplier': True,
|
||||
})
|
||||
return res
|
||||
|
||||
@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)])
|
||||
for user in users:
|
||||
if user.partner_id.company_id:
|
||||
user.partner_id.company_id = False
|
||||
logger.info(
|
||||
'Wrote company_id=False on user %s ID %d',
|
||||
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