mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-27 01:52:02 +02:00
Initial commit: OCA Mrp packages (117 packages)
This commit is contained in:
commit
277e84fd7a
4403 changed files with 395154 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import switch_workcenter
|
||||
from . import res_config_settings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
workcenter_parent_level_empty = fields.Boolean(
|
||||
related="company_id.workcenter_parent_level_empty", store=True, readonly=False
|
||||
)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="mrp.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//div[@id='workorder_settings_dependencies']"
|
||||
position="after"
|
||||
>
|
||||
<div
|
||||
id="workcenter_hierarchy"
|
||||
class="row mt-2"
|
||||
attrs="{'invisible': [('group_mrp_routings','=',False)]}"
|
||||
>
|
||||
<field
|
||||
name="workcenter_parent_level_empty"
|
||||
class="col flex-grow-0 ml16 mr0 pe-2"
|
||||
/>
|
||||
<div class="col ps-0">
|
||||
<label for="workcenter_parent_level_empty" />
|
||||
<div class="text-muted">
|
||||
The parent level on workcenters will be empty if case of there are no parent/great parent or more.
|
||||
On the contrary, by default, the parent level are always set, allowing a view by workorder grouped by top parent workcenter
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import _, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class SwitchWorkcenter(models.TransientModel):
|
||||
_name = "switch.workcenter"
|
||||
_description = "Switch Workcenter onf workorders"
|
||||
|
||||
workcenter_id = fields.Many2one("mrp.workcenter", "Workcenter", required=True)
|
||||
parent_workcenter_id = fields.Many2one(
|
||||
"mrp.workcenter", "Parent Workcenter", required=True
|
||||
)
|
||||
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
wos = self.env["mrp.workorder"].browse(self.env.context.get("active_ids", []))
|
||||
if any([wo.state in ("done", "cancel") for wo in wos]):
|
||||
raise UserError(
|
||||
_(
|
||||
"You can not change the workcenter of an in progress or done "
|
||||
"operation"
|
||||
)
|
||||
)
|
||||
|
||||
workcenter = wos.workcenter_id
|
||||
if len(workcenter) != 1:
|
||||
raise UserError(
|
||||
_(
|
||||
"You can only change the workcenter of workorders belonging to the "
|
||||
"same workcenter"
|
||||
)
|
||||
)
|
||||
parent_level_1_id = workcenter.parent_level_1_id.id
|
||||
if not parent_level_1_id:
|
||||
raise UserError(
|
||||
_(
|
||||
"The present workcenter of the workorders does not belong to any "
|
||||
"group of workcenter. It can't be switched"
|
||||
)
|
||||
)
|
||||
res["parent_workcenter_id"] = workcenter.parent_level_1_id.id
|
||||
return res
|
||||
|
||||
def switch_workcenter(self):
|
||||
self.ensure_one()
|
||||
active_ids = self.env.context.get("active_ids", [])
|
||||
vals = {"workcenter_id": self.workcenter_id.id}
|
||||
lines = self.env["mrp.workorder"].browse(active_ids)
|
||||
lines.write(vals)
|
||||
return True
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_wiz_switch_workcenter_form" model="ir.ui.view">
|
||||
<field name="model">switch.workcenter</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Switch Workcenter">
|
||||
<group col="4">
|
||||
<p colspan="4">
|
||||
Replace selected workcenters by another one.
|
||||
</p>
|
||||
<field name="parent_workcenter_id" invisible="1" />
|
||||
<field
|
||||
name="workcenter_id"
|
||||
domain="[('parent_level_1_id', '=', parent_workcenter_id)]"
|
||||
/>
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
name="switch_workcenter"
|
||||
string="Apply"
|
||||
type="object"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
or
|
||||
<button special="cancel" string="Cancel" class="oe_link" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_switch_workcenter" model="ir.actions.act_window">
|
||||
<field name="name">Switch Workcenter</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">switch.workcenter</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="binding_view_types">form,list</field>
|
||||
<field name="binding_model_id" ref="mrp.model_mrp_workorder" />
|
||||
<field name="view_id" ref="view_wiz_switch_workcenter_form" />
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue