You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.9 KiB
44 lines
1.9 KiB
# -*- coding: utf-8 -*-
|
|
from odoo import models, fields, tools
|
|
|
|
|
|
class ResPartnerRoot(models.Model):
|
|
_name = "res.partner.hierarchy"
|
|
_description = "Partners hierarchy"
|
|
_auto = False
|
|
|
|
name = fields.Char()
|
|
active = fields.Boolean()
|
|
parent_id = fields.Many2one("res.partner.hierarchy")
|
|
|
|
def init(self):
|
|
tools.drop_view_if_exists(self.env.cr, self._table)
|
|
self.env.cr.execute(
|
|
"""
|
|
CREATE OR REPLACE VIEW %s AS (
|
|
SELECT DISTINCT id AS id,
|
|
active as active,
|
|
CONCAT(partner_code, ' - ', ref) AS name,
|
|
NULL::int AS parent_id
|
|
FROM res_partner WHERE partner_code IS NOT NULL AND ffck_network IS TRUE AND partner_scale = '1' AND (ref IS NOT NULL OR name IS NOT NULL)
|
|
UNION ALL
|
|
SELECT DISTINCT id AS id,
|
|
active as active,
|
|
CONCAT(partner_code, ' - ', ref) AS name,
|
|
ffck_partner_id AS parent_id
|
|
FROM res_partner WHERE partner_code IS NOT NULL AND ffck_network IS TRUE AND partner_scale = '2' AND (ref IS NOT NULL OR name IS NOT NULL)
|
|
UNION ALL
|
|
SELECT DISTINCT id AS id,
|
|
active as active,
|
|
CONCAT(partner_code, ' - ', ref) AS name,
|
|
crck_partner_id AS parent_id
|
|
FROM res_partner WHERE partner_code IS NOT NULL AND ffck_network IS TRUE AND partner_scale = '3' AND (ref IS NOT NULL OR name IS NOT NULL)
|
|
UNION ALL
|
|
SELECT DISTINCT id AS id,
|
|
active as active,
|
|
CONCAT(partner_code, ' - ', ref) AS name,
|
|
cdck_partner_id AS parent_id
|
|
FROM res_partner WHERE partner_code IS NOT NULL AND ffck_network IS TRUE AND partner_scale = '4' AND (ref IS NOT NULL OR name IS NOT NULL)
|
|
)"""
|
|
% (self._table,)
|
|
)
|