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] mrp_mto_with_stock #255

Merged
merged 11 commits into from
Apr 10, 2018
Merged

Conversation

bodedra
Copy link
Member

@bodedra bodedra commented Feb 16, 2018

@pedrobaeza pedrobaeza mentioned this pull request Feb 16, 2018
25 tasks
@pedrobaeza pedrobaeza added this to the 11.0 milestone Feb 16, 2018
@bodedra bodedra force-pushed the 11.0-mig-mrp_mto_with_stock branch 2 times, most recently from 1d32e12 to 9ba29fc Compare February 19, 2018 07:12
@bodedra bodedra changed the title 11.0 mig mrp mto with stock [11.0][MIG] mrp_mto_with_stock Feb 19, 2018

<odoo> <data noupdate="1">

<record id="product_product_manufacture_1" model="product.product">
Copy link
Member

Choose a reason for hiding this comment

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

could be the occasion to fix this 8 spaces indentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have notice same. Somewhere I have read that formatting changes not allow. So ignore it. May we allow to fix it in XML files ?

Copy link
Member

Choose a reason for hiding this comment

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

Formatting changes are to avoid when you do a pull request for a change in an existing version. I'd say as we are doing a large diff anyway it could be the right moment to fix it. On the other hand, it can make the port of pull requests less easier. No strong opinion then.

Copy link
Member Author

@bodedra bodedra Feb 20, 2018

Choose a reason for hiding this comment

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

Corresponded. Thank you.

@api.multi
def _adjust_procure_method(self):
# Si location => By pass method...
super(MrpProduction, self)._adjust_procure_method()
Copy link
Member

Choose a reason for hiding this comment

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

The code is the same in the 10.0 version, but I don't see the point of it

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I am agree. We will remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Corresponded. Thank you.

@bodedra bodedra force-pushed the 11.0-mig-mrp_mto_with_stock branch from 77d6fde to e035400 Compare February 20, 2018 11:20
Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

Tested locally, does not work as expected.

if move.group_id:
domain.append(('group_id', '=', move.group_id.id))
procurement = self.env['procurement.order'].search(domain)
procurement = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you asuming that if you have group you don't have to procure?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lreficent will improve these. Appreciate your feedback.

@@ -68,18 +67,11 @@ def test_manufacture_with_forecast_stock(self):

self.assertEqual(self.production.availability, 'partially_available')

self.assertEquals(self.subproduct1.virtual_available, 0)
self.assertEquals(self.subproduct1.virtual_available, -3)
Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow Feb 22, 2018

Choose a reason for hiding this comment

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

Well, I didn't check in deep but my first thought here is that this is not the way to migrate tests. If tests are failing change the logic, don't adapt the result to what you are getting.

Copy link
Member Author

@bodedra bodedra Feb 23, 2018

Choose a reason for hiding this comment

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

@lreficent Here is explanation for -3 virtual quantity.

  • Update self.subproduct1 with 2 quantity and MO is generated with 5 quantity. So 2-5=-3

I will do more analysis on it and update you. Thanks for trigger.

Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow Feb 26, 2018

Choose a reason for hiding this comment

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

Yes, of course but the module should use that 2 units and then create a procurement for the remaining 3. The previous 0 was there for a reason, that's what I meant.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend you to review the functionality in v10 and understand it a little bit more and then come back to v11 so you will know what to expect and could figure out what to fix

Copy link
Member

Choose a reason for hiding this comment

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

@bodedra In v10, the method action_assign in https://github.com/OCA/manufacture/blob/10.0/mrp_mto_with_stock/models/mrp_production.py#L20 is supposed to create a new procurement order to fulfill the missing quantity of the component.

In v11, you need to migrate the method to create a new purchase order or manufacturing order (depending on the product configuration). This will increase the forecast quantity and it will match the expected quantity set in the tests.

Copy link

Choose a reason for hiding this comment

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

Not sure with the scope of this module, looking at the code I haven't seen regarding orderpoints on the procurement should we also need to consider it?

Copy link

Choose a reason for hiding this comment

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

If an MO that triggered for a PO is cancelled what would happen to the PO? What if PO is on Draft/RFQ state? How about if PO is on confirmed state?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lreficent @max3903 @agyamuta

I still have problem in following code.

qty_to_procure = move.remaining_qty - move.reserved_availability

Request to provide few guidance on it.

I have improved logic and test case. Would you please provide me feedback on it.

@jgrandguillaume
Copy link
Member

I agree with @lreficent, please do not merge this branch before fixing this properly (maening not the test result). @max3903 You can drop a card at us to help here if required.

@max3903 max3903 requested a review from agyamuta February 27, 2018 17:19
@bodedra bodedra force-pushed the 11.0-mig-mrp_mto_with_stock branch 3 times, most recently from b686d2a to f9a7832 Compare March 1, 2018 13:43
@bodedra
Copy link
Member Author

bodedra commented Mar 6, 2018

Hi All,

Following screen-shots represents test case in Odoo 10. It seems have problem in it.

Current behavior

  1. Create "P1" and "R1" product. Update "2" quantity of "R1" in location stock.

screenshot from 2018-03-06 17 19 40

screenshot from 2018-03-06 17 19 58

  1. "R1" product manufacturing MTO/MTS location configuration.

screenshot from 2018-03-06 17 45 14

  1. Create bill of materials of "P1" product.

screenshot from 2018-03-06 17 20 25

  1. Create manufacturing order of "P1" with quantity 12 and save it.

screenshot from 2018-03-06 17 20 54

screenshot from 2018-03-06 17 21 23

  1. It will trigger purchase order for "R1" with 12 quantity as per our product configuration.

screenshot from 2018-03-06 17 21 30

  1. "R1" product quantity on hand and forecasted quantity.

screenshot from 2018-03-06 17 21 41

Expected behavior

First use 2 quantity in stock location and then create PO with 10 quantity to fulfil MO requirements.


Would you please correct me on these.

@lreficent May we do screen share via google hangout if possible for you?

@JordiBForgeFlow
Copy link
Member

JordiBForgeFlow commented Mar 6, 2018 via email

@bodedra
Copy link
Member Author

bodedra commented Mar 6, 2018

@jbeficent Appreciate your quick response. I have tested as per your suggested configuration and it creates PO with 10 quantity. I will start working on Odoo 11 to get same. Thank you.

@bodedra bodedra force-pushed the 11.0-mig-mrp_mto_with_stock branch from f9a7832 to fa27afd Compare March 7, 2018 12:32
@bodedra bodedra force-pushed the 11.0-mig-mrp_mto_with_stock branch from fa27afd to dab59bc Compare March 7, 2018 12:51
@max3903
Copy link
Member

max3903 commented Mar 15, 2018

@jbeficent What do you think if @bodedra adds an onchange or check the values when writing to avoid this misconfiguration?

@jgrandguillaume
Copy link
Member

Hi,

I think the best way to avoid this problem would be to refactor this module on this one:

https://github.com/OCA/stock-logistics-warehouse/tree/10.0/stock_mts_mto_rule

-> It means:

  • The MTS / MTO become a route (not an outside configuration)
  • The route uses a new method run (as buy or manufacture, we now have mts_mto

I don't know if I'm clear enough, but the idea is to bring this behavior through routes & run_* methods instead of overriding it like it has been done here... I think this would be the "ideal" way to bring this feature IMO.

Then, if too complicated or too much work at this stage, I understand..

Regards,

Joël

@florian-dacosta
Copy link
Contributor

I also think it could be more logical to use the routes/rules. But it seems kind of tricky to use route and pull rule... Hard to see a good solution here.

But, maybe we could use only the route.
This module could depend on stock_mts_mto_rule and override mrp.production's _adjust_procure_method function.
There, we can check if the product is configured with the mts+mto rule and then split each move into 2 if needed (depending on the quantity available).(one would be with procure_method 'make to order' and the other 'make to stock'
But it is weird to use a route for an other purpose than searching pull rules... In this solution, the route would be used like a pull rule in a way.
(I am not sure I am very clear!)

Anyway, I am not sure it is really better.

Copy link
Contributor

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

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

Thanks for the work!
Althought tests are green, I see 2 main problem.
One bug about mto_with_no_move_dest_id option, not yet showed by tests.
And the other is about useless procurement group creation, unless I miss understood this part.

# Search procurement group which has created from here
group_name = '{0}:{1}'.format(
production.name, move.product_id.name)
procurement = procurement_obj.search(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get this part. Why are you (later) creating a new procurement group? I don't think it is needed.

new_move = move
pg_data = production._get_procurement_group_data(
new_move)
group = procurement_obj.create(pg_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing than before, I see no reason to create a procurement group, as it used only un run_procurement to find the origin. In that case, you can simply define a char origin variable instead of creating a record in Odoo!

qty_to_procure = production.get_mto_qty_to_procure(move)
if qty_to_procure > 0.0:
pg_data = production._get_procurement_group_data(move)
group = procurement_obj.create(pg_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue

def run_procurement(self, move, group, qty):
self.ensure_one()
errors = []
values = move._prepare_procurement_values()
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of mto_with_no_move_dest_id, you need to remove 'move_dest_ids' from values.
Else the 2 case handled in this module are the same.
Indeed, with mto_with_no_move_dest_id, we want to buy/manufacture to make the future qty (virtual qty) = 0
but we do not want to link the purchase/manufacture order to the stock move.

It would be nice to add a small test to show this issue.
It can be easily done, for instance, adding

self.production.action_assign()
self.assertEquals(self.production.move_raw_ids[0].state, 'assigned')

after https://github.com/ursais/manufacture/blob/dab59bcc211b61bab0f67486818bdaed38539e2a/mrp_mto_with_stock/tests/test_mrp_mto_with_stock.py#L77
Indeed, if you add this test with the present code, it will fail because the raw moves have ancestor and they should not.
Of course, the rest of the test may need to be adapted.

@florian-dacosta
Copy link
Contributor

florian-dacosta commented Apr 9, 2018

Hello,
I have fixed the 2 issues I talked about here : ursais#1
All seems good to me now

[11.0][mrp_mto_with_stock] Migration
Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

Tested on runbot. This looks good to me now!

Thanks @florian-dacosta and @bodedra

@max3903 max3903 merged commit 205015f into OCA:11.0 Apr 10, 2018
@max3903 max3903 deleted the 11.0-mig-mrp_mto_with_stock branch April 10, 2018 13:45
@bodedra
Copy link
Member Author

bodedra commented Apr 11, 2018

@florian-dacosta and @lreficent appreciate your support. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.