-
Notifications
You must be signed in to change notification settings - Fork 0
[18.0][MIG] purchase_compute_order: Migration to 18.0 #2
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
base: 18.0
Are you sure you want to change the base?
Conversation
* [ADD] Added new feature to sort Computed PO lines * [ADD] Added new feauture to see Computed purchase order lines, Improved fr translations
[ADD] icon.png
Currently translated at 100.0% (178 of 178 strings) Translation: foodcoops-12.0/foodcoops-12.0-purchase_compute_order Translate-URL: https://translate.druidoo.io/projects/foodcoops-12-0/foodcoops-12-0-purchase_compute_order/fr/
Currently translated at 100.0% (178 of 178 strings) Translation: foodcoops-12.0/foodcoops-12.0-purchase_compute_order Translate-URL: https://translate.druidoo.io/projects/foodcoops-12-0/foodcoops-12-0-purchase_compute_order/fr/ [FIX] Order of lines in Calculated Purchase Order [FIX] CPO performance issue (S#26472) [FIX] S#26688: Cann’t order from Viome [ADD] S#T34632 - Delivery Categories [ADD] F#T59775 - Minimum Quantity for products in Calculated purchase order F#T60423 - Add column Nb. Package MAX [ADD] F#T60745 - Add Shelf Life information [UPD] F#T60886 - Save Purchase Target in CPO after order PO created [UPD] F#T60885 - Adjustment to Product History Pop-up in CPO [UPD] F#T61877 - [SQQ-VDM] Missing translation in FR
b0fd57a to
7317a54
Compare
nguyenminhchien
left a comment
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.
nguyenminhchien
left a comment
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.
- Add
product_packaging_idto the flow: product.supplierinfo => CPO => PO =>... - Remember to show the package things for the group
product.group_stock_packagingonly.
| compute="_compute_subtotal_price", | ||
| digits="Product Price", | ||
| ) | ||
| package_qty = fields.Float("Package quantity") |
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.
- Add new field product_packaging_id m2o to product.packaging
- package_qty = fields.Float(related="product_packaging_id.qty", store=True,...)
| <field name="uom_id" /> | ||
| <field name="stock_duration" /> | ||
| <field name="cpo_state" invisible="1" /> | ||
| <field name="purchase_qty_package" /> |
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.
- Show
product_packaging_idto the UI. - Add
groups="product.group_stock_packaging"for all the fields related to the package
7317a54 to
5f89bf6
Compare
nguyenminhchien
left a comment
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.
Tests still failed from fresh db:
2025-12-04 02:28:28,667 22467 INFO v18c_purchase_compute_order odoo.addons.purchase_compute_order.tests.test_purchase_compute_order: Starting TestPurchaseComputeOrder.test_003_make_purchase_order ...
2025-12-04 02:28:28,721 22467 INFO v18c_purchase_compute_order odoo.addons.purchase_compute_order.tests.test_purchase_compute_order: ======================================================================
2025-12-04 02:28:28,721 22467 ERROR v18c_purchase_compute_order odoo.addons.purchase_compute_order.tests.test_purchase_compute_order: ERROR: TestPurchaseComputeOrder.test_003_make_purchase_order
Traceback (most recent call last):
File "/home/chien/code/oca/purchase-workflow/18.0/purchase_compute_order/tests/test_purchase_compute_order.py", line 68, in test_003_make_purchase_order
self.cmp_purchase_order.compute_purchase_quantities()
File "/home/chien/code/oca/purchase-workflow/18.0/purchase_compute_order/models/computed_purchase_order.py", line 492, in compute_purchase_quantities
return cpo._compute_purchase_quantities_days()
File "/home/chien/code/oca/purchase-workflow/18.0/purchase_compute_order/models/computed_purchase_order.py", line 369, in _compute_purchase_quantities_days
line.purchase_qty_package = quantity / package_qty
ZeroDivisionError: float division by zero
nguyenminhchien
left a comment
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.
Add product_packaging_id to the flow: product.supplierinfo => CPO => PO =>...
You missed this point.
I cannot test further without that feature.
| <field name="purchase_qty" /> | ||
| <field name="product_price_inv" /> | ||
| <field name="discount_inv" /> | ||
| <field name="price_policy" /> |
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.
| <field name="price_policy" /> | |
| <field name="price_policy" groups="product.group_stock_packaging"/> |
| <field name="purchase_qty" readonly="1" /> | ||
| <field name="product_price_inv" readonly="1" /> | ||
| <field name="discount_inv" readonly="1" /> | ||
| <field name="price_policy" readonly="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.
| <field name="price_policy" readonly="1" /> | |
| <field name="price_policy" readonly="1" groups="product.group_stock_packaging" /> |
| </div> | ||
| <field name="product_price_inv" /> | ||
| <field name="discount_inv" /> | ||
| <field name="price_policy" /> |
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.
| <field name="price_policy" /> | |
| <field name="price_policy" groups="product.group_stock_packaging"/> |
| required=True, | ||
| help="""This comes from the product form.""", | ||
| ) | ||
| package_qty = fields.Float( |
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.
Wherever package_qty is, add product_packaging_id and change package_qty to be a related field.
| "product_code": line.product_code, | ||
| "product_name": line.product_name, | ||
| "product_uom": line.uom_po_id.id, | ||
| "package_qty": line.package_qty, |
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.
| "package_qty": line.package_qty, | |
| "product_packaging_id": line.product_packaging_id, |
| "product_name": line.product_name, | ||
| "product_code": line.product_code, | ||
| "product_uom": line.product_uom.id, | ||
| "package_qty": line.package_qty, |
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.
| "package_qty": line.package_qty, | |
| "product_packaging_id": line.product_packaging_id, |
|
I just made a change in |
38c3b6e to
c7a2201
Compare
| <field name="product_code_inv" readonly="1" /> | ||
| <field | ||
| name="product_code_inv" | ||
| string="Supplier Product Code" |
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 did you remove readonly="1"?
| <field name="incoming_qty" string="Incoming" /> | ||
| <field | ||
| name="displayed_average_consumption" | ||
| readonly="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.
Why did you remove readonly="1"?
| name="purchase_qty_package" | ||
| attrs="{'readonly': | ||
| [('cpo_state', '!=', 'draft')]}" | ||
| readonly="cpo_state != 'draft'" |
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.
readonly="cpo_state != 'draft' or not product_packaging_id"
User needs to choose the packaging first.
| readonly="1" | ||
| groups="product.group_stock_packaging" | ||
| /> | ||
| <field name="purchase_qty" /> |
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.
readonly="cpo_state != 'draft' or product_packaging_id"
| "product_name": psi.product_name, | ||
| "product_price": psi.base_price, | ||
| "price_policy": psi.price_policy, | ||
| "package_qty": psi.package_qty or psi.min_qty, |
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.
| "package_qty": psi.package_qty or psi.min_qty, | |
| "product_packaging_id": psi.product_packaging_id.id, |
| psi_ids = psi_obj.search( | ||
| [ | ||
| ("partner_id", "=", partner_id), | ||
| ("product_tmpl_id", "=", product_tmpl_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.
add a domain for packaging id of the cpol if any.
| "product_name": cpol.product_name, | ||
| "product_code": cpol.product_code, | ||
| "product_uom": cpol.uom_po_id.id, | ||
| "package_qty": cpol.package_qty_inv, |
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.
| "package_qty": cpol.package_qty_inv, | |
| "product_packaging_id": cpol.product_packaging_id.id, |
It's seem that the button call this action will never be called. But just in case.
| - the theoretical duration of the stock, based on the precedent figures. | ||
|
|
||
| - Unlink the products you don't want to buy anymore to this supplier (this only deletes the product_supplierinfo) | ||
| - Add new products you want to buy and link them (this creates a product_supplierinfo) |
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.
Remove this line since it cannot be added now. Most of the fields are readonly: Supplier product code, product, price,..
|
|
||
| - Unlink the products you don't want to buy anymore to this supplier (this only deletes the product_supplierinfo) | ||
| - Add new products you want to buy and link them (this creates a product_supplierinfo) | ||
| - Modify any information about the products: supplier product_code, supplier product_name, purchase price, package quantity, purchase UoM. |
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.
Remove this line, these fields are readonly now.
Btw, check and update this file to adapt with the current behaviors.
| ) | ||
| uom_id = fields.Many2one(related="product_id.uom_id") | ||
| product_code = fields.Char( | ||
| "Supplier Product Code", |
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 see that we have some duplicated fields:
- product_code vs product_code_inv
- product_name vs product_name_inv
- product_price vs product_price_inv
- discount vs discount_inv
inv here is the short word of inverse. These *_inv fields were allowed the user to update the values of Product.supplierinfo. But, they're readonly now. Means that we don't need them anymore.
- Remove them all.
- Change these fields to related fields (NO store):
- product_code: psi_id.product_code
- product_name: psi_id.product_name
- product_price: psi_id.price
- discount: psi_id.discount
- price_policy: psi_id.price_policy
- uom_po_id: psi_id.uom_po_id
1241867 to
1176b9e
Compare
nguyenminhchien
left a comment
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.
| ) | ||
| self.psi_id = valid_psi.id | ||
|
|
||
| @api.depends("purchase_qty_package", "package_qty") |
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 not depend on package_qty since it's a related field. This could lead to unexpected update behavior.
Depends on product_packaging_id instead.
Check for other related fields: price_policy, discount,...
1176b9e to
1ec9fbe
Compare
| @api.depends( | ||
| "purchase_qty", "psi_id.price", "psi_id.price_policy", "psi_id.discount" | ||
| ) | ||
| def _compute_subtotal_price(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.
| /> | ||
| <field name="stock_duration" /> | ||
| <field | ||
| name="product_packaging_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.
Add context to set the product when adding a new package here.
| line_values = { | ||
| "name": line_name, | ||
| "product_qty": line.purchase_qty, | ||
| "package_qty": line.package_qty, |
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.
| "package_qty": line.package_qty, | |
| "product_packaging_id": line.product_packaging_id.id, |
1ec9fbe to
ead5d8b
Compare



Uh oh!
There was an error while loading. Please reload this page.