Skip to content

Commit

Permalink
Revert hook view create back to model init
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed May 4, 2017
1 parent 40e803e commit 770bd71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 0 additions & 2 deletions base_multi_company/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
# 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: 0 additions & 1 deletion base_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'license': 'LGPL-3',
'installable': True,
'application': False,
'post_init_hook': 'create_company_assignment_view',
'depends': [
'base',
],
Expand Down
10 changes: 0 additions & 10 deletions base_multi_company/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@


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


def create_company_assignment_view(cr, registry):
table = registry('res.company.assignment')._table
cr.execute("""
CREATE OR REPLACE VIEW %s
AS SELECT id, name
FROM res_company;
""" % (table))


def post_init_hook(cr, rule_ref, model_name):
""" Set the `domain_force` and default `company_ids` to `company_id`.
Expand Down
11 changes: 10 additions & 1 deletion 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 fields, models
from odoo import api, fields, models, tools


class ResCompanyAssignment(models.Model):
Expand All @@ -11,3 +11,12 @@ 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 770bd71

Please sign in to comment.