Skip to content

Commit

Permalink
[MIG] repair_calendar_view: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
unaiberis committed Jul 8, 2024
1 parent 5296c16 commit 3972ca1
Show file tree
Hide file tree
Showing 56 changed files with 468 additions and 329 deletions.
1 change: 0 additions & 1 deletion mrp_repair_cancel_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import wizard
Expand Down
39 changes: 20 additions & 19 deletions mrp_repair_cancel_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
'name': 'MRP Repair Cancel Reason',
"name": "MRP Repair Cancel Reason",
"version": "16.0.1.0.0",
"license": 'AGPL-3',
"author": 'AvanzOSC',
'website': "http://www.odoomrp.com",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "https://github.com/avanzosc/mrp-repair-addons",
"contributors": [
"Ana Juaristi <[email protected]>",
"Alfredo de la Fuente <[email protected]>",
],
'category': 'Manufacturing',
'depends': ['product',
'stock',
'mrp',
'repair',
],
'data': ['security/ir.model.access.csv',
'data/repair_order_cancel_reason.xml',
'wizard/wiz_repair_order_cancel_reason_view.xml',
'views/repair_order_view.xml',
'views/repair_order_cancel_reason_view.xml',
],
'installable': True,
],
"category": "Manufacturing",
"depends": [
"product",
"stock",
"mrp",
"repair",
],
"data": [
"security/ir.model.access.csv",
"data/repair_order_cancel_reason.xml",
"wizard/wiz_repair_order_cancel_reason_view.xml",
"views/repair_order_view.xml",
"views/repair_order_cancel_reason_view.xml",
],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data noupdate="1">
<record id="mrp_cancel_reason_customer" model="repair.order.cancel.reason">
Expand Down
1 change: 0 additions & 1 deletion mrp_repair_cancel_reason/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import repair_order
18 changes: 10 additions & 8 deletions mrp_repair_cancel_reason/models/repair_order.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models, fields
from odoo import fields, models


class MrpRepair(models.Model):
_inherit = 'repair.order'
_inherit = "repair.order"

cancel_reason_id = fields.Many2one(
'repair.order.cancel.reason', string='Reason for cancellation',
readonly=True, ondelete='restrict')
"repair.order.cancel.reason",
string="Reason for cancellation",
readonly=True,
ondelete="restrict",
)


class MrpRepairCancelReason(models.Model):
_name = 'repair.order.cancel.reason'
_description = 'Repair Cancel Reason'
_name = "repair.order.cancel.reason"
_description = "Repair Cancel Reason"

name = fields.Char('Reason', required=True, translate=True)
name = fields.Char("Reason", required=True, translate=True)
1 change: 0 additions & 1 deletion mrp_repair_cancel_reason/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_repair_order_cancel_reason
55 changes: 31 additions & 24 deletions mrp_repair_cancel_reason/tests/test_repair_order_cancel_reason.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
import openerp.tests.common as common


class TestMrpRepairCancelReason(common.TransactionCase):

def setUp(self):
super(TestMrpRepairCancelReason, self).setUp()
self.data_model = self.env['ir.model.data']
self.repair_order_model = self.env['repair.order']
self.wiz_model = self.env['wiz.repair.order.cancel.reason']
self.product = self.env.ref('product.product_product_6')
self.warehouse = self.data_model.get_object('stock', 'warehouse0')
vals = {'product_id': self.product.id,
'location_id': self.warehouse.lot_stock_id.id,
'location_dest_id': self.warehouse.lot_stock_id.id,
'product_uom': self.product.uom_id.id}
super().setUp()
self.data_model = self.env["ir.model.data"]
self.repair_order_model = self.env["repair.order"]
self.wiz_model = self.env["wiz.repair.order.cancel.reason"]
self.product = self.env.ref("product.product_product_6")
self.warehouse = self.data_model.get_object("stock", "warehouse0")
vals = {
"product_id": self.product.id,
"location_id": self.warehouse.lot_stock_id.id,
"location_dest_id": self.warehouse.lot_stock_id.id,
"product_uom": self.product.uom_id.id,
}
self.repair_order = self.repair_order_model.create(vals)
self.reason = self.env.ref(
'repair_order_cancel_reason.mrp_cancel_reason_customer')
"repair_order_cancel_reason.mrp_cancel_reason_customer"
)

def test_wizard_cancel_draft_repair_with_reason(self):
vals = {'reason_id': self.reason.id}
vals = {"reason_id": self.reason.id}
wiz = self.wiz_model.create(vals)
wiz.with_context(active_ids=[self.repair_order.id]).confirm_cancel()
self.assertEqual(
self.repair_order.state, 'cancel',
'Repair order not in CANCEL state')
self.repair_order.state, "cancel", "Repair order not in CANCEL state"
)
self.assertEqual(
self.repair_order.cancel_reason_id.id, self.reason.id,
'Repair order canceled without cancel reason')
self.repair_order.cancel_reason_id.id,
self.reason.id,
"Repair order canceled without cancel reason",
)

def test_wizard_cancel_confirmed_repair_with_reason(self):
self.repair_order.signal_workflow('repair_confirm')
vals = {'reason_id': self.reason.id}
self.repair_order.signal_workflow("repair_confirm")
vals = {"reason_id": self.reason.id}
wiz = self.wiz_model.create(vals)
wiz.with_context(active_ids=[self.repair_order.id]).confirm_cancel()
self.assertEqual(
self.repair_order.state, 'cancel',
'Confirmed Repair order not in CANCEL state')
self.repair_order.state,
"cancel",
"Confirmed Repair order not in CANCEL state",
)
self.assertEqual(
self.repair_order.cancel_reason_id.id, self.reason.id,
'Confirmed Repair order canceled without cancel reason')
self.repair_order.cancel_reason_id.id,
self.reason.id,
"Confirmed Repair order canceled without cancel reason",
)
21 changes: 12 additions & 9 deletions mrp_repair_cancel_reason/views/repair_order_cancel_reason_view.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record model="ir.ui.view" id="repair_order_cancel_reason_form_view">
<field name="name">repair.order.cancel.reason.form.view</field>
<field name="model">repair.order.cancel.reason</field>
<field name="arch" type="xml">
<form string="Repair Cancel Reasons">
<field name="name"/>
<field name="name" />
</form>
</field>
</record>
<record model="ir.ui.view" id="repair_order_cancel_reason_tree_view">
<field name="name">repair.order.cancel.reason.tree.view</field>
<field name="model">repair.order.cancel.reason</field>
<field name="arch" type="xml">
<tree string="Repair Cancel Reasons" editable="bottom" >
<field name="name"/>
<tree string="Repair Cancel Reasons" editable="bottom">
<field name="name" />
</tree>
</field>
</record>
Expand All @@ -24,10 +24,13 @@
<field name="res_model">repair.order.cancel.reason</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_repair_order_cancel_reason"
parent="mrp.menu_mrp_manufacturing"
name="Repair Cancel Reasons"
action="action_repair_order_cancel_reason"
sequence="55" groups="mrp.group_mrp_user" />
<menuitem
id="menu_repair_order_cancel_reason"
parent="mrp.menu_mrp_manufacturing"
name="Repair Cancel Reasons"
action="action_repair_order_cancel_reason"
sequence="55"
groups="mrp.group_mrp_user"
/>
</data>
</openerp>
22 changes: 16 additions & 6 deletions mrp_repair_cancel_reason/views/repair_order_view.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record id="view_repair_order_form_inh_cancel_reason" model="ir.ui.view">
<field name="name">view.repair.order.form.inh.cancel.reason</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.view_repair_order_form"/>
<field name="inherit_id" ref="repair.view_repair_order_form" />
<field name="arch" type="xml">
<field name="guarantee_limit" position="after">
<field name="cancel_reason_id" />
</field>
<xpath expr="//button[@name='action_repair_cancel']" position="attributes">
<xpath
expr="//button[@name='action_repair_cancel']"
position="attributes"
>
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//button[@name='action_repair_cancel']" position="before">
<button name="%(action_repair_order_cancel_with_reason)d" string="Cancel Repair" type="action"
attrs="{'invisible':['|',('invoice_method','!=','none'), ('state', 'not in',('confirmed','2binvoiced','ready','under_repair', 'invoice_except'))]}"/>
<button
name="%(action_repair_order_cancel_with_reason)d"
string="Cancel Repair"
type="action"
attrs="{'invisible':['|',('invoice_method','!=','none'), ('state', 'not in',('confirmed','2binvoiced','ready','under_repair', 'invoice_except'))]}"
/>
</xpath>
<xpath expr="//button[@name='action_repair_cancel']" position="attributes">
<xpath
expr="//button[@name='action_repair_cancel']"
position="attributes"
>
<attribute name="invisible">True</attribute>
</xpath>
<!-- <xpath expr="//button[@name='action_repair_cancel']" position="after">
Expand Down
1 change: 0 additions & 1 deletion mrp_repair_cancel_reason/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import wiz_repair_order_cancel_reason
21 changes: 10 additions & 11 deletions mrp_repair_cancel_reason/wizard/wiz_repair_order_cancel_reason.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
# -*- coding: utf-8 -*-
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models, fields, api
from odoo import fields, models

QUOTATION_STATES = ['draft']
QUOTATION_STATES = ["draft"]


class WizMrpRepairCancelReason(models.TransientModel):

_name = 'wiz.repair.order.cancel.reason'
_description = 'Ask a reason from the repair cancellation'
_name = "wiz.repair.order.cancel.reason"
_description = "Ask a reason from the repair cancellation"

reason_id = fields.Many2one(
'repair.order.cancel.reason', string='Reason', required=True)
"repair.order.cancel.reason", string="Reason", required=True
)

def confirm_cancel(self):
self.ensure_one()
act_close = {'type': 'ir.actions.act_window_close'}
repair_ids = self.env.context.get('active_ids', False)
act_close = {"type": "ir.actions.act_window_close"}
repair_ids = self.env.context.get("active_ids", False)
if not repair_ids:
return act_close
assert len(repair_ids) == 1, "Only 1 repair ID expected"
repair = self.env['repair.order'].browse(repair_ids)
repair = self.env["repair.order"].browse(repair_ids)
repair.cancel_reason_id = self.reason_id.id
if repair.state in QUOTATION_STATES:
repair.signal_workflow('cancel')
repair.signal_workflow("cancel")
else:
repair.action_cancel()
return act_close
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record id="wiz_repair_order_cancel_reason_form_view" model="ir.ui.view">
Expand All @@ -11,27 +11,35 @@
repair.
</p>
<group>
<field name="reason_id" widget="selection"/>
<field name="reason_id" widget="selection" />
</group>
<footer>
<button name="confirm_cancel"
string="Confirm" type="object"
class="oe_highlight"/>
<button
name="confirm_cancel"
string="Confirm"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link"
special="cancel" />
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_repair_order_cancel_with_reason" model="ir.actions.act_window">
<record
id="action_repair_order_cancel_with_reason"
model="ir.actions.act_window"
>
<field name="name">Reason for the cancellation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wiz.repair.order.cancel.reason</field>
<field name="view_mode">form</field>
<field name="view_id" ref="mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view"/>
<field
name="view_id"
ref="mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view"
/>
<field name="target">new</field>
<!-- <field name="binding_model_id" ref="repair.order"/> -->
</record>
</record>
</data>
</openerp>
26 changes: 13 additions & 13 deletions mrp_repair_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
'name': 'MRP Repair Date',
"name": "MRP Repair Date",
"version": "16.0.1.0.0",
"license": 'AGPL-3',
"author": 'OdooMRP team,'
'AvanzOSC,'
'Serv. Tecnol. Avanzados - Pedro M. Baeza',
'website': "http://www.odoomrp.com",
"license": "AGPL-3",
"author": "OdooMRP team," "AvanzOSC," "Serv. Tecnol. Avanzados - Pedro M. Baeza",
"website": "https://github.com/avanzosc/mrp-repair-addons",
"contributors": [
"Ana Juaristi <[email protected]>",
"Oihane Crucelaegui <[email protected]>",
"Alfredo de la Fuente <[email protected]>",
],
'category': 'Manufacturing',
'depends': ['mrp_repair',
],
'data': ['views/mrp_repair_view.xml',
],
'installable': True,
],
"category": "Manufacturing",
"depends": [
"mrp_repair",
],
"data": [
"views/mrp_repair_view.xml",
],
"installable": True,
}
Loading

0 comments on commit 3972ca1

Please sign in to comment.