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

[11.0] [MIG] stock_quant_manual_assign #361

Closed
wants to merge 30 commits into from

Conversation

fanha99
Copy link
Contributor

@fanha99 fanha99 commented Dec 28, 2017

[11.0] [MIG] stock quant manual assign
please help to check, thx.

NOTE: in v11, the stock_quant is take different role in compare to v10.
This module must be stock lot/serial manual assign

avanzosc1 and others added 29 commits December 28, 2017 19:16
… the wizard of "quants Manual" and check availability.
* Extended usage in README
Conforms to the latest README template: bugtracker, runbot etc.
Fixes bugtracker URL on some modules.
States OCA as maintainer, removes other contributors from the 'Maintainer' section.
* Fix uom issue
* Convert move quantity in the default product uom to use the same uom as quant
[FIX] test_flake8

 [FIX]
 - use the already existing field product_qty
 - fix picking edition by warehouse user due to related none readonly field
@pedrobaeza pedrobaeza mentioned this pull request Dec 28, 2017
46 tasks
@pedrobaeza pedrobaeza added this to the 11.0 milestone Dec 28, 2017
@pedrobaeza
Copy link
Member

You can review other PRs and ask in exchange that they review yours

@fanha99
Copy link
Contributor Author

fanha99 commented Dec 28, 2017

Hi,
Am I need to fix all the test_flake8 in the Travis-CI, most of them is "line too long (96 > 79 characters)"?

2 other Travis-CI report is relative to the "test_stock_quant_manual_assign.py" which is from v9.0 -> v10.0. I just don't know how to use them. is there any document about the it? Is that good to remove them?

@pedrobaeza
Copy link
Member

You should fix everything, and test shouldn't be removed, but fixed. Tests assures that everything goes correct. Tests can fail because:

  • The migration is not correct and it's not covering the expected results.
  • Something in the code has changed (field names, model names, method names...) and you need to adapt the test to this new situation.

@rousseldenis
Copy link
Sponsor Contributor

@fanha99 The quantity field in stock.quant model has changed.

It's called 'quantity' now (old name : qty).

@fanha99
Copy link
Contributor Author

fanha99 commented Dec 30, 2017

@rousseldenis, thanks. I can run the test now. but there are still bugs
is there a document online about how to debug the test?

@fanha99 fanha99 force-pushed the 11.0-mig-stock_quant_manual_assign branch from fb31d5e to 340afb7 Compare January 6, 2018 15:37
@fanha99
Copy link
Contributor Author

fanha99 commented Feb 9, 2018

@DbTechGit you can try this module to "lock" assigned serial

@fanha99 fanha99 force-pushed the 11.0-mig-stock_quant_manual_assign branch from 340afb7 to 7850ab9 Compare July 23, 2018 10:24
@rousseldenis
Copy link
Sponsor Contributor

@fanha99 Is this ok ?

@fanha99
Copy link
Contributor Author

fanha99 commented Oct 3, 2018

@rousseldenis : i'm using this module in our production Odoo. I think it is ok for us. :)

  • it is work well on PC, but not good on the mobile interface (as some problem with the kanban refresh)
  • it will not work in case the stock move don't have the init demand quantity. because the module check and don't allow user to transfer the quantity is bigger then init demand quantity.

Copy link
Sponsor Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

Code review

self.env['stock.quant'].quants_reserve(quants, move)
move._do_unreserve()
for line in self.quants_lines:
if line.qty > 0:
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

@fanha99 Please use float_compare

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I use math.isclose(line.qty, 0.0, rel_tol=1e-6)
the math.isclose is with the python 3.5

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

No, Odoo orm uses a layer on top of some float fields to interpret what is stored in database. These fields are defined with decimal precision. So, to interpret values, you have to use orm-integrated functions as float_compare. Other libraries are useless.

move.product_id,
move.location_id,
lot_id=line.lot_id)
if available_quantity <= 0:
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Maybe a float_compare on this should be used too

line['qty'] = 0
move_lines = move.move_line_ids.filtered(
lambda ml:
ml.location_id == x.location_id and ml.lot_id == x.lot_id)
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

I think this is too restrictive (or I don't understand the flow) ? IMHO you have to add condition as you maybe want to match quants that don't have lot if move line has no lot.

... and (ml.lot_id == False and x.lot_id = False or ml.lot_id == x.lot_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

multi locations?
when the delivery order is form location A, you could not choice the product from location B to send out.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

On move lines, you can have multiple locations if products come from children of move location.

Try to store product A in STOCK > Shelf 1 and product B in STOCK > Shelf 2. Create a picking from stock to out with product A and product B.

Moves are from stock to out and move lines are from children locations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these lines of code is getting the correct reserved quant/lot info (form previous action) and display to the wizard form.

wizard.lines_qty)
for quant in self.move.reserved_quant_ids:
self.assertTrue(quant in selected_quants)
# self.assertEqual(len(wizard.quants_lines.filtered('selected')),
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Please remove comments if they are not needed

<field name="in_date" />
<field name="lot_id" />
<field name="package_id" />
<field name="lot_id" readonly="1"/>
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Why changing to readonly from v10 ? Is the flow changed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these fields were set to readonly in the python code. Just not remember why need to set readonly the the xml view too. maybe there are bugs or somethings else.
will double check.
there are 10 months since the last commit (Dec 28, 2017).

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Ok, no problem. Try to make this merged.

@cubells
Copy link
Sponsor Member

cubells commented Oct 11, 2018

@fanha99 can I push to this repository and finish this pull request?

@fanha99
Copy link
Contributor Author

fanha99 commented Oct 11, 2018

@cubells : yes, please :)

@fanha99 fanha99 force-pushed the 11.0-mig-stock_quant_manual_assign branch from aea7c2e to 4a3a6d2 Compare October 17, 2018 09:09
@LoisRForgeFlow
Copy link
Contributor

@fanha99 Thanks for the work here!

I just tested it on runbot and it does not work as I expected if you select quants in sublocations. Example:
image

In the example above I select the quant in the small refrigerator and confirm. After that the quantity reserved is still 0.
image

@LoisRForgeFlow LoisRForgeFlow changed the title [11.0] [MIG] stock quant manual assign [11.0] [MIG] stock_quant_manual_assign Nov 9, 2018
@pedrobaeza
Copy link
Member

This is because there's no stock.move.line created.

Copy link
Sponsor Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

Code review. LGTM. Could you attend @lreficent remarks?

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

This is not relevant

@pedrobaeza
Copy link
Member

@rousseldenis I don't think this is working properly. See our previous comments.

@cubells
Copy link
Sponsor Member

cubells commented Nov 10, 2018

I'm working on a pr to approve this pr.

@cubells
Copy link
Sponsor Member

cubells commented Nov 12, 2018

Superseded by #508

@pedrobaeza pedrobaeza closed this Nov 12, 2018
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.

None yet

10 participants