-
Notifications
You must be signed in to change notification settings - Fork 21
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
[14.0][ADD] mrp_production_batch: new module #338
base: 14.0
Are you sure you want to change the base?
Conversation
<field name="code">mrp.production.batch</field> | ||
<field name="prefix">MOB/</field> | ||
<field name="padding">5</field> | ||
<field name="company_id" eval="False" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No company??
production_batch_id = fields.Many2one( | ||
comodel_name="mrp.production.batch", | ||
string="Production Batch", | ||
readonly=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ondelete
attribute
def _check_production_to_batch_consitency(self, mrp_production_ids): | ||
if not mrp_production_ids: | ||
raise ValidationError(_("No productions selected")) | ||
if mrp_production_ids.mapped("production_batch_id"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just if mrp_productions.production_batch_id
, not needed in 14.0
raise ValidationError( | ||
_("Some of the selected productions are already done or cancelled") | ||
) | ||
picking_type_ids = mrp_production_ids.mapped("picking_type_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picking_types = mrp_production_ids.picking_type_id
readonly=True, | ||
) | ||
|
||
def _check_production_to_batch_consitency(self, mrp_production_ids): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember the guidelines + typo: consistency
def _check_production_to_batch_consistency(self, mrp_productions):
manufacturing_ids = fields.One2many( | ||
comodel_name="mrp.production.batch.line.wizard", | ||
inverse_name="mrp_production_batch_id", | ||
readonly=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already readonly=False
by default
for production in self.manufacturing_ids: | ||
production.production_batch_id = res.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be necessary
_name = "mrp.production.batch.line.wizard" | ||
_description = "MRP Production Line Batch wizard" | ||
|
||
mrp_production_batch_id = fields.Many2one( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to production_batch_wizard_id
from . import wizard_mrp_production_batch | ||
from . import wizard_mrp_production_batch_line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check OCA guidelines if this is the way to name wizards and also check the wizard filenames
|
||
|
||
class PickingType(models.Model): | ||
_inherit = "stock.picking.type" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This model is not stock.picking
it should be in a separate file stock_picking_type
. We use OCA guidelines not the Odoo ones...
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 14.0 #338 +/- ##
==========================================
- Coverage 44.98% 44.76% -0.23%
==========================================
Files 747 759 +12
Lines 12972 13313 +341
Branches 2836 2924 +88
==========================================
+ Hits 5835 5959 +124
- Misses 7005 7221 +216
- Partials 132 133 +1 ☔ View full report in Codecov by Sentry. |
a3d2b92
to
4f5b5be
Compare
).button_mark_done() | ||
except Exception: | ||
productions_display_name.append(production.display_name) | ||
if productions_display_name and len(productions_display_name) == len_production: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing this len(productions_display_name) == len_production
def action_generate_serial(self): | ||
for rec in self: | ||
for production in rec.production_wo_lot_producing_id: | ||
production.action_generate_serial() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to change this, the serial numbers should be generated at the time the MO is processed.
bc7b27e
to
a002267
Compare
a182fd1
to
f475b92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally:
- def action_generate_serial(self): this shouldn't be done in a separate step, this should be done seamlessly on process batch.
- Do an additional check on process batch. Just in case someone has changed something on a already marked "ready to process" production.
from odoo.exceptions import ValidationError | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = "mrp.production" | ||
|
||
is_ready_to_produce = fields.Boolean( | ||
store=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default, you don't need to specify this, please remove it
% rec.production_batch_id.name | ||
) | ||
elif rec.state == "done": | ||
if not self.env.context.get("mrp_production_batch_create"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency if mrp_production_batch_create
is a boolean
if not self.env.context.get("mrp_production_batch_create", False):
message = "The following productions could not be marked as 'done':\n" | ||
message += "\n".join(productions_not_ready) | ||
raise UserError(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message_l = [
"The following productions could not be marked as 'done':",
"\n".join(productions_not_ready)
]
raise UserError("\n".join(message_l))
message = "The following productions could not be marked as 'done':\n" | ||
message += "\n".join(productions_display_name) | ||
raise UserError(message) | ||
with self.env.cr.savepoint(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Environment as we discussed
).button_mark_done() | ||
raise ValidationError(raise_msg) | ||
except (ValidationError, UserError) as e: | ||
production.is_ready_to_produce = bool(e.name == raise_msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This willl be removed using the Environemtn approach
production.error_message = e.name | ||
else: | ||
production.error_message = False | ||
if not self.env.context.get("mrp_production_check"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not self.env.context.get("mrp_production_check", False):
productions = self.production_ids.filtered( | ||
lambda r: r.state not in ("cancel", "done") | ||
) | ||
productions = self.production_ids.filtered(lambda r: r.state != "cancel") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process all productions here and check before if all of them are in "ready" state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks!
… the recordset exists
26ee5c2
to
2b85d00
Compare
7428528
to
9f3dd72
Compare
…MO from a Batch and display a notification
No description provided.