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

[17.0][ADD] sale_product_approval #3108

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from

Conversation

patrickrwilson
Copy link

This PR adds the sale_product_approval module to v17 - Note that this module was introduced in earlier versions but PR's were not merged.

patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Apr 29, 2024
@patrickrwilson
Copy link
Author

/ocabot rebase

@OCA-git-bot
Copy link
Contributor

Sorry @patrickrwilson you are not allowed to rebase.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

exceptions_sale_approval_confirm = fields.Boolean(
compute="_compute_exceptions", string="Exception", default=False
)
override_exception = fields.Boolean(default=False)
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

IMHO, this name is a little bit too broad. Should reflect the 'sale product approval' flow to avoid names collisions.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

No need of default=Falseas default

_inherit = "sale.order"

exceptions_sale_approval_confirm = fields.Boolean(
compute="_compute_exceptions", string="Exception", default=False
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Suggested change
compute="_compute_exceptions", string="Exception", default=False
compute="_compute_exceptions_sale_approval_confirm", string="Exception", default=False

user_id=order.user_id.id or SUPERUSER_ID,
)

def _render_product_state_excep(self, order, product_id):
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Prefer explicit naming than abbreviations

class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

approved_sale_confirm = fields.Boolean(
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Is this really needed as stored value ?

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Ok, see. For the search.

note = self._render_product_state_excep(order, product_id)
order.activity_schedule(
"mail.mail_activity_data_warning",
date.today(),
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Is this timezone safe ?

candidate_sale_confirm = fields.Boolean(
string="Candidate to be Sold",
)
can_edit_candidate = fields.Boolean(compute="_compute_can_edit_candidate")
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

This name should maybe reflect 'product approval' flow.

Copy link
Author

Choose a reason for hiding this comment

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

We went over the naming of these fields internally quite a bit and ended up settling on 'candidate' because the approval part is in the states and having the 'approved to be' on the products confused the users because they struggled to make the connection between the setting on the product depends on the state. So we settled on 'Candidate' to say basically its configured to be 'Sold', 'Purchased', etc as long as the state it's in allows it.


def _compute_can_edit_candidate(self):
for product in self:
product.can_edit_candidate = self.env.user.has_group(
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

You can do without loop (as record value depends on self value):

Suggested change
product.can_edit_candidate = self.env.user.has_group(
self.update({"can_edit_candidate": self.env.user.(...)})

)

@api.onchange("candidate_sale_confirm")
def _onchange_candidate_sale_confirm(self):
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Change the field candidate_sale as compute/readonly=False/stored field to avoid onchanges.



class TestSaleOrderLineDates(TransactionCase):
def setUp(self):
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Please use classmethod instead

@rousseldenis rousseldenis added this to the 17.0 milestone Aug 19, 2024
@Nikul-OSI Nikul-OSI force-pushed the add_sale_product_approval branch 4 times, most recently from db28a4b to 6526638 Compare August 21, 2024 10:33
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Sep 3, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Sep 4, 2024
This PR adds the sale_product_approval module to v17 - Note that this module was introduced in earlier versions but PR's were not merged.
@patrickrwilson
Copy link
Author

@rousseldenis I think all your comments have been addressed and ready for a re-review, thanks for your effort.

patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Sep 19, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Sep 19, 2024
patrickrwilson pushed a commit to ursais/sale-workflow that referenced this pull request Sep 19, 2024
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.

3 participants