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

Closed
wants to merge 2 commits into 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

@@ -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 _(

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Oct 9, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from c78e195 to 93e9c35 Oct 14, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Oct 14, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from 93e9c35 to a32f245 Oct 14, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Oct 14, 2019
@@ -312,7 +324,7 @@ class MrpAbstractWorkorderLine(models.AbstractModel):
lot_id = fields.Many2one(
'stock.production.lot', 'Lot/Serial Number',
check_company=True,
domain="[('product_id', '=', product_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]")
domain="[('product_id', '=', product_id), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]")

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Oct 15, 2019

Contributor

shoudln't this one go in v13?

@@ -31,7 +31,7 @@
<field name="raw_workorder_line_ids" attrs="{'invisible': [('raw_workorder_line_ids', '=', [])]}" nolabel="1" context="{'w_production': True, 'active_id': production_id, 'default_finished_lot_id': finished_lot_id}">
<tree editable="top" delete="0" decoration-danger="(qty_to_consume &lt; qty_done)">
<field name="company_id" invisible="1"/>
<field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" force_save="1"/>
<field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" force_save="1"/>

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Oct 15, 2019

Contributor

v13?

@@ -47,7 +47,7 @@
<field name="finished_workorder_line_ids" attrs="{'invisible': [('finished_workorder_line_ids', '=', [])]}" nolabel="1" context="{'w_production': True, 'active_id': production_id, 'default_finished_lot_id': finished_lot_id}">
<tree editable="top" delete="0" decoration-danger="(qty_to_consume &lt; qty_done)">
<field name="company_id" invisible="1"/>
<field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" force_save="1"/>
<field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" force_save="1"/>

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Oct 15, 2019

Contributor

v13?

@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from a32f245 to b7a8d98 Oct 16, 2019
@robodoo robodoo removed the CI 🤖 label Oct 16, 2019
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from b7a8d98 to d2d1694 Oct 16, 2019
Whenrow added 2 commits 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
This commit redo the way workorders are planned on their workcenter
calendar. The resource_calendar_leaves introduced in 0679d0d is now linked
to the effetives dates (date_start and date_finished).
The planned dates copy their information onto effective date at the
workorder plannification or any modification before the actual production
(state = draft, pending or ready)

This way, the gantt view and calendar view display either the plannifaction
slot if the production isn't started yet and the effective production
time if it's done. The plannification is also impacted by validating
a production sooner than expected or cancelling it. In the first case,
the date_finished is set at 'now' and in the second case, all the dates
are emptied. The futur workorders will be planned on the newly recover
time slot.

This commit also fix the button_start() method that always rewrite the
date_start even if the production had already been started.

Task : 2082442
@Whenrow Whenrow force-pushed the odoo-dev:master-warning-sn-mrp-whe branch from d2d1694 to 82b0740 Oct 16, 2019
@robodoo robodoo added the CI 🤖 label Oct 16, 2019
@amoyaux

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2019

robodoo r+

@robodoo robodoo added the r+ 👌 label Oct 16, 2019
@amoyaux

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2019

robodoo rebase-ff

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2019

Merge method set to rebase and fast-forward

robodoo pushed a commit that referenced this pull request Oct 16, 2019
This commit redo the way workorders are planned on their workcenter
calendar. The resource_calendar_leaves introduced in 0679d0d is now linked
to the effetives dates (date_start and date_finished).
The planned dates copy their information onto effective date at the
workorder plannification or any modification before the actual production
(state = draft, pending or ready)

This way, the gantt view and calendar view display either the plannifaction
slot if the production isn't started yet and the effective production
time if it's done. The plannification is also impacted by validating
a production sooner than expected or cancelling it. In the first case,
the date_finished is set at 'now' and in the second case, all the dates
are emptied. The futur workorders will be planned on the newly recover
time slot.

This commit also fix the button_start() method that always rewrite the
date_start even if the production had already been started.

Task : 2082442

closes #34038

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

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2019

Merged at 644663e, thanks!

@robodoo robodoo closed this Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.