ak-odoo-incubator icon indicating copy to clipboard operation
ak-odoo-incubator copied to clipboard

[CHG] intercompany_shared_contact: remove security_rule_not_editable

Open kevinkhao opened this issue 4 years ago • 4 comments

it seems to me that security_rule_not_editable is not necessary for the configuration of intercompany_shared_contact

kevinkhao avatar Jun 24 '21 15:06 kevinkhao

this is because it costs too much to have security_rule_not_editable (for example, if I want to start using UoM through settings->use multiple UoM, I can't since all rules are hard-locked)

kevinkhao avatar Jun 24 '21 15:06 kevinkhao

hum, indeed if we want to contribute this module in the OCA we need to remove the dependency The only issue is for loading this file : https://github.com/akretion/ak-odoo-incubator/blob/14.0/intercompany_shared_contact/security/ir_rule.xml Indeed odoo will not update the rule so we need to do it with a pre-hook or something like that

sebastienbeau avatar Jun 25 '21 15:06 sebastienbeau

Also maybe we should fix security_rule_not_editable so we can still tick option, I will try to spend time on it next week

sebastienbeau avatar Jun 25 '21 16:06 sebastienbeau




class ResPartner(models.Model):
    _inherit = "res.partner"

    # Note Even if it's a many2one we always have one partner per company so we use "_id"
    created_from_company_id = fields.one2many("res.company", "partner_id", readonly=True)
    intercompany_owner_id = fields.Many2one(compute="_compute_intercompany_owner_id", store=True)

    @api.depends("created_from_company_id", "parent_id.intercompany_owner_id")
    def _compute_intercompany_owner_id(self):
        for record in self:
            if record.created_from_company_id:
                record.intercompany_owner_id = record.created_from_company_id
                record.company_id = False
            elif record.parent_id.intercompany_owner_id:
                record.intercompany_owner_id = record.parent_id.intercompany_ower_id
                record.company_id = False
            else:
                record.intercompany_owner_id = False

                
class ResCompany(models.Model):

    _sql_constraints = [
        ('partner_uniq', 'unique (partner_id)', 'The company partner_id must be unique !')
    ]


``

sebastienbeau avatar Jun 28 '21 09:06 sebastienbeau