Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

domain_force need to be upgrade everytime there is a change

Naroči se

Get notified when there's activity on this post

This question has been flagged
ir.ruleodoo16
1538 Prikazi
Avatar
Dimas Aditya Kristianto

I'm trying to change an ir.rule that is from odoo base crm module. Specifically in odoo-server/addons/crm/security/crm_security.xml. The ir.rule is registered as no_update then I find this thread "How to inherit and change the domain of standard rules in odoo 8.0?". It work. The ir.rule is changed. 


My goal is to change the domain_force so that when the user's "Sales" access right was set to "User: Own document only", it will see the user status in "Sales Team" (crm.team). If he is a leader, he can see the member's opportunity and his opportunity when opening the CRM menu




I add new many2many field in res.partner to store all crm.lead that a user can be viewed 


The problem is when I open CRM menu, the data is not updated when I change the leader in "Sales Team". But it change when I upgrade the module OR set the argument --dev=xml​ when running the service





class CrmLead(models.Model):

    _inherit = 'crm.lead'

    def write(self, vals):

        res = super(CrmLead, self).write(vals)

        _logger.info("Editing in crm.lead")


        # user_ids = self.user_id

        partner_ids = self.env['res.users'].search([]).partner_id.ids

        if partner_ids:

            self._update_visible_crm_lead_ids(partner_ids)

        _logger.info("Finish editing in crm.lead")

        return res


    visible_res_users_ids = fields.Many2many('res.partner', string='Leads')

    def _update_visible_crm_lead_ids(self, partner_ids):

        """

        1. Check the user. If the user is leader, get the members user_id. If not, just get user_id

        2. Get all crm_lead that has the user_id that we got from the first step

        3. Replace all visible_crm_lead_ids with the new one


        """

        _logger.info("Entering update_visible_crm_lead with users: %s", partner_ids)

        partners = self.env['res.partner'].sudo().search([('id', 'in', partner_ids)])

        for partner in partners:

            res_user = self.env['res.users'].search([('partner_id', '=', res_user.id)])

            all_user_to_get_all_crm_lead = res_user.ids

            if crm_team_based_on_leader:

                all_user_to_get_all_crm_lead = all_user_to_get_all_crm_lead + crm_team_based_on_leader.member_ids.ids

                all_user_to_get_all_crm_lead = list(set(all_user_to_get_all_crm_lead))

                

            all_crm_lead = self.env['crm.lead'].search([('user_id', 'in', all_user_to_get_all_crm_lead)]).ids

            _logger.debug("partner display name: %s", partner.display_name)

            _logger.debug("res users: %s", res_user.display_name)

            _logger.debug("all_crm_lead: %s", all_crm_lead)

            partner.visible_crm_lead_ids = [(6, 0, all_crm_lead)]



class ResPartner(models.Model):

    _inherit = "res.partner"

    visible_crm_lead_ids = fields.Many2many('crm.lead', string='Leads')


class CrmTeam(models.Model):

    _inherit = 'crm.team'


    def write(self, vals):

        res = super(CrmTeam, self).write(vals)

        self.create_depart_users_write()

        # self.update_res_partner()

        _logger.info("Editing in crm.team")

        crm_lead = self.env['crm.lead'].search([], limit=1)

        if crm_lead:

            partner_ids = self.env['res.users'].search([]).partner_id.ids

            crm_lead._update_visible_crm_lead_ids(partner_ids)


        _logger.info("Finish editing in crm.team")

        return res

  



<?xml version="1.0" encoding="utf-8"?>

<odoo>


    <!--Find the corresponding "to be inherited record" with noupdate="1" -->

    <function name="write" model="ir.model.data">

        <function model="ir.model.data" name="search">

            <value eval="[('module', '=', 'crm'), ('name', '=', 'crm_rule_personal_lead')]" />

        </function>

        <value eval="{'noupdate': False}"/>

    </function>


    <!--Finish the job, i.e. inheriting/modifying some fields-->

    <record id="crm.crm_rule_personal_lead" model="ir.rule">            

        <field name="domain_force">[('id', 'in', user.partner_id.visible_crm_lead_ids.ids)]</field>        

    </record>


    <!--Optional, if you want to set noupdate to True again-->

    

    <function name="write" model="ir.model.data">

        <function model="ir.model.data" name="search">

            <value eval="[('module', '=', 'crm'), ('name', '=', 'crm_rule_personal_lead')]" />

        </function>

        <value eval="{'noupdate': True}"/>

    </function>


</odoo>







0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Automatic Batch Transfer Solved
odoo16
Avatar
Avatar
1
avg. 25
1383
Automatic Batch Transfer
odoo16
Avatar
Avatar
1
maj 25
2196
Bank statement import via email
odoo16
Avatar
0
nov. 24
2123
Display 'total' ( Like in Sale Order) on TOP
odoo16
Avatar
Avatar
2
okt. 24
2163
I have a manufacturing type product that comes out with 0 stock despite having materials.
odoo16
Avatar
0
avg. 24
1660
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now