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

[IMP] mrp_workorder: flexible component consumption #31473

Closed
wants to merge 2 commits into from

Conversation

Projects
None yet
6 participants
@Whenrow
Copy link
Contributor

commented Feb 27, 2019

Purpose: The quantities to consume on Bill of Material lines should be
either strictly used or be taken as a reference more or less adjustable.

This commit adds a setting on BoM to specify if the consumption is 'strict'
or 'flexible'. This new option has the following impacts:

  • On produce wizard: if consumption is set to 'strict', the done quantities
    are prefilled and locked in read only mode. Changing the quantity to
    produce will, as done before, update the components to consume but the
    manufacturing user cannot change them by hand.
    If set to 'flexible', the production flow remains the same as present
    one.
  • On workorders: if consumption is set to 'strict', the Validate button
    will save the consumed data, and propose to fill the remaining ones until
    the total is registered. If set to 'flexible', two button are displayed.
    'Validate' to register the current component and pass to next step either
    the quantity to consume is complete or not, and 'Continue Consumption'
    to registered the current component quantity but leaving the user the
    possibility to add more quantity (and possibly another lot number) for
    the current component

Task: 1889393

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo robodoo added the seen 🙂 label Feb 27, 2019

@C3POdoo C3POdoo added the RD label Feb 27, 2019

addons/mrp/models/mrp_abstract_workorder.py Outdated
@@ -17,6 +17,7 @@ class MrpAbstractWorkorder(models.AbstractModel):
product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure', required=True, readonly=True)
final_lot_id = fields.Many2one('stock.production.lot', string='Lot/Serial Number', domain="[('product_id', '=', product_id)]")
product_tracking = fields.Selection(related="product_id.tracking")
consumption = fields.Selection(related="production_id.bom_id.consumption")

This comment has been minimized.

Copy link
@fmdl

fmdl Feb 27, 2019

Contributor

it could be better that this field in dependant of the bom, (it is set during the workorder creation). like this if we change the consuption on the bom, on the already created workorder the beavior don't change.

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch 3 times, most recently Mar 4, 2019

@robodoo robodoo added the CI 🤖 label Mar 5, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch Mar 7, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 7, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch Mar 12, 2019

@robodoo robodoo removed the CI 🤖 label Mar 12, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch Mar 13, 2019

@robodoo robodoo added the CI 🤖 label Mar 13, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch to 56d9537 Mar 14, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 14, 2019

consumption = fields.Selection([
('strict', 'Strict'),
('flexible', 'Flexible')],
help=u"Defines if you can consume more or less components than the quantity defined on the BoM.",

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

why the u?

consumed_less_than_planned = fields.Boolean(
compute='_compute_consumed_less_than_planned',
help='Technical field used to see if we have to display a warning or not when confirming an order.')

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

you should write in the commit message you're essentially reverting d3617fd

@@ -109,7 +111,7 @@ def _record_production(self):
'name': order.name,
'reference': order.name,
'product_id': line.product_id.id,
'product_uom': line.product_uom_id.id,
'product_uom': line.product_id.uom_id.id,

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

useless

qty_done = sum(same_pp_line.mapped('qty_done'))
qty_to_consume = sum(same_pp_line.mapped('qty_to_consume'))
rounding = self.product_uom_id.rounding
if float_compare(qty_done, qty_to_consume, precision_rounding=rounding) == -1:

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

duplicated block, use a kwarg in the original method on abstract workorder and change it when used from the workorders

@@ -119,6 +121,8 @@ def _record_production(self):
})
line.move_id = move_id.id

if self.consumption == 'strict':
self._check_strict_consumption(self.workorder_line_ids)

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

i don't get why this check is done in the middle of everything, i would move it to the first line of record_production

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

now that we get why, add a comment "call _check_strict_consumption" when we are sur every workorder line has an associated move

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

move to the start of update raw move so that the code is shared for the tablet view

@@ -130,6 +134,16 @@ def _record_production(self):
'date_start': datetime.now(),
})

def _check_strict_consumption(self, lines_to_check):

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

lines_to_check is useless, self.workorder_line_ids will always contain everything...

rounding = self.product_uom_id.rounding
if float_compare(qty_done, qty_to_consume, precision_rounding=rounding) == 1:
raise UserError(_('You should consume the quantity of components defined in the BoM. If you want to consume more or less components, change the consumption setting on the BoM.'))
return lines_to_check

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Mar 21, 2019

Contributor

if you group self.workorder_line_ids by move you'll handle the bom with multiple times the same products and diffeent quantities

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch from 56d9537 to de54d09 Mar 21, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 21, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch from de54d09 to f24b4d4 Mar 21, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 21, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch from 5b66f42 to 9f96fbe Mar 25, 2019

@robodoo robodoo removed the CI 🤖 label Mar 25, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch 3 times, most recently from d5255ef to 19dbba9 Mar 25, 2019

@robodoo robodoo added the CI 🤖 label Mar 25, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch from 19dbba9 to 200bf6d Mar 27, 2019

@robodoo robodoo removed the CI 🤖 label Mar 27, 2019

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch 3 times, most recently from 41bb600 to 1876e4a Mar 27, 2019

@robodoo robodoo added the CI 🤖 label Mar 27, 2019

@amoyaux amoyaux force-pushed the odoo-dev:master-flexible-consumption-whe branch from 1876e4a to 54d94c4 Mar 27, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 27, 2019

Whenrow added some commits Mar 26, 2019

[IMP] mrp: flexible component consumption
Purpose: The quantities to consume on Bill of Material lines should be
either strictly used or be taken as a reference more or less adjustable.

This commit adds a setting on BoM to specify if the consumption is 'strict'
or 'flexible'. This new option has the following impacts:

   On produce wizard: if consumption is set to 'strict', the done quantities
   are prefilled and checked when saving the wizard. If set to 'flexible',
   the production flow remains the same as present one.

   On workorders: if consumption is set to 'strict', the Validate button
   will save the consumed data, and propose to fill the remaining ones until
   the total is registered. If set to 'flexible', two button are displayed.
   'Validate' to register the current component and pass to next step either
   the quantity to consume is complete or not, and 'Continue Consumption'
   to registered the current component quantity but leaving the user the
   possibility to add more quantity (and possibly another lot number) for
   the current component

This commit also revert partially d3617fd
as the warning become some sort of an error

Task: 1889393
[FIX] mrp: update test_order.py
- Add docstrings
- Use Form views in all tests
- Add some missing assets

@Whenrow Whenrow force-pushed the odoo-dev:master-flexible-consumption-whe branch from 54d94c4 to 894599c Mar 27, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 27, 2019

@amoyaux

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2019

robodoo r+ rebase-ff

@robodoo robodoo added the r+ 👌 label Mar 27, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2019

Merge method set to rebase and fast-forward

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2019

Linked pull request(s) odoo/enterprise#3737 not ready. Linked PRs are not staged until all of them are ready.

robodoo pushed a commit that referenced this pull request Mar 28, 2019

[FIX] mrp: update test_order.py
- Add docstrings
- Use Form views in all tests
- Add some missing assets

closes #31473

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
@robodoo

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2019

Merged, thanks!

@robodoo robodoo closed this Mar 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.