Skip to content

Commit

Permalink
10.0 base multi company lmi (#1)
Browse files Browse the repository at this point in the history
* Revert "Revert hook view create back to model init"

This reverts commit 770bd71.

* [FIX] base_multi_company: Always create the view into a pre_init_hook to avoid error in log
  • Loading branch information
lmignon authored and mstuttgart committed Aug 6, 2018
1 parent 36061ea commit 426fa09
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions base_multi_company/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from .hooks import create_company_assignment_view

from . import models
1 change: 1 addition & 0 deletions base_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'license': 'LGPL-3',
'installable': True,
'application': False,
'pre_init_hook': 'create_company_assignment_view',
'depends': [
'base',
],
Expand Down
9 changes: 9 additions & 0 deletions base_multi_company/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@


__all__ = [
'create_company_assignment_view',
'post_init_hook',
'uninstall_hook',
]


def create_company_assignment_view(cr):
cr.execute("""
CREATE OR REPLACE VIEW res_company_assignment
AS SELECT id, name
FROM res_company;
""")


def post_init_hook(cr, rule_ref, model_name):
""" Set the `domain_force` and default `company_ids` to `company_id`.
Expand Down
11 changes: 1 addition & 10 deletions base_multi_company/models/res_company_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

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


class ResCompanyAssignment(models.Model):
Expand All @@ -11,12 +11,3 @@ class ResCompanyAssignment(models.Model):
_auto = False

name = fields.Char()

@api.model_cr
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW %s
AS SELECT id, name
FROM res_company;
""" % (self._table))

0 comments on commit 426fa09

Please sign in to comment.