diff --git a/addons/base_branch_company/demo/branch_data.xml b/addons/base_branch_company/demo/branch_data.xml index 3f65ac15..b4476e1f 100644 --- a/addons/base_branch_company/demo/branch_data.xml +++ b/addons/base_branch_company/demo/branch_data.xml @@ -19,5 +19,9 @@ + + + + diff --git a/addons/base_branch_company/models/res_branch.py b/addons/base_branch_company/models/res_branch.py index 32ceb362..1cec0bfa 100644 --- a/addons/base_branch_company/models/res_branch.py +++ b/addons/base_branch_company/models/res_branch.py @@ -16,6 +16,7 @@ def migrate_company_branch(cr, registry): 'branch_ids': [(6, 0, [user_id.company_id.branch_id.id])]}) cr.commit() + class Company(models.Model): _name = "res.company" _inherit = ["res.company"] @@ -129,7 +130,7 @@ class Users(models.Model): string="Number of Companies", default=_branches_count) @api.onchange('company_id') - def _onchange_address(self): + def _onchange_company_id(self): self.default_branch_id = self.company_id.branch_id.id self.branch_ids = [(4, self.company_id.branch_id.id)] diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 5380d4e0..210ddbbd 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -7,7 +7,7 @@ from dateutil.relativedelta import relativedelta from flectra import api, fields, models, SUPERUSER_ID, _ from flectra.tools import DEFAULT_SERVER_DATETIME_FORMAT from flectra.tools.float_utils import float_is_zero, float_compare -from flectra.exceptions import UserError, AccessError +from flectra.exceptions import UserError, AccessError, ValidationError from flectra.tools.misc import formatLang from flectra.addons.base.res.res_partner import WARNING_MESSAGE, WARNING_HELP from flectra.addons import decimal_precision as dp diff --git a/addons/sales_team/security/sales_team_security.xml b/addons/sales_team/security/sales_team_security.xml index 11802bd0..5481cddc 100644 --- a/addons/sales_team/security/sales_team_security.xml +++ b/addons/sales_team/security/sales_team_security.xml @@ -43,7 +43,7 @@ CRM Team multi-branch - + ['|',('branch_id','=', False),'|',('branch_id','=',user.default_branch_id.id), ('branch_id','in', [b.id for b in user.branch_ids])] diff --git a/addons/stock/models/res_company.py b/addons/stock/models/res_company.py index de1db580..45f1a3ee 100644 --- a/addons/stock/models/res_company.py +++ b/addons/stock/models/res_company.py @@ -41,5 +41,5 @@ class Company(models.Model): company.create_transit_location() # mutli-company rules prevents creating warehouse and sub-locations self.env['stock.warehouse'].check_access_rights('create') - self.env['stock.warehouse'].sudo().create({'name': company.name, 'code': company.name[:5], 'company_id': company.id, 'partner_id': company.partner_id.id}) + self.env['stock.warehouse'].sudo().create({'name': company.name, 'code': company.name[:5], 'company_id': company.id, 'branch_id': company.branch_id.id, 'partner_id': company.partner_id.id}) return company diff --git a/addons/stock_account/data/stock_account_data_post_install.yml b/addons/stock_account/data/stock_account_data_post_install.yml index 7389eac6..dc56b4d6 100644 --- a/addons/stock_account/data/stock_account_data_post_install.yml +++ b/addons/stock_account/data/stock_account_data_post_install.yml @@ -4,24 +4,25 @@ !python {model: account.journal, id: False} : | #if we already have a coa installed, create journal and set property field company_obj = self.env['res.company'] - company_ids = company_obj.search([('chart_template_id', '!=', False)]).ids + company_ids = company_obj.search([('chart_template_id', '!=', False)]) for company_id in company_ids: from flectra.tools.translate import _ #Check if property exists for stock account journal exists PropertyObj = self.env['ir.property'] - properties = PropertyObj.search([('name', '=', 'property_stock_journal'), ('company_id', '=', company_id)]) + properties = PropertyObj.search([('name', '=', 'property_stock_journal'), ('company_id', '=', company_id.id)]) AccountJournal = self.env['account.journal'] #If not, check if you can find a journal that is already there with the same name, otherwise create one if not properties: - journal_id = AccountJournal.search([('name', '=', _('Stock Journal')), ('company_id', '=', company_id), ('type', '=', 'general')], limit=1).id + journal_id = AccountJournal.search([('name', '=', _('Stock Journal')), ('company_id', '=', company_id.id), ('type', '=', 'general')], limit=1).id if not journal_id: journal_id = AccountJournal.create({ 'name': _('Stock Journal'), 'type': 'general', 'code': 'STJ', - 'company_id': company_id, + 'company_id': company_id.id, + 'branch_id': company_id.branch_id.id, 'show_on_dashboard': False }).id vals = {'name': 'property_stock_journal', @@ -29,7 +30,7 @@ ('name', '=', 'property_stock_journal'), ('model', '=', 'product.category'), ('relation', '=', 'account.journal')], limit=1).id, - 'company_id': company_id, + 'company_id': company_id.id, 'value': 'account.journal,' + str(journal_id)} PropertyObj.create(vals) @@ -39,9 +40,8 @@ 'property_stock_account_output_categ_id', 'property_stock_valuation_account_id', ] - company = company_obj.browse(company_id) for record in todo_list: - account = getattr(company, record) + account = getattr(company_id, record) value = account and 'account.account,' + str(account.id) or False if value: field_id = self.env['ir.model.fields'].search([ @@ -51,11 +51,11 @@ ], limit=1).id vals = { 'name': record, - 'company_id': company_id, + 'company_id': company_id.id, 'fields_id': field_id, 'value': value, } - properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id)], limit=1) + properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company_id.id)], limit=1) if not properties: # create the property PropertyObj.create(vals)