Fall 4448: Multi Company

develop
Ahmed Aly 2017-11-16 12:37:43 +01:00
parent f96665f3c6
commit 1752eebd03
11 changed files with 127 additions and 6 deletions

View File

@ -34,6 +34,8 @@
],
'data': [
'data/dp_custom_data.xml',
'data/glaser_company_data.xml',
'data/tz_austria_company_data.xml',
'views/dp_custom_views.xml',
'security/ir.model.access.csv',
],

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="glaser_and_co_company" model="res.company">
<field name="name">Glaser &amp; Co.</field>
<field name="street">Neugasse 36</field>
<field name="city">Spannberg</field>
<field name="zip">2244</field>
<field name="phone">+43 (0)2538/8628-0</field>
<field name="fax">+43 (0)2538/8628-400</field>
<field name="email">office@glaser-co.at</field>
<field name="website">https://www.glaser-co.at</field>
<field name="company_registry">FN 61793 y</field>
<field name="country_id" search="[('code','=','AT')]"/>
<field name="vat">ATU17860303</field>
<field name="vat_check_vies" eval="False"/>
</record>
<function id="set_company_logo" model="res.company" name="set_company_logo">
<value eval="[ref('glaser_and_co_company')]"/>
<value>../static/src/img/logo_glaser.png</value>
</function>
<record id="glaser_admin_user" model="res.users">
<field name="lastname">Glaser &amp; Co. ADMIN</field>
<field name="login">glaser-admin</field>
<field name="email">admin@glaser.at</field>
<field name="company_id" eval="ref('glaser_and_co_company')"/>
<field name="company_ids" eval="[(6, 0, [ref('glaser_and_co_company')])]"/>
<field name="groups_id"
eval="[(4,ref('account.group_account_manager')),
(4,ref('sales_team.group_sale_manager')),
(4,ref('stock.group_stock_manager')),
(4,ref('base.group_system')),
(4,ref('base.group_partner_manager'))]"/>
</record>
<!--<function-->
<!--id="set_company_favicon"-->
<!--model="res.company"-->
<!--name="set_company_favicon"-->
<!--eval="[ref('glaser_and_co_company')]">-->
<!--<value>../static/src/img/favicon_glaser.png</value>-->
<!--</function>-->
</odoo>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="tz_admin_user" model="res.users">
<field name="lastname">TZ Tischlerzentrum ADMIN</field>
<field name="login">tz-admin</field>
<field name="company_id" eval="ref('base.main_company')"/>
<field name="company_ids" eval="[(6, 0, [ref('base.main_company')])]"/>
<field name="email">admin@tz-austria.at</field>
<field name="groups_id"
eval="[(4,ref('account.group_account_manager')),
(4,ref('sales_team.group_sale_manager')),
(4,ref('stock.group_stock_manager')),
(4,ref('base.group_system')),
(4,ref('base.group_partner_manager'))]"/>
</record>
</odoo>

View File

@ -21,3 +21,4 @@
from . import ir_ui_menu
from . import res_partner
from . import res_company

View File

@ -19,9 +19,7 @@
#
##############################################################################
from odoo import models
from odoo import api
from odoo import tools
from odoo import models, api, tools
DISABLED_MENUS = [
]

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import os
import base64
from odoo import fields, models, api
class Company(models.Model):
_inherit = 'res.company'
@api.model
def set_company_logo(self, company, logo):
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), logo)
fi = open(filename, 'rb')
content = base64.b64encode(fi.read())
content = content.decode()
fi.close()
self.browse(company).write({'logo': content})
@api.model
def set_company_favicon(self, company, logo):
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), logo)
fi = open(filename, 'rb')
content = base64.b64encode(fi.read())
content = content.decode()
fi.close()
self.browse(company).write(
{'favicon_backend': content, 'favicon_backend_mimetype': 'image/x-icon'})

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -119,6 +119,7 @@ def main():
#'default_set_order_policy',
'update_values',
#'update_special_values',
'set_password_for_admin_users',
'set_sys_params',
#'setup_reports',
'consume_tours',

View File

@ -198,7 +198,6 @@ class Config():
# 'dp_reports_stock',
'account_cancel',
'stock',
'partner_firstname',
'dp_changelogs'
]

View File

@ -90,8 +90,7 @@ class DatenpolFunctions:
vals['favicon_backend'] = self._readAndReturnFile(vals['favicon_backend'], encode='base64')
vals['country_id'] = country_id
c_ids = self.odoo.env['res.company'].search([])
return self.odoo.env['res.company'].write(c_ids, vals)
return self.odoo.env.ref('base.main_company').write(vals)
def set_taxes(self):
"""Setze nicht benötigte Steuern auf inaktiv"""
@ -562,6 +561,18 @@ class DatenpolFunctions:
"""Spezialwerte setzen"""
return True
def set_password_for_admin_users(self):
"""Passwort für admin Users setzen"""
user_ids = self.odoo.env['res.users'].search([('login', 'ilike', 'admin'), ('id', '!=', 1)])
wizard_id = self.odoo.env['change.password.wizard'].create({})
change_ids = []
for user_id in user_ids:
change_id = self.odoo.env['change.password.user'].create(
{'wizard_id': wizard_id, 'user_id': user_id, 'new_passwd': self.env.pwd})
change_ids.append(change_id)
self.odoo.env['change.password.user'].browse(change_ids).change_password_button()
return True
def update_values(self):
"""Existierende Daten aktualisieren"""