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

Prevent using already produced serial number #34038

Open
wants to merge 3 commits into
base: master
from

Conversation

@Whenrow
Copy link
Contributor

commented Jun 11, 2019

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 Jun 11, 2019
@C3POdoo C3POdoo added the RD label Jun 11, 2019
@Whenrow Whenrow changed the title Prevent using already procuded serial number Prevent using already produced serial number Jun 12, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch 3 times, most recently Jun 12, 2019
@robodoo robodoo added the CI 🤖 label Jun 14, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch to 62512d3 Jun 25, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jun 25, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from 62512d3 Jun 26, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jun 26, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch Jun 27, 2019
@robodoo robodoo removed the CI 🤖 label Jun 27, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch Jun 27, 2019
@robodoo robodoo added the CI 🤖 label Jun 27, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch to 84bed01 Jun 27, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jun 27, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from 84bed01 to 0179768 Jul 2, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jul 2, 2019
('location_id', '=', self._get_production().location_src_id.id),
('location_dest_id', '=', self._get_production().production_location_id.id),
('qty_done', '=', 1),
('state', '=', 'done')

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Jul 2, 2019

Contributor

one state done, qty = 1 the other no state and qty_done > 0

@@ -154,6 +154,9 @@ def _search_date_planned_finished(self, operator, value):
def _onchange_finished_lot_id(self):
"""When the user changes the lot being currently produced, suggest
a quantity to produce consistent with the previous workorders. """
res = super(MrpWorkorder, self)._onchange_finished_lot_id()
if res:
return res

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Jul 2, 2019

Contributor

why?

This comment has been minimized.

Copy link
@Whenrow

Whenrow Jul 4, 2019

Author Contributor

because _onchange_finished_lot_id() on abstract_workorder could return a warning

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Jul 4, 2019

Contributor

don't shortcircuit here an make these ocnhange always return something

# Alert the user if this serial number as already been produced
sml = self.env['stock.move.line'].search_count([
('lot_id', '=', self.finished_lot_id.id),
('location_id', '=', self.production_id.production_location_id.id),

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Jul 4, 2019

Contributor

what if 1 company multipe warehouses multiple production_location?

@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from 0179768 to aa67d04 Jul 5, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jul 5, 2019
('lot_id', '=', self.finished_lot_id.id),
('location_id.usage', '=', 'production'),
('qty_done', '=', 1),
('state', '=', 'done')
])
if sml:
return {'warning': {
Comment for lines 53  – 59

This comment has been minimized.

Copy link
@Whenrow

Whenrow Oct 7, 2019

Author Contributor

test comment

@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from aa67d04 to 924bb53 Oct 7, 2019
@robodoo robodoo removed the CI 🤖 label Oct 7, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from 924bb53 to fa4e94b Oct 7, 2019
@robodoo robodoo added the CI 🤖 label Oct 7, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from fa4e94b to fabc5b1 Oct 7, 2019
@robodoo robodoo removed the CI 🤖 label Oct 7, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch 3 times, most recently from 935a72a to a26f6c6 Oct 7, 2019
@robodoo robodoo added the CI 🤖 label Oct 7, 2019
With this commit, the manufacturer will now be noticed earlier in
the process if he produced/consumed a serial number already produced/consumed in a
previous production. Before this commit, an error was triggered as
well but only at the very last step of the production.
This leaded to two issues :
 - The user had to unlock-edit-lock to update the wrong serial number
 - On large production, it was difficult to figure out which was/were
   the product(s) to fix.

The search on previous production is done each time the produce wizard is closed
or once the production is done on a workorder

Task 2002133
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from a26f6c6 to 099f7d4 Oct 8, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Oct 8, 2019
The company_id on product_produce_line is a computed field due to the
relation with abstract workorder model. This emplies the company_id of
new line in the produce wizard is still blanck. Therefore, the domains on
product_id and lot_id are wrongly executed.

This commit uses parent.company_id in the domains. Which means the wizard
itself.
@@ -362,7 +374,10 @@ def _update_move_lines(self):
raise UserError(_('Please enter a lot or serial number for %s !' % self.product_id.display_name))

if self.lot_id and self.product_id.tracking == 'serial' and self.lot_id in self.move_id.move_line_ids.filtered(lambda ml: ml.qty_done).mapped('lot_id'):
raise UserError(_('You cannot consume the same serial number twice. Please correct the serial numbers encoded.'))
if self[self._get_raw_workorder_inverse_name()]:
raise UserError(_('The serial number used for component %s has already been consumed' % self.product_id.name))

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Oct 9, 2019

Contributor

wrong call to _(

self._check_company()
if float_compare(self.qty_producing, 0, precision_rounding=self.product_uom_id.rounding) <= 0:
raise UserError(_('Please set the quantity you are currently producing. It should be different from zero.'))

if 'check_ids' not in self:

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Oct 9, 2019

Contributor

we need a better way to know if mrp_workorder is installed or not :)

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.