-
Notifications
You must be signed in to change notification settings - Fork 23k
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
[IMP] product: revamp #165016
[IMP] product: revamp #165016
Conversation
3b29d2a
to
e4c5e23
Compare
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.
Thank for your work!!
Had first look at your PR looks like more things are broken then working need to rework and do proper testing 🙁
Could you move your demo data related and stat button position related changes in separate commit which we are sure they are not break anything? 🙂
I'll continue tomorrow if this is ready to review again and need to rework some points 😪
addons/account/models/product.py
Outdated
@api.onchange('taxes_id') | ||
def _onchange_taxes_id(self): | ||
# On the change of sales tax, purchase tax should be set if the same amount is present else remain as it is | ||
for product in self: | ||
sales_taxes = product.taxes_id.filtered(lambda x: x.type_tax_use == 'sale') | ||
# Get existing purchase taxes | ||
existing_purchase_taxes = product.supplier_taxes_id.ids | ||
purchase_taxes_ids = [] | ||
|
||
for tax in sales_taxes: | ||
# Find purchase tax with the same amount as sales tax | ||
matching_purchase_tax = self.env['account.tax'].search([('type_tax_use', '=', 'purchase'), | ||
('amount', '=', tax.amount)]) | ||
if matching_purchase_tax: | ||
purchase_taxes_ids.extend(matching_purchase_tax.ids) | ||
|
||
# Update supplier_taxes_id only if there are new purchase taxes | ||
if purchase_taxes_ids: | ||
updated_purchase_taxes = list(set(existing_purchase_taxes) | set(purchase_taxes_ids)) | ||
product.supplier_taxes_id = [(6, 0, updated_purchase_taxes)] | ||
else: | ||
# If no matching purchase tax is found, retain the existing purchase taxes | ||
product.supplier_taxes_id = [(6, 0, existing_purchase_taxes)] | ||
|
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.
Oh :()
What are you trying to do here 🤔
This look huge performance killer because you use search inside two for loops
Also why you need onchange
method? can't this be achieved via compute? 👀
], | ||
['event_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.
This seems too heavy 😢
May you could add a compute field checking that in python and add condition for that field 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.
Isn't there a way to specify a limit to the ´search_read` call ?
(same comment for the event_booth logic)
def sale_product_domain(self): | ||
return expression.AND([ | ||
super(Website, self).sale_product_domain(), | ||
[('detailed_type', '!=', 'course')], | ||
[('detailed_type', '!=', 'service')], | ||
]) |
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 seems wrong
I don't think we need this condition here :(
|
||
@api.model | ||
def _get_product_types_allow_zero_price(self): | ||
return super()._get_product_types_allow_zero_price() + ["event_booth"] |
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 has higher chances of breaking eCom flows
Like before if I add any product with zero price and this method return detailed type then it let me add product now I can't
For Ex Before this I can add Event product from eCom with Zero price but now I can't and it'll raise an error stating you can't add zero rupee product
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.
Indeed, this logic must be somehow replaced.
@@ -8,4 +8,4 @@ class Website(models.Model): | |||
_inherit = 'website' | |||
|
|||
def sale_product_domain(self): | |||
return ['&'] + super(Website, self).sale_product_domain() + [('detailed_type', '!=', 'event_booth')] | |||
return ['&'] + super().sale_product_domain() + [('detailed_type', '!=', 'service')] |
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 wrong 🙈
Remove this method
|
||
@api.model | ||
def _get_product_types_allow_zero_price(self): | ||
return super()._get_product_types_allow_zero_price() + ["event"] |
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.
same as above
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.
FYI
This method does not called now for events so removing this method for event, still this case happen for booth and course I guess
Related PR to remove zero price event in cart and create so line
Need to check with SM PO if we can do same for booth and course 🤔 (In new task obviously in SM )
e4c5e23
to
0c0c28a
Compare
addons/product/data/product_data.xml
Outdated
<field name="name">Expenses</field> | ||
</record> | ||
<record id="cat_services" model="product.category"> |
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 think it could be good to have more consistent name. I suggest you product_category_whatever so we have the model's name followed by the actual category.
I think having only category_whatever could also be OK in this case since we use the module name to find the record (product.category_whatever
), but if product category data are defined in another module where other kind of category are created (UOM or tagt category for example), it could be annoying.
Anyway, having consistent name is better, since this PR targets master, nothing stop you to make it so :)
<record id="product_category_4" model="product.category"> | ||
<field name="parent_id" ref="product.product_category_1"/> | ||
<field name="parent_id" ref="product.cat_services"/> |
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.
Should be cool to give better and more relevant name to those categories too
@@ -22,7 +22,7 @@ class ProductTemplate(models.Model): | |||
@tools.ormcache() | |||
def _get_default_category_id(self): | |||
# Deletion forbidden (at least through unlink) | |||
return self.env.ref('product.product_category_all') | |||
return self.env.ref('product.product_category_5') |
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.
Previously, the default category was a data, now it's a demo data, so not always installed. Sound like a bad idea IMO
addons/stock/tests/test_inventory.py
Outdated
@@ -19,13 +19,13 @@ def setUpClass(cls): | |||
cls.product1 = cls.env['product.product'].create({ | |||
'name': 'Product A', | |||
'type': 'product', | |||
'categ_id': cls.env.ref('product.product_category_all').id, | |||
'categ_id': cls.env.ref('product.cat_services').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.
For all the stock
related tests, you should use a category who reflect better a storable product.
It is not so meaningful for now but it would better reflect real use case.
I guess furniture should be more appropriate
dbf894b
to
baaf075
Compare
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.
Well, it seems like a loooot of side-effects and existing logics were not properly considered in the current task specification.
- Detailed types: Need more time to think about it, but I feel like it won't be trivial to handle all existing flows.
I believe this should be done in separate ordered commits:
- UX changes (moving fields from one page to another, button ordering, field renamings, ...)
- Merging
product
andconsu
intoGoods
- Other detailed types changes
- Categories cleanup
- SLA improvements (already seems to be in a separate commit on enterprise 👍)
This will allow us to see more clearly what's done for what part of the spec, what is working fine or not (and maybe has to be postponed for next freeze).
Edit 4PM: Categories are still required, but since we can now create a category on the fly, it's ok (will maybe annoy a bit the product imports, but can be easily solved imho). Making the categories not required will be for another task if needed, but won't be done here.
addons/event_sale/models/product.py
Outdated
@@ -1,24 +1,6 @@ | |||
# -*- coding: utf-8 -*- |
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.
replace coding by license, and rename file to product_product.py
@@ -15,7 +15,7 @@ def write(self, vals): | |||
in website_sale controller shop/address that updates customer, but not | |||
only. """ | |||
result = super(SaleOrder, self).write(vals) | |||
if any(line.product_type == 'event' for line in self.order_line) and vals.get('partner_id'): | |||
if any(line.product_type == 'service' for line in self.order_line) and vals.get('partner_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.
if any(line.product_type == 'service' for line in self.order_line) and vals.get('partner_id'): | |
if any(line.event_id for line in self.order_line) and vals.get('partner_id'): |
@@ -66,4 +63,4 @@ def _get_product_catalog_domain(self): | |||
:rtype: list | |||
""" | |||
domain = super()._get_product_catalog_domain() | |||
return expression.AND([domain, [('detailed_type', '!=', 'event')]]) | |||
return expression.AND([domain, [('detailed_type', '!=', 'service')]]) |
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.
With this, you won't see any service in the catalog, this is not the expected behavior
@@ -6,7 +6,7 @@ import { formView } from "@web/views/form/form_view"; | |||
|
|||
/** | |||
* This controller is overridden to allow configuring sale_order_lines through a popup | |||
* window when a product with 'detailed_type' == 'event' is selected. | |||
* window when a product with 'detailed_type' == 'service' is selected. |
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.
* window when a product with 'detailed_type' == 'service' is selected. | |
* window when a service product linked to events is selected. |
], | ||
['event_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.
Isn't there a way to specify a limit to the ´search_read` call ?
(same comment for the event_booth logic)
@@ -72,7 +72,7 @@ | |||
|
|||
<record id="matrix_product_template_shirt" model="product.template"> |
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.
Is the tshirt category used somewhere else?
If not, it can be moved into the demo data of product_matrix
@@ -116,7 +116,7 @@ | |||
<field name="model">product.template</field> | |||
<field name="inherit_id" ref="product.product_template_only_form_view"/> | |||
<field name="arch" type="xml"> | |||
<div name="button_box" position="inside"> |
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.
Instead of targeting specific elements, can't this be handled with views priorities ?
@@ -6,7 +6,7 @@ | |||
<field name="model">product.template</field> | |||
<field name="inherit_id" ref="product.product_template_form_view"/> | |||
<field name="arch" type="xml"> | |||
<xpath expr="//group[@name='group_general']/field[@name='uom_po_id']" position="after"> | |||
<xpath expr="//group[@name='group_general']" position="inside"> |
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.
<xpath expr="//group[@name='group_general']" position="inside"> | |
<group name="group_general" position="inside"> |
|
||
@api.model | ||
def _get_product_types_allow_zero_price(self): | ||
return super()._get_product_types_allow_zero_price() + ["event_booth"] |
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.
Indeed, this logic must be somehow replaced.
@@ -26,7 +26,7 @@ def _cart_find_product_line( | |||
def _verify_updated_quantity(self, order_line, product_id, new_qty, **kwargs): | |||
"""Forbid quantity updates on event booth lines.""" | |||
product = self.env['product.product'].browse(product_id) | |||
if product.detailed_type == 'event_booth' and new_qty > 1: | |||
if product.detailed_type == 'service' and new_qty > 1: |
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.
Nope, this will fail whenever we increase the quantity of a SOL with a service product.
baaf075
to
6cd6eec
Compare
760826e
to
de24f62
Compare
e70f4b2
to
c5b406c
Compare
26a36a4
to
8fa4c1b
Compare
7ccdb33
to
1069418
Compare
search="_search_is_event_booth", | ||
) | ||
|
||
def _compute_is_event_booth(self): |
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.
That's a really bad idea. It means you cannot create your product then link it. You are going to add a lot of code complexity (read group, ...) and break flows just to remove one field ? Not sure it makes sense...
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 create a service product and then link it, since the domain on events is now products of service type.
Nevertheless, I kinda agree that the detailed type changes are not the best part of this spec :D (fp-request though :c)
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 suggest to postpone to next freeze so that we calmy check and test everything, especially LNA is waaaay busy those days. Don't think people will die if they wait for 2 months, will they ?
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.
Well, our PO is on holidays for the freeze, and he didn't test the task either :D.
We'll try to merge the true back 2 basics change of this task for the freeze, and the rest will probably wait for next freeze (and more debates/testing with PO's/FP)
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.
Indeed, don't think we have to rush model changes in intermediate saas, does not seem to be the critical point right now.
f2a4715
to
9162cca
Compare
Remove UX and Service related commit in favor of #165935 and https://github.com/odoo/enterprise/pull/62741 |
* Drop hide_from_shop logic, we don't want that, users shouldn't publish the event/event_booth/... products * make is_event_ticket/is_event_booth work, only check if there are linked booths/tickets, not if event is valid or in the future, they shouldn't use those products for other logics * restore the configurator logic as before, keep changes minimal when possible * is_add_to_cart_allowed now gets the cart update params, to know more cleanly/easily when one type of product is allowed or not.
9162cca
to
eeb6b4f
Compare
Close in favor of #166497 |
The following changes have been made in this commit:
Target version: master
Task: 3526304