-
-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] purchase_allowed_product: Improve UX
- Make use_only_supplied_product field computed, stored and not readonly - Propagation of use_only_supplied_product field to invoices
- Loading branch information
Showing
9 changed files
with
40 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
# © 2016 Chafique DELLI @ Akretion | ||
# Copyright 2024 Moduon Team S.L. <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
from odoo import api, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = ["account.move", "supplied.product.mixin"] | ||
_name = "account.move" | ||
|
||
@api.onchange("invoice_vendor_bill_id") | ||
def _onchange_invoice_vendor_bill(self): | ||
if self.invoice_vendor_bill_id: | ||
self.use_only_supplied_product = ( | ||
self.invoice_vendor_bill_id.use_only_supplied_product | ||
) | ||
return super()._onchange_invoice_vendor_bill() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# © 2017 Today Mourad EL HADJ MIMOUNE @ Akretion | ||
# Copyright 2024 Moduon Team S.L. <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
@@ -7,3 +8,9 @@ | |
class PurchaseOrder(models.Model): | ||
_inherit = ["purchase.order", "supplied.product.mixin"] | ||
_name = "purchase.order" | ||
|
||
def _prepare_invoice(self): | ||
self.ensure_one() | ||
invoice_vals = super()._prepare_invoice() | ||
invoice_vals["use_only_supplied_product"] = self.use_only_supplied_product | ||
return invoice_vals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# © 2017 Today Mourad EL HADJ MIMOUNE @ Akretion | ||
# Copyright 2024 Moduon Team S.L. <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
@@ -10,13 +11,17 @@ class SuppliedProductMixin(models.AbstractModel): | |
|
||
use_only_supplied_product = fields.Boolean( | ||
string="Use only allowed products", | ||
compute="_compute_partner_id_supplied_product", | ||
store=True, | ||
readonly=False, | ||
help="If checked, only the products provided by this supplier " | ||
"will be shown.", | ||
) | ||
|
||
@api.onchange("partner_id") | ||
def _onchange_partner_id_supplied_product(self): | ||
self.use_only_supplied_product = ( | ||
self.partner_id.use_only_supplied_product | ||
or self.partner_id.commercial_partner_id.use_only_supplied_product | ||
) | ||
@api.depends("partner_id") | ||
def _compute_partner_id_supplied_product(self): | ||
for record in self: | ||
record.use_only_supplied_product = ( | ||
record.partner_id.use_only_supplied_product | ||
or record.partner_id.commercial_partner_id.use_only_supplied_product | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters