Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] Inventory Users cannot Validate receipt pickings [purchase_discount] #1935

Open
atumer opened this issue Jul 8, 2023 · 0 comments
Open
Labels

Comments

@atumer
Copy link

atumer commented Jul 8, 2023

Users that only have Stock access rights, with no Purchase access rights, cannot validate Receipt pickings, due to calculation in price_unit.

Problem is related to purchase_discount module's hack in price unit calculation method for stock.move. This hack tries to write on purchase order lines temporarily, but standard inventory user does not have any "write" permission on Purchase Order Line. It is also not viable to set these users as Purchase users, just to bypass this problem.

    def _get_price_unit(self):
        """Get correct price with discount replacing current price_unit
        value before calling super and restoring it later for assuring
        maximum inheritability.

        HACK: This is needed while https://github.com/odoo/odoo/pull/29983
        is not merged.
        """
        price_unit = False
        po_line = self.purchase_line_id
        if po_line and self.product_id == po_line.product_id:
            price = po_line._get_discounted_price_unit()
            if price != po_line.price_unit:
                # Only change value if it's different
                price_unit = po_line.price_unit
                po_line.price_unit = price  # LINE CAUSING PROBLEM
        res = super()._get_price_unit()
        if price_unit:
            po_line.price_unit = price_unit  # LINE CAUSING PROBLEM
        return res
@atumer atumer added the bug label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant