Giter Club home page Giter Club logo

Comments (4)

LoisRForgeFlow avatar LoisRForgeFlow commented on August 17, 2024

It makes sense, my only concern would be the (unlikely) possibility of a document without company_id, nowadays almost every document in odoo has it but we need to cover every use case.

If you are brave enough you can try to make a PR, if not I would try to find some time for this in the following weeks.

from server-ux.

CasVissers-360ERP avatar CasVissers-360ERP commented on August 17, 2024

@LoisRForgeFlow
For me a PR to fix it is a bit out of my league. I will definitely help functionally with a PR though.

from server-ux.

CasVissers-360ERP avatar CasVissers-360ERP commented on August 17, 2024

@LoisRForgeFlow
I did some work on this:

  1. Added a field
    company_id = fields.Many2one(
        comodel_name="res.company",
        compute='_compute_company_id',
        store=True)
  1. Add method to compute:
@api.depends('model', 'res_id')
  def _compute_company_id(self):
      for rec in self:
          model = self.env[rec.model]
          rel_rec = model.search(
                  [("id", "=", rec.res_id)],
                  limit=1)
          if rel_rec and 'company_id' in model._fields:
              rec.company_id = rel_rec.company_id
          else:
              rec.company_id = None
  1. update review_user_count to filter on company:
  @api.model
   def review_user_count(self):
       user_reviews = {}
       to_review_docs = {}
       **company = self.env.company**
       for review in self.env.user.**sudo().**review_ids.filtered(
           lambda r: r.status == "pending" **and r.company_id.id in company.ids**
       ):

My problem is that we have to inherit all modules with models we want to search on. Any suggestions to avoid this?

EDIT:
And of-course also added a record rule:

    <record id="tier_review_comp_rule" model="ir.rule">
        <field name="name">Tier Review multi-company</field>
        <field name="model_id" ref="model_tier_review"/>
        <field name="domain_force"> ['|',('company_id', 'in', company_ids),('company_id','=',False)]</field>
    </record>

from server-ux.

LoisRForgeFlow avatar LoisRForgeFlow commented on August 17, 2024

Solved

from server-ux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.