Giter VIP home page Giter VIP logo

Comments (11)

pedrobaeza avatar pedrobaeza commented on August 28, 2024

Please make a PR (https://odoo-community.org/page/code) rewriting it this way:

@api.multi
def _compute_company_id(self):
    for record in self:
        if self.env.user.company_id in record.company_ids:
            record.company_id = self.env.user.company_id
        else:
            record.company_id = (
                self.env.user.company_ids - record.company_ids
            )[:1]

from multi-company.

sharonshentc avatar sharonshentc commented on August 28, 2024

Hi, I don't understand your code? what does (self.env.user.company_ids - record.company_ids) do? it intersects the 2 lists? (I think this is what we want, the intersection of the 2 lists...)

from multi-company.

pedrobaeza avatar pedrobaeza commented on August 28, 2024

Set operation called difference

from multi-company.

pedrobaeza avatar pedrobaeza commented on August 28, 2024

But you are right. It's intersection what is needed. Please change it to self.env.user.company_ids & record.company_ids

from multi-company.

sharonshentc avatar sharonshentc commented on August 28, 2024

i thought the minus was overwritten by odoo or something...

from multi-company.

pedrobaeza avatar pedrobaeza commented on August 28, 2024

Well, indeed each operator can be overwritten in Python for adding your own logic about what the operation means for you, and it's done in that way with recordset, but as said, it's intersection what we want.

from multi-company.

sharonshentc avatar sharonshentc commented on August 28, 2024

yeah, i mean i thought the minus was overwritten in odoo to do intersection, which would be crazy, but since i'm new to python and odoo, i wasn't sure :)

from multi-company.

pedrobaeza avatar pedrobaeza commented on August 28, 2024

Sorry, my bad

from multi-company.

sharonshentc avatar sharonshentc commented on August 28, 2024

no problem

from multi-company.

sharonshentc avatar sharonshentc commented on August 28, 2024

Sorry but i think i will use the original code... record.company_ids is actually res.company.assignment. The code you suggested needs to be converted to sets and it also give me apple-orange error...

from multi-company.

pedrobaeza avatar pedrobaeza commented on August 28, 2024

Fixed after merging #91

from multi-company.

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.