-
-
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
|
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
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.
no, as per our comments.
Please add a comment here explaining why it is not mandatory ;)
15a994e
to
497f4c4
Compare
Hi @simahawk ,
|
The idea is that everything should be explicit. You must explicitly declare which action you want to use.
Ok, you are right. Cannot be mandatory. Good point :) |
def exchange_generate_send(self, recordset, skip_generate=False, skip_send=False): | ||
for rec in recordset: | ||
if skip_generate: | ||
job1 = rec |
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.
what would be delayed in this case if we skip_send too? 🤔
auto_join=True, | ||
index=True, | ||
) | ||
model = 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.
model = fields.Many2one( | |
model_id = fields.Many2one( |
[ | ||
("on_record_write", "Update Record"), | ||
("on_record_create", "Create Record"), | ||
("on_email_send", "Send Email"), |
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 guess this is to ease the configuration for models like SO, PO, INV, that can be sent by email.
As there's no specific implementation here, I would add a comment that explain why this is here.
Also, I think trigger
should be mandatory otherwise the conf is useless, no?
Maybe we can add another option like ("disabled", "Disabled")
which would allow to keep the conf visible but disabled.
|
||
def edi_get_conf(self, trigger, backend=None): | ||
domain = [("trigger", "=", trigger)] | ||
backend_ids = self.mapped("type_id.backend_id.id") |
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.
what's the point on filtering on all the backends assigned to the current recordset?
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.
no, as per our comments.
Please add a comment here explaining why it is not mandatory ;)
def _edi_send_via_edi(self, exchange_type): | ||
exchange_record = self._edi_create_exchange_record(exchange_type) | ||
exchange_record.action_exchange_generate_send() | ||
msg = _("EDI auto: output generated.") |
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 is not only generated but generated and sent.
I wonder if we need this custom message...
The backend will call notify_action_complete
when is done...
|
||
def on_button_confirm_purchase_order(self, record): | ||
trigger = "on_button_confirm_purchase_order" | ||
confs = record.mapped("partner_id.edi_purchase_conf_ids").edi_get_conf(trigger) |
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.
no need to use mapped
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: