diff --git a/edi_sale_oca/README.rst b/edi_sale_oca/README.rst index 2897e4ddd..b0124caf2 100644 --- a/edi_sale_oca/README.rst +++ b/edi_sale_oca/README.rst @@ -7,7 +7,7 @@ EDI Sales !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:a15a65af9b9ffa6808d4901942982eb8467aa13f7c1ac65c07f8751ccbceeff7 + !! source digest: sha256:fb52928e31a51155acf8913e3bded99f8f488dc78beadcf8d6e35bb1f29b1bae !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png @@ -43,10 +43,16 @@ On your exchange type, go to advanced settings and add the following:: components: process: usage: input.process.sale.order - [...] - sale_order: - default_confirm_order: true - + env_ctx: + # Values for the wizard + default_confirm_order: true + default_price_source: order + # Custom keys, whatever you need + random_one: true + +Note that `env_ctx` will propagate all keys to the whole env so you can use it +for any kind of context related configuration. In the case of the sale order import wizard +here we are just passing defaults as we could do in odoo standard. TODO: shall we add an exchange type example as demo? diff --git a/edi_sale_oca/components/process.py b/edi_sale_oca/components/process.py index 61dbf53f7..13bce23e5 100644 --- a/edi_sale_oca/components/process.py +++ b/edi_sale_oca/components/process.py @@ -16,15 +16,6 @@ class EDIExchangeSOInput(Component): _inherit = "edi.component.input.mixin" _usage = "input.process.sale.order" - def __init__(self, work_context): - super().__init__(work_context) - self.settings = {} - # Suppor legacy key `self.type_settings` - for key in ("sale_order", "sale_order_import"): - if key in self.type_settings: - self.settings = self.type_settings.get(key, {}) - break - def process(self): wiz = self._setup_wizard() res = wiz.import_order_button() @@ -53,13 +44,17 @@ def msg_generic_error(self): def _setup_wizard(self): """Init a `sale.order.import` instance for current record.""" - ctx = self.settings.get("wiz_ctx", {}) # Set the right EDI origin on both order and lines edi_defaults = {"origin_exchange_record_id": self.exchange_record.id} - ctx["sale_order_import__default_vals"] = dict( - order=edi_defaults, lines=edi_defaults + addtional_ctx = dict( + sale_order_import__default_vals=dict(order=edi_defaults, lines=edi_defaults) + ) + wiz = ( + self.env["sale.order.import"] + .with_context(**addtional_ctx) + .sudo() + .create({}) ) - wiz = self.env["sale.order.import"].with_context(**ctx).sudo().create({}) wiz.order_file = self.exchange_record._get_file_content(binary=False) wiz.order_filename = self.exchange_record.exchange_filename wiz.order_file_change() diff --git a/edi_sale_oca/readme/DESCRIPTION.rst b/edi_sale_oca/readme/DESCRIPTION.rst index b11290099..55cdc88ed 100644 --- a/edi_sale_oca/readme/DESCRIPTION.rst +++ b/edi_sale_oca/readme/DESCRIPTION.rst @@ -13,9 +13,15 @@ On your exchange type, go to advanced settings and add the following:: components: process: usage: input.process.sale.order - [...] - sale_order: - default_confirm_order: true + env_ctx: + # Values for the wizard + default_confirm_order: true + default_price_source: order + # Custom keys, whatever you need + random_one: true +Note that `env_ctx` will propagate all keys to the whole env so you can use it +for any kind of context related configuration. In the case of the sale order import wizard +here we are just passing defaults as we could do in odoo standard. TODO: shall we add an exchange type example as demo? diff --git a/edi_sale_oca/static/description/index.html b/edi_sale_oca/static/description/index.html index eada31a83..5afcfd7b5 100644 --- a/edi_sale_oca/static/description/index.html +++ b/edi_sale_oca/static/description/index.html @@ -367,7 +367,7 @@
Note that env_ctx will propagate all keys to the whole env so you can use it +for any kind of context related configuration. In the case of the sale order import wizard +here we are just passing defaults as we could do in odoo standard.
TODO: shall we add an exchange type example as demo?
Important
diff --git a/edi_sale_oca/tests/test_process.py b/edi_sale_oca/tests/test_process.py index 1ec85332c..dbf05bbe3 100644 --- a/edi_sale_oca/tests/test_process.py +++ b/edi_sale_oca/tests/test_process.py @@ -29,11 +29,10 @@ def setUpClass(cls): components: process: usage: input.process.sale.order - sale_order_import: - wiz_ctx: - random_key: custom - default_price_source: 'pricelist' - default_import_type: 'xml' + env_ctx: + default_price_source: 'pricelist' + default_import_type: 'xml' + random_key: custom """ ), )