-
-
Notifications
You must be signed in to change notification settings - Fork 664
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] account_invoice_supplierinfo_update: fix updating the right supplierinfo #1697
Open
sebastienbeau
wants to merge
1
commit into
OCA:16.0
Choose a base branch
from
akretion:16.0-fix-updating-the-right-supplierinfo
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,106 @@ def setUpClass(cls, chart_template_ref=None): | |
cls.WizardUpdateSupplierinfo = cls.env["wizard.update.invoice.supplierinfo"] | ||
cls.ProductSupplierinfo = cls.env["product.supplierinfo"] | ||
|
||
def test_get_the_right_variant_supplierinfo(self): | ||
# Variant the product A and set a price on variation 1 | ||
tmpl_a = self.product_a.product_tmpl_id | ||
tmpl_a.write( | ||
{ | ||
"attribute_line_ids": [ | ||
( | ||
0, | ||
0, | ||
Comment on lines
+51
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicking, could be replaced by Command.create |
||
{ | ||
"attribute_id": self.env.ref( | ||
"product.product_attribute_2" | ||
).id, | ||
"value_ids": [ | ||
( | ||
6, | ||
0, | ||
Comment on lines
+59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here ( Command.set([...])) |
||
[ | ||
self.env.ref( | ||
"product.product_attribute_value_3" | ||
).id, | ||
self.env.ref( | ||
"product.product_attribute_value_4" | ||
).id, | ||
], | ||
) | ||
], | ||
}, | ||
) | ||
] | ||
} | ||
) | ||
product_a_1, product_a_2 = tmpl_a.product_variant_ids | ||
|
||
supplier_product_a_1 = self.env["product.supplierinfo"].create( | ||
[ | ||
{ | ||
"partner_id": self.invoice.supplier_partner_id.id, | ||
"product_tmpl_id": tmpl_a.id, | ||
"product_id": product_a_1.id, | ||
"price": 30, | ||
} | ||
] | ||
) | ||
|
||
# Set the variation 2 on the invoice and run the wizard | ||
self.line_a.write({"product_id": product_a_2, "price_unit": 400}) | ||
vals_wizard = self.invoice.check_supplierinfo().get("context", {}) | ||
line_ids = vals_wizard.get("default_line_ids", {}) | ||
|
||
self.assertEqual(line_ids[0][2]["current_price"], False) | ||
self.assertEqual(line_ids[0][2]["new_price"], 400.0) | ||
|
||
wizard = self.WizardUpdateSupplierinfo.create( | ||
{"line_ids": line_ids, "invoice_id": self.invoice.id} | ||
) | ||
wizard.update_supplierinfo() | ||
|
||
# Supplier of product_a_1 should be not updated and a new supplierinfo | ||
# have been created (to make it simple supplierinfo are always created | ||
# on template) | ||
self.assertEqual(supplier_product_a_1.price, 30) | ||
self.assertEqual(len(tmpl_a.seller_ids), 2) | ||
self.assertEqual(tmpl_a.seller_ids[1].price, 400) | ||
self.assertFalse(tmpl_a.seller_ids[1].product_id) | ||
|
||
def test_get_the_right_qty_supplierinfo(self): | ||
tmpl_a = self.product_a.product_tmpl_id | ||
self.env["product.supplierinfo"].create( | ||
[ | ||
{ | ||
"partner_id": self.invoice.supplier_partner_id.id, | ||
"product_tmpl_id": tmpl_a.id, | ||
"price": 500, | ||
"min_qty": 0, | ||
}, | ||
{ | ||
"partner_id": self.invoice.supplier_partner_id.id, | ||
"product_tmpl_id": tmpl_a.id, | ||
"price": 300, | ||
"min_qty": 20, | ||
}, | ||
] | ||
) | ||
|
||
vals_wizard = self.invoice.check_supplierinfo().get("context", {}) | ||
line_ids = vals_wizard.get("default_line_ids", {}) | ||
|
||
self.assertEqual(line_ids[0][2]["current_price"], 500) | ||
self.assertEqual(line_ids[0][2]["new_price"], 400.0) | ||
|
||
wizard = self.WizardUpdateSupplierinfo.create( | ||
{"line_ids": line_ids, "invoice_id": self.invoice.id} | ||
) | ||
wizard.update_supplierinfo() | ||
|
||
self.assertEqual(len(tmpl_a.seller_ids), 2) | ||
self.assertEqual(tmpl_a.seller_ids[0].price, 300) | ||
self.assertEqual(tmpl_a.seller_ids[1].price, 400) | ||
|
||
def test_update_pricelist_supplierinfo(self): | ||
# supplier invoice with pricelist supplierinfo to update and | ||
# product supplierinfo is on product_template | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"Information is a mass noun. It has no plural form"* so infos looks like informations which would be Frenglish and looks TinyERP. Better change that to supplier_info or supplier_data as you want.
#onestpasamiserieux
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.
Hi.
@rvalyi. We already talk about that in another PR. summary of the previous comments :
what you mention is not an OCA rule.
So if you want to introduce that new rule, please create a dedicated PR here https://github.com/OCA/odoo-community.org/tree/master/website/Contribution
In the meantime, please avoid to block valid PR.
Thanks !
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 didn't block, only suggest to use better variable names. When native English speakers read that they feel it's cheap while it's easy to improve.
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 set "changes requested". Could you remove it ?
Thanks !