Skip to content

Commit

Permalink
Merge pull request #225 from ursais/12-fieldservice_stock_add_direction
Browse files Browse the repository at this point in the history
[IMP] fieldservice_stock: Add direction to views
  • Loading branch information
max3903 authored May 31, 2019
2 parents 7a30c00 + 0752f5d commit c57c61e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 15 deletions.
2 changes: 1 addition & 1 deletion fieldservice_stock/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

REQUEST_STATES = [
('draft', 'Draft'),
('submit', 'Submitted'),
('submitted', 'Submitted'),
('open', 'In progress'),
('done', 'Done'),
('cancel', 'Cancelled')]
Expand Down
26 changes: 24 additions & 2 deletions fieldservice_stock/models/stock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2018 - TODAY, Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class StockRequest(models.Model):
Expand All @@ -11,7 +11,29 @@ class StockRequest(models.Model):
'fsm.order', string="FSM Order", ondelete='cascade',
index=True, copy=False)
direction = fields.Selection([('outbound', 'Outbound'),
('inbound', 'Inbound')], string='Direction')
('inbound', 'Inbound')],
string='Direction',
states={'draft': [('readonly', False)]},
readonly=True)

@api.onchange('direction', 'fsm_order_id')
def _onchange_location_id(self):
if self.direction == 'outbound':
# Inventory location of the FSM location of the order
self.location_id = \
self.fsm_order_id.location_id.inventory_location_id.id
else:
# Otherwise the stock location of the warehouse
self.location_id = \
self.fsm_order_id.warehouse_id.lot_stock_id.id

@api.model
def create(self, vals):
res = super().create(vals)
if 'fsm_order_id' in vals:
fsm_order = self.env['fsm.order'].browse(vals['fsm_order_id'])
fsm_order.write({'request_stage': 'draft'})
return res


class StockMoveLine(models.Model):
Expand Down
10 changes: 4 additions & 6 deletions fieldservice_stock/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class="oe_highlight" string="Set to Draft"/>
<button name="action_request_cancel"
attrs="{'invisible': [('request_stage', 'not in', ['draft','open'])]}"
type="object" class="oe_highlight" string="Cancel"/>
type="object" string="Cancel"/>
<field name='request_stage' widget="statusbar"/>
</header>
<group groups="stock.group_stock_user">
Expand All @@ -59,13 +59,11 @@
<field name="product_uom_qty"/>
<field name="qty_in_progress"/>
<field name="qty_done"/>
<field name="expected_date" invisible="1"/>
<field name="picking_policy"
invisible="1"/>
<field name="expected_date"/>
<field name="picking_policy" invisible="1"/>
<field name="warehouse_id" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="procurement_group_id"
invisible="1"/>
<field name="procurement_group_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="state"/>
</tree>
Expand Down
36 changes: 30 additions & 6 deletions fieldservice_stock/views/stock.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- Stock Request Views -->
<record id="stock_request_tree" model="ir.ui.view">
<field name="name">stock.request.tree.direction</field>
<field name="model">stock.request</field>
<field name="inherit_id" ref="stock_request.view_stock_request_tree"/>
<field name="arch" type="xml">
<field name="location_id" position="after">
<field name="direction"/>
</field>
</field>
</record>

<record id="stock_request_form" model="ir.ui.view">
<field name="name">stock.request.form.direction</field>
<field name="model">stock.request</field>
<field name="inherit_id" ref="stock_request.view_stock_request_form"/>
<field name="arch" type="xml">
<field name="location_id" position="after">
<field name="direction"/>
</field>
</field>
</record>

<!-- Menu Items -->
<menuitem id="menu_fsm_stock_request"
name="Stock Requests"
action="stock_request.action_stock_request_form"
parent="fieldservice.operations"
sequence="90"/>

<menuitem id="menu_fsm_product"
name="Products"
action="stock.product_template_action_product"
Expand All @@ -13,10 +43,4 @@
parent="fieldservice.reporting"
sequence="30"/>

<menuitem id="menu_fsm_stock_request"
name="Stock Requests"
action="stock_request.stock_request_order_action"
parent="fieldservice.operations"
sequence="20"/>

</odoo>

0 comments on commit c57c61e

Please sign in to comment.