Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

domain_force need to be upgrade everytime there is a change

Odoberať

Get notified when there's activity on this post

This question has been flagged
ir.ruleodoo16
1537 Zobrazenia
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Automatic Batch Transfer Solved
odoo16
Avatar
Avatar
1
aug 25
1383
Automatic Batch Transfer
odoo16
Avatar
Avatar
1
máj 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
aug 24
1660
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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