-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][IMP] choose between brand or company values in layout
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import res_brand | ||
from . import res_company |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2024 Akretion (https://www.akretion.com). | ||
# @author Kévin Roche <[email protected]> | ||
|
||
from odoo import models | ||
|
||
|
||
class CompanyBrandAdapter: | ||
def __init__(self, company, brand): | ||
super().__init__() | ||
for field in dir(company): | ||
if field.startswith("__"): | ||
continue | ||
brands_fields = brand._get_company_overriden_fields() | ||
if field in brands_fields and getattr(brand, field): | ||
setattr(self, field, getattr(brand, field)) | ||
else: | ||
setattr(self, field, getattr(company, field)) | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
def _get_company_brand_adapter(self, brand): | ||
return CompanyBrandAdapter(self, brand) | ||
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