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

[FIX] stock_quantity_history_location: Migrate js to OWL #282

Conversation

rolandojduartem
Copy link
Contributor

@rolandojduartem rolandojduartem commented Aug 18, 2023

This commit solves the error
"Non loaded module
stock_quantity_history_location.InventoryReportListController" because
the dependency stock.InventoryReportListController was missed. The
dependency from stock was migrated to OWL [1], so it is inherited using the
OWL to preserve the behavior.

References:

@rolandojduartem
Copy link
Contributor Author

This is in development phase

@OCA-git-bot
Copy link
Contributor

Hi @luisg123v,
some modules you are maintaining are being modified, check this out!

@rolandojduartem rolandojduartem force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch 3 times, most recently from 77b0c2c to 9eab428 Compare August 19, 2023 20:48
@rolandojduartem
Copy link
Contributor Author

Hi, @luisg123v, @imanie383 and @desdelinux, please, could you review this PR? Do you know anything about the lint in the pre-commit?

@luisg123v
Copy link

Hi @sebasdrk17,

Could you review, please?

"stock_quantity_history_location/static/src/components"
"/inventory_report/inventory_report.js",
"stock_quantity_history_location/static/src/components/"
"inventory_report//inventory_report.xml",

Choose a reason for hiding this comment

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

Extra slash

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>

Choose a reason for hiding this comment

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

Add name

Choose a reason for hiding this comment

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

I meant ID:

Suggested change
<templates>
<templates id="template" xml:space="preserve">

<templates>
<t t-inherit="stock.InventoryReport.Buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//button[contains(@t-if, 'stock.quant')]" position="attributes">
<attribute name="t-if" add="and !this.multi_location" separator=" " />

Choose a reason for hiding this comment

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

There's no safe way to add conditions to an attribute, as order is not guaranteed

I'd suggest creating a <t t-if element and moving button there, and inserting the new button just after that element using t-else

"stock_quantity_history_location/static/src/xml/inventory_report.xml",
"stock_quantity_history_location/static/src/components"
"/inventory_report/inventory_report.js",
"stock_quantity_history_location/static/src/components/"
Copy link

@imanie383 imanie383 Aug 21, 2023

Choose a reason for hiding this comment

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

you are not importing any files in L22

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was importing the file.

Choose a reason for hiding this comment

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

@imanie383 to clarify, this is a multiline string, next line contains file name.

Choose a reason for hiding this comment

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

Up to you

you could just use a shortpath

stock_quantity_history_location/static/src/**/*.xml

example:
Screenshot 2023-08-21 at 1 06 39 p m

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know, but @luisg123v prefers explicit file paths when there are few files.

this._super(...arguments);
this.multi_location = false;
onWillStart(async () => {
this.multi_location = await session.user_has_group(

Choose a reason for hiding this comment

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

@rolandojduartem rolandojduartem force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch from 9eab428 to c19fc50 Compare August 21, 2023 17:57
@rolandojduartem
Copy link
Contributor Author

Hi, @luisg123v and @imanie383, I applied your suggestions.

@sebasdrk17
Copy link

@luisg123v Am I still needed here? I've seen that @imanie383 has already review

@luisg123v
Copy link

@luisg123v Am I still needed here? I've seen that @imanie383 has already review

@sebasdrk17 maybe not as needed anymore, but any comment is welcomed anyway.

<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-inherit="stock.InventoryReport.Buttons" t-inherit-mode="extension" owl="1">
<xpath expr="(//div/*)[last()]" position="after">

Choose a reason for hiding this comment

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

AFAIK this is inserting elements at the end, even after the "Appli All" button.

Maybe what you need is to place this before the "Apply All" button, by filtering by t-on-click="onClickApplyAll".

!props.context.inventory_mode
or props.context.inventory_report_mode
)
and !props.context.no_at_date

Choose a reason for hiding this comment

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

Add an ID to this button, so if we (or anybody else) migrate the module stock_account_quantity_history_location, xpaths are simpler

@@ -0,0 +1,17 @@
/** @odoo-module */

Choose a reason for hiding this comment

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

Suggested change
/** @odoo-module */
/** @odoo-module **/

@rolandojduartem rolandojduartem force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch 2 times, most recently from b89296a to 3226a7c Compare August 21, 2023 19:07
@rolandojduartem
Copy link
Contributor Author

Hi, @luisg123v and @imanie383, I applied your suggestions.

@imanie383 imanie383 force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch from 2132463 to dd88aeb Compare August 21, 2023 19:28
@rolandojduartem rolandojduartem force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch 2 times, most recently from 3226a7c to 8325609 Compare August 21, 2023 19:34
@rolandojduartem
Copy link
Contributor Author

Hi, @luisg123v and @imanie383, could you review this PR again? CI is green now

<t t-else="" name="has_not_multi_location" />
</button>
<t name="has_not_multi_location" position="inside">
<xpath expr="//button[contains(@t-if, 'stock.quant')]" position="move" />
Copy link

@imanie383 imanie383 Aug 21, 2023

Choose a reason for hiding this comment

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

image

Choose a reason for hiding this comment

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

Wait, I'm not sure why you need another button if your button is exactly the same as the original button(if and click-method)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, hasclass('o_button_at_date') is more ambiguous because stock_account add another button with that class, actually using the model is more specific for every button. What do you think? (This module will work together with stock_account_quantity_history_location if stock_account_quantity_history_location is migrated).

Choose a reason for hiding this comment

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

I agree with @rolandojduartem, current filter is preferred to using class.

Regarding this:

Wait, I'm not sure why you need another button if your button is exactly the same as the original button(if and click-method)

Because the text is different and there's no way to change or hide current text.

Copy link

@imanie383 imanie383 Aug 21, 2023

Choose a reason for hiding this comment

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

you can use a t-out like

<button t-out="'demo'">imanie</button>

that overwrites the inner text

<templates id="template" xml:space="preserve">
<t t-inherit="stock.InventoryReport.Buttons" t-inherit-mode="extension" owl="1">
<button t-on-click="onClickApplyAll" position="before">
<t t-if="this.multi_location" name="has_multi_location">
Copy link

@imanie383 imanie383 Aug 21, 2023

Choose a reason for hiding this comment

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

Suggested change
<t t-if="this.multi_location" name="has_multi_location">
<t t-if="multi_location" name="has_multi_location">

image

This commit solves the error
"Non loaded module
stock_quantity_history_location.InventoryReportListController" because
the dependency stock.InventoryReportListController was missed. The
dependency from stock was migrated to OWL [1], so it is inherited using the
OWL to preserve the behavior.

References:
- [1] odoo/odoo@ec0b1005
@rolandojduartem rolandojduartem force-pushed the 16.0-stock_quantity_history_location-migrate_to_owl-rolando branch from 8325609 to 5ae2895 Compare August 22, 2023 20:41
@rolandojduartem
Copy link
Contributor Author

Hi, @luisg123v and @imanie383, what do you think now? I could not make the groups attribute works for this inheritance, it would be great to remove the js file

Copy link

@luisg123v luisg123v left a comment

Choose a reason for hiding this comment

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

LGTM 👍

/ocabot merge nobump

Not increasing version because this change is already increasing it.

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-282-by-luisg123v-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit db10002 into OCA:16.0 Aug 22, 2023
6 checks passed
@OCA-git-bot
Copy link
Contributor

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

5 participants