-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][MIG] pos_product_template: Migration to 16.0
Co-authored-by: Daniel Duque <daniel.duque@factorlibre.com> Co-authored-by: Adriana Saiz <adriana.saiz@factorlibre.com>
- Loading branch information
1 parent
2ca2eb8
commit fee39db
Showing
19 changed files
with
346 additions
and
284 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
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 was deleted.
Oops, something went wrong.
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,3 @@ | ||
from . import pos_config | ||
from . import pos_session | ||
from . import res_config_settings |
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,86 @@ | ||
from odoo import api, models | ||
|
||
|
||
class PosSession(models.Model): | ||
_inherit = "pos.session" | ||
|
||
def _loader_params_pos_config(self): | ||
params = super()._loader_params_pos_config() | ||
if params.get("search_params", {}).get("fields"): | ||
params.get("search_params", {}).get("fields").append( | ||
"iface_product_template_show_variants" | ||
) | ||
return params | ||
|
||
@api.model | ||
def _pos_ui_models_to_load(self): | ||
models_to_load = super()._pos_ui_models_to_load() | ||
models_to_load.append("product.template") | ||
models_to_load.append("product.attribute") | ||
models_to_load.append("product.attribute.value") | ||
models_to_load.append("product.template.attribute.value") | ||
return models_to_load | ||
|
||
def _loader_params_product_product(self): | ||
params = super()._loader_params_product_product() | ||
params["search_params"]["fields"].append("name") | ||
params["search_params"]["fields"].append("product_template_attribute_value_ids") | ||
params["search_params"]["fields"].append("product_variant_count") | ||
return params | ||
|
||
def _get_pos_ui_product_template(self, params): | ||
return self.env["product.template"].search_read(**params["search_params"]) | ||
|
||
def _loader_params_product_template(self): | ||
return { | ||
"search_params": { | ||
"domain": [("sale_ok", "=", True), ("available_in_pos", "=", True)], | ||
"fields": [ | ||
"name", | ||
"display_name", | ||
"product_variant_ids", | ||
"product_variant_count", | ||
], | ||
}, | ||
} | ||
|
||
def _get_pos_ui_product_attribute(self, params): | ||
return self.env["product.attribute"].search_read(**params["search_params"]) | ||
|
||
def _loader_params_product_attribute(self): | ||
return { | ||
"search_params": { | ||
"fields": ["name", "value_ids", "sequence"], | ||
}, | ||
} | ||
|
||
def _get_pos_ui_product_attribute_value(self, params): | ||
return self.env["product.attribute.value"].search_read( | ||
**params["search_params"] | ||
) | ||
|
||
def _loader_params_product_attribute_value(self): | ||
return { | ||
"search_params": { | ||
"fields": ["name", "attribute_id"], | ||
}, | ||
} | ||
|
||
def _get_pos_ui_product_template_attribute_value(self, params): | ||
return self.env["product.template.attribute.value"].search_read( | ||
**params["search_params"] | ||
) | ||
|
||
def _loader_params_product_template_attribute_value(self): | ||
return { | ||
"search_params": { | ||
"domain": [("product_tmpl_id.available_in_pos", "=", True)], | ||
"fields": [ | ||
"name", | ||
"attribute_id", | ||
"product_tmpl_id", | ||
"product_attribute_value_id", | ||
"ptav_product_variant_ids", | ||
], | ||
}, | ||
} |
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,9 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
iface_product_template_show_variants = fields.Boolean( | ||
related="pos_config_id.iface_product_template_show_variants", readonly=False | ||
) |
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
Oops, something went wrong.