Initialize v18 branch
Rename *_usability modules to *_usability_akretion
This commit is contained in:
3
mrp_usability_akretion/models/__init__.py
Normal file
3
mrp_usability_akretion/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import mrp_production
|
||||
from . import mrp_bom
|
||||
from . import product
|
||||
20
mrp_usability_akretion/models/mrp_bom.py
Normal file
20
mrp_usability_akretion/models/mrp_bom.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright 2021-2022 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MrpBom(models.Model):
|
||||
_inherit = 'mrp.bom'
|
||||
|
||||
code = fields.Char(tracking=50)
|
||||
type = fields.Selection(tracking=20)
|
||||
product_tmpl_id = fields.Many2one(tracking=10)
|
||||
product_id = fields.Many2one(tracking=15)
|
||||
product_qty = fields.Float(tracking=30)
|
||||
product_uom_id = fields.Many2one(tracking=35)
|
||||
ready_to_produce = fields.Selection(tracking=90)
|
||||
picking_type_id = fields.Many2one(tracking=60)
|
||||
consumption = fields.Selection(tracking=40)
|
||||
37
mrp_usability_akretion/models/mrp_production.py
Normal file
37
mrp_usability_akretion/models/mrp_production.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2015-2022 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import fields, models, Command
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
lot_producing_id = fields.Many2one(tracking=True)
|
||||
location_src_id = fields.Many2one(tracking=True)
|
||||
location_dest_id = fields.Many2one(tracking=True)
|
||||
bom_id = fields.Many2one(tracking=True)
|
||||
|
||||
# Target: allow to modify location_dest_id until the button 'Mark as done' is pushed
|
||||
# I didn't find a better implementation... feel free to improve if you find one
|
||||
def _compute_move_finished_ids(self):
|
||||
for prod in self:
|
||||
if prod.state not in ('draft', 'done') and prod.location_dest_id:
|
||||
vals = {'location_dest_id': prod.location_dest_id.id}
|
||||
prod.move_finished_ids = [
|
||||
Command.update(m.id, vals) for m in prod.move_finished_ids
|
||||
if m.state != 'done'
|
||||
]
|
||||
super()._compute_move_finished_ids()
|
||||
|
||||
# Method used by the report, inherited in this module
|
||||
# @api.model
|
||||
# def get_stock_move_sold_out_report(self, move):
|
||||
# lines = move.active_move_line_ids
|
||||
# qty_in_lots = sum([x.product_uom_qty for x in lines])
|
||||
# diff = round(move.product_qty - qty_in_lots, 3)
|
||||
# if diff == 0.0:
|
||||
# return ""
|
||||
# return diff
|
||||
46
mrp_usability_akretion/models/product.py
Normal file
46
mrp_usability_akretion/models/product.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright 2020-2022 Akretion France (http://www.akretion.com/)
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
def action_view_bom(self):
|
||||
"""Replace native action `template_open_bom` to distinguish if we will display
|
||||
only one BoM form or a list of BoMs."""
|
||||
self.ensure_one()
|
||||
if self.bom_count == 1:
|
||||
action_xml_id = "mrp.mrp_bom_form_action"
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id)
|
||||
bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)])
|
||||
action.update(
|
||||
{
|
||||
"context": {"default_product_tmpl_id": self.id},
|
||||
"views": False,
|
||||
"view_mode": "form,tree",
|
||||
"res_id": bom.id,
|
||||
}
|
||||
)
|
||||
else:
|
||||
action_xml_id = "mrp.template_open_bom"
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id)
|
||||
return action
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
def action_view_bom(self):
|
||||
action = super().action_view_bom()
|
||||
bom_target_ids = self.env["mrp.bom"].search(action["domain"])
|
||||
if len(bom_target_ids) == 1:
|
||||
action.update(
|
||||
{
|
||||
"views": False,
|
||||
"view_mode": "form,tree",
|
||||
"res_id": bom_target_ids[0].id,
|
||||
}
|
||||
)
|
||||
return action
|
||||
Reference in New Issue
Block a user