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

[15.0][FIX] account_invoice_pricelist: Adapted Tests for changes made in Sale module. #1457

Merged

Conversation

mbcosta
Copy link
Contributor

@mbcosta mbcosta commented May 11, 2023

Adapted Tests for changes made in Sale module, this problem generate error in others PRs example #1452 the LOG https://github.com/OCA/account-invoicing/actions/runs/4942212532/jobs/8835537437?pr=1452#step:8:137

2023-05-10 23:27:32,617 255 ERROR odoo odoo.tests.loader: Can not import account_invoice_pricelist.
Traceback (most recent call last):
File "/opt/odoo/odoo/tests/loader.py", line 33, in _get_tests_modules
mod = importlib.import_module('.tests', modpath)
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/__w/account-invoicing/account-invoicing/account_invoice_pricelist/tests/init.py", line 3, in
from . import test_account_move_pricelist
File "/__w/account-invoicing/account-invoicing/account_invoice_pricelist/tests/test_account_move_pricelist.py", line 9, in
from odoo.addons.sale.models.sale import SaleOrderLine as upstream

By solving this first problem another appear

ERROR odoo odoo.sql_db: bad query: INSERT INTO "product_template" ("id", "active", "categ_id", "
create_date", "create_uid", "detailed_type", "list_price", "name", "priority", "purchase_ok", "s
ale_delay", "sale_ok", "sequence", "tracking", "uom_id", "uom_po_id", "write_date", "write_uid")
VALUES (nextval('product_template_id_seq'), true, 1, '2023-05-11 01:16:13.968840', 1, 'consu',
'100.00', 'Product Test', '0', true, 0.0, true, 1, 'none', 1, 1, '2023-05-11 01:16:13.968840', 1
) RETURNING id
ERROR: null value in column "purchase_line_warn" of relation "product_template" violates not-nul
l constraint

To solve I just get the Default Values of the object.

cc @rvalyi @renatonlima

@mbcosta mbcosta force-pushed the 15.0-FIX-test_account_invoice_pricelist branch from ff6dcde to b700f23 Compare May 11, 2023 14:23
@mbcosta
Copy link
Contributor Author

mbcosta commented May 11, 2023

There are another error in the tests but in sale_timesheet_invoice_description module, LOG https://github.com/OCA/account-invoicing/actions/runs/4948966918/jobs/8850424002?pr=1457#step:8:477

2023-05-11 14:27:14,545 254 ERROR odoo odoo.addons.sale_timesheet_invoice_description.tests.test_sale_timesheet_description: FAIL: TestSaleTimesheetDescription.test_three_timesheets_same_date_split
Traceback (most recent call last):
File "/__w/account-invoicing/account-invoicing/sale_timesheet_invoice_description/tests/test_sale_timesheet_description.py", line 217, in test_three_timesheets_same_date_split
self.assertEqual(aml_ids[-1].quantity, 1.3)
AssertionError: 1.29 != 1.3

I'm trying understand the problem, it's seems a rounding error, but I'm not sure if it can be ignored and we should just change the value for 1.29, any idea to solve will be appreciated.

@mbcosta mbcosta force-pushed the 15.0-FIX-test_account_invoice_pricelist branch from b700f23 to 936a3ce Compare May 18, 2023 22:05
@mbcosta mbcosta force-pushed the 15.0-FIX-test_account_invoice_pricelist branch from 936a3ce to 714cdd3 Compare May 19, 2023 01:49
@mbcosta
Copy link
Contributor Author

mbcosta commented May 19, 2023

Unnecessary get the Default Values to the creation of Product Template in the tests. The problem in sale_timesheet_invoice_description was solved in #1458

Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

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

good one @mbcosta !

@rvalyi
Copy link
Member

rvalyi commented May 19, 2023

really the _get_real_price_currency method that is checked by the hash was in the sale/models/sale.py file in v14 https://github.com/odoo/odoo/blob/14.0/addons/sale/models/sale.py#LL1831C1-L1874C74 and in the sale/models/sale_line.py file in v15 https://github.com/odoo/odoo/blob/15.0/addons/sale/models/sale_order_line.py#LL742C1-L785C74

But I checked there is no real difference just an unused variable price that is changed to _price in v15 to avoid a flake8 unused variable error, more specifically:

in v14:

[,,,]
            if pricelist_item.pricelist_id.discount_policy == 'without_discount':
                while pricelist_item.base == 'pricelist' and pricelist_item.base_pricelist_id and pricelist_item.base_pricelist_id.discount_policy == 'without_discount':
                    price, rule_id = pricelist_item.base_pricelist_id.with_context(uom=uom.id).get_product_price_rule(product, qty, self.order_id.partner_id)
                    pricelist_item = PricelistItem.browse(rule_id)

vs in v15:

[...]
            if pricelist_item.pricelist_id.discount_policy == 'without_discount':
                while pricelist_item.base == 'pricelist' and pricelist_item.base_pricelist_id and pricelist_item.base_pricelist_id.discount_policy == 'without_discount':
                    _price, rule_id = pricelist_item.base_pricelist_id.with_context(uom=uom.id).get_product_price_rule(product, qty, self.order_id.partner_id)
                    pricelist_item = PricelistItem.browse(rule_id)

as this is a very trivial test adjust, I take the liberty for fast tracking.

@rvalyi
Copy link
Member

rvalyi commented May 19, 2023

/ocabot merge patch

@mbcosta
Copy link
Contributor Author

mbcosta commented May 19, 2023

thanks @rvalyi , after the merge I'm think the PR #1439 can be closed.

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-1457-by-rvalyi-bump-patch, awaiting test results.

@OCA-git-bot
Copy link
Contributor

@rvalyi The merge process could not be finalized, because command git push origin 15.0-ocabot-merge-pr-1457-by-rvalyi-bump-patch:15.0 failed with output:

To https://github.com/OCA/account-invoicing
 ! [remote rejected]   15.0-ocabot-merge-pr-1457-by-rvalyi-bump-patch -> 15.0 (cannot lock ref 'refs/heads/15.0': is at f4b4644ca4046d60bc03d9552682684728549f57 but expected 77123d1561340db05bc9893d40605067747be7ad)
error: failed to push some refs to 'https://***@github.com/OCA/account-invoicing'

@OCA-git-bot OCA-git-bot merged commit c0696cb into OCA:15.0 May 19, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at f4b4644. 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.

3 participants