-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
[14.0][IMP] edi_oca: Add new model edi.configuration #1035
base: 14.0
Are you sure you want to change the base?
Conversation
More information would be awesome in order to understand why you did this. |
@etobella this origins from our discussion on OCA/edi-framework#39 |
@thienvh332 as it's draft, do you want us to wait for a review? |
hi @simahawk
|
0a7f624
to
92b7973
Compare
92b7973
to
89cc982
Compare
89cc982
to
15a994e
Compare
Hello @simahawk , |
can you drop the pypdf fix? 15a994e |
): | ||
# Default action if not provided | ||
if ir_action is None: | ||
# `action_send_email` is just an action name I created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get what's the need for this ... there's no action_send_email
anywhere.
code = fields.Char(required=True, copy=False, index=True, unique=True) | ||
description = fields.Char(help="Describe what the conf is for") | ||
backend_id = fields.Many2one(string="Backend", comodel_name="edi.backend") | ||
type_id = fields.Many2one( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type should be mandatory
help="Model the conf applies to. Leave blank to apply for all models", | ||
) | ||
model_name = fields.Char(related="model.model", store=True) | ||
partner_ids = fields.Many2many( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for a partner_ids field. The conf should be stored on the partner on a specific field per app or module (eg: edi_purchase_conf_ids
).
The goal is to have clarity on UI on what confs are used for.
In fact, it's not in the specs.
def default_get(self, fields): | ||
vals = super().default_get(fields) | ||
model = self.env.context.get("default_model_name", False) | ||
partners = self.env.context.get("default_partner_ids", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd choose which model field you want to be the master. If the model name is only used for searches, we don't need this.
Partners as well, can be trashed here.
@@ -0,0 +1,222 @@ | |||
# Copyright 2024 Camptocamp SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes from the auto-type stuff, can you keep the authorship here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license must be LGPL
from odoo.addons.component.core import Component | ||
|
||
|
||
class EDIBackendListenerComponentConfig(Component): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this listener is useless IMO. See below.
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class EDIConfigurationMixin(models.AbstractModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we need this mixin. Is not in the specs... :/
Looks like a not required copy/past from *_auto
module.
I think there's a big misunderstanding on WHO is supposed to trigger the specific action.
I wanted to simplify what I've done on *_auto
module getting rid of all this automation and leave the control to the specific module and to the configuration that you can define.
Concept:
- the trigger is given by the specific module ->
on_button_confirm_purchase_order
must be an event triggered by the moduleedi_purchase_oca
whenbutton_confirm
is called (which is already the case!) - the condition to skip or exec a conf is defined on the conf itself -> that's why I described 2 methods (before_do and do)
@@ -7,10 +7,11 @@ | |||
|
|||
class EdiExchangeConsumerTest(models.Model): | |||
_name = "edi.exchange.consumer.test" | |||
_inherit = ["edi.exchange.consumer.mixin"] | |||
_inherit = ["edi.exchange.consumer.mixin", "edi.configuration.mixin"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can rollback this
_description = "Model used only for test" | ||
|
||
name = fields.Char() | ||
partner_id = fields.Many2one("res.partner") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a partner_id? If there's no partner on the model we should not run anything or even break the init of the model if you are assigning configurations to a model w/o partners
def on_button_confirm_purchase_order(self, record): | ||
trigger = "on_button_confirm_purchase_order" | ||
for rec in record: | ||
confs = self.env["edi.configuration"].edi_get_conf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not using edi_purchase_conf_ids
Specs
In edi_oca
Add generic
edi.configuration
model with these characteristics:Fields
This model can then be used by conf consumers.
Other methods:
Backend / Exc. record
Then add edi.exchange.record.action_exchange_generate_send and use that method from backend.
Consumer mixin
Specific fields for configuration (eg: edi_purchase_conf_ids) will be added by glue modules on res.partner.
Default conf
NOTE:
sending emails is not really bound to edibut in real life it's handy to have a default way to send EDI docs via email.
You could even generate an exchange record to keep track of that
but the choice will be up to the implementers.
The key is that w/ this features they can do whatever they want.
Views
On edi_purchase_oca
Example of specific listener implementation: