Skip to content
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

[16.0][IMP] sign_oca: Improvements migrated from 14.0 #22

Merged
merged 29 commits into from
May 17, 2024

Conversation

PauBForgeFlow
Copy link

@PauBForgeFlow PauBForgeFlow commented Mar 6, 2024

Migrated PRs:
#8 #17 #18 #19 #20 #21 #24 #26 #27 #30

@OCA-git-bot
Copy link
Contributor

Hi @etobella,
some modules you are maintaining are being modified, check this out!

@PauBForgeFlow PauBForgeFlow changed the title [16.0][IMP] sign_oca: Improvements migrated from 14.0 [WIP][16.0][IMP] sign_oca: Improvements migrated from 14.0 Mar 6, 2024
@PauBForgeFlow PauBForgeFlow force-pushed the 16.0-imp-sign_oca branch 3 times, most recently from 40e501f to cfb2d25 Compare March 6, 2024 12:49
Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this work to v16.

Some comments (my functional review is still pending).

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I have seen do not work in v16:

Other things I have not been able to check.

@PauBForgeFlow PauBForgeFlow force-pushed the 16.0-imp-sign_oca branch 3 times, most recently from 378c829 to f38c83c Compare March 7, 2024 16:48
@victoralmau
Copy link
Member

Some comments to keep in mind:

@PauBForgeFlow PauBForgeFlow force-pushed the 16.0-imp-sign_oca branch 3 times, most recently from 699d5e3 to d46dd41 Compare April 9, 2024 14:28
@PauBForgeFlow PauBForgeFlow force-pushed the 16.0-imp-sign_oca branch 2 times, most recently from 93152a1 to f41970a Compare April 18, 2024 07:14
@BernatPForgeFlow
Copy link
Member

@victoralmau I'm checking the PR but still seem to find something not completely finished. The problem is that when we generate a signature request from the 'Sign from template' action, it doesn't create the signers. It seems to be something that has already been commented here but it's not quite clear to me: #25 (comment)

From my point of view, in the sign_oca code we should generate by default all the signers defined in the template with the active user that is throwing the action. And later, in any case, it could be inherited from the method that generates the signers to define a different logic. So, the 'Sign from Template' feature should work on its own without the need for another module.

Finally, I would also like to ask what exactly is the 'partner_type' field inside the 'sign.oca.role' model? I don't fully understand how to use it. Is it necessary?

@victoralmau
Copy link
Member

Currently everything is correct although I understand the confusion that exists (perhaps the readme should be improved).

I explain a little bit the different use cases:

1- Sign_now
ejemplo--1

A request will be created defining as signer the user that makes it.

2- Send
ejemplo-2

A wizard will be created to define the desired signers manually.

3- Sign from template
ejemplo-3

A wizard will be created that when selecting a template will generate a request with the "corresponding" signers. The concept of signers does not exist in the templates, it is something that generates from the roles and the type (fixed partner or regular expression). You can check #32 to understand it better.

@BernatPForgeFlow
Copy link
Member

BernatPForgeFlow commented May 7, 2024

@victoralmau Ok, I understand how it works and it looks good to me. The only thing that makes me hesitate is that the field is called 'Partner type' as it is not intuitive. How about we change it to 'Partner Selection Policy'? And in addition we add a help explaining a little how it works.

Other than that, what is the use of the 'Empty' option? I don't see any use for it, I would change 'Empty' to 'Active User'. By default, if the role is not configured with another partner selection policy, it would take the active user. Thus, any user can select records from a model and sign them on their behalf.
image

Lastly, when I use the 'Default' option it seems to fail.

Traceback (most recent call last):
  File "/mnt/data/odoo-addons-dir/sign_oca/wizards/sign_oca_template_generate_multi.py", line 35, in generate
    requests = self._generate()
  File "/mnt/data/odoo-addons-dir/sign_oca/wizards/sign_oca_template_generate_multi.py", line 30, in _generate
    return self.env["sign.oca.request"].create(
  File "<decorator-gen-154>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/mnt/data/odoo-addons-dir/sign_oca/models/sign_oca_request.py", line 298, in create
    records = super().create(vals_list)
psycopg2.ProgrammingError: can't adapt type 'res.partner'

@victoralmau
Copy link
Member

If you want to change the string of the field and add a perfect help, but the empty option should be kept and it is the "most frequent".

If we create a sign.request with the action "Sign from template" from a record (sale.order for example) the user that creates it should NOT be auto-added as signer; the ones that correspond with the defined in the template will be set.

The error you indicate I have not been able to reproduce it, can you indicate the steps to reproduce it and/or add a mini-video? If it is something that happens in 15.0 currently it should be solved.

@BernatPForgeFlow
Copy link
Member

Okay thank you! Will add the changes!

If we create a sign.request with the action "Sign from template" from a record (sale.order for example) the user that creates it should NOT be auto-added as signer; the ones that correspond with the defined in the template will be set.

About this, why would you add an item in a template that is filled by a role whose partner selection policy is 'Empty'? It's difficult for me to imagine a situation in which you would configure it like that.
For me, it makes sense that the person who selects the sale order and clicks the action 'Sign from template' is the one who signs the request. It might be useful to validate objects like sale orders, pickings, etc.

A video showing how it is failing for me:
https://github.com/OCA/sign/assets/90243017/6b5d822f-8a63-4130-a9dd-19d70b05a6b6

@PauBForgeFlow
Copy link
Author

@BernatPForgeFlow @victoralmau The error that you reported has been fixed. Also, the field partner_type has been renamed to partner_selection_policy.

@victoralmau
Copy link
Member

About this, why would you add an item in a template that is filled by a role whose partner selection policy is 'Empty'? It's difficult for me to imagine a situation in which you would configure it like that. For me, it makes sense that the person who selects the sale order and clicks the action 'Sign from template' is the one who signs the request. It might be useful to validate objects like sale orders, pickings, etc.

IMO by default the user who creates it should not be added as a signer. I understand what you comment but there are several things that would not make it very coherent:

  • What would be the role for the user (none would be correct).
  • If a maintenance user (maintenance_sign_oca) for example creates a sign request from a template, it would NOT be correct to set him as signer, you must set the corresponding ones according to the template (the user of the equipment and a fixed user for example).

IMO it could be improved (in a different PR) sign_oca so that in the wizard from "Sign from template" the signers that will be set with that template are shown, being able to modify them and/or add new ones (for example the user's partner with the desired role).

Copy link
Member

@BernatPForgeFlow BernatPForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! As @victoralmau recommended I will open a separated PR to propose a new way to work with the 'Partner Selection Policy' in 'Sign from template' action.

@victoralmau
Copy link
Member

Sorry, could you add a migration script to rename field partner_type to partner_selection_policy from sign.oca.role?

@BernatPForgeFlow
Copy link
Member

Ping @pedrobaeza @etobella

Change partner_type column to partner_selection_policy
@PauBForgeFlow
Copy link
Author

@pedrobaeza This is now ready

@victoralmau
Copy link
Member

Is everything correct now? IMO I think it is important not to delay merging and adding these changes in the 17.0 migration.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-22-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 340cb69 into OCA:16.0 May 17, 2024
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 27ca9b9. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants