Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button on top right to link to transit moves on sale and purchase…
…s forms
- Loading branch information
1 parent
637a019
commit 630f115
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import stock_move | ||
from . import shipment_plan | ||
from . import sale_order | ||
from . import purchase_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# | ||
# Author: Yannick Vaucher | ||
# Copyright 2015 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more description. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# | ||
from openerp import models, fields, api | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = 'purchase.order' | ||
|
||
to_transit_moves_count = fields.Integer( | ||
compute='_count_to_transit_moves' | ||
) | ||
|
||
@api.multi | ||
def _get_to_transit_moves(self): | ||
""" Get moves related to Purchase order going to transit location""" | ||
moves = self.picking_ids.mapped('move_lines') | ||
return moves.filtered( | ||
lambda rec: rec.location_dest_id.usage == 'transit') | ||
|
||
@api.one | ||
@api.depends('picking_ids.move_lines.location_dest_id.usage') | ||
def _count_to_transit_moves(self): | ||
""" Count moves related to Purchase order going to transit location""" | ||
self.to_transit_moves_count = len(self._get_to_transit_moves()) | ||
|
||
@api.multi | ||
def action_open_to_transit_moves(self): | ||
""" Open move list view of to transit moves """ | ||
action_ref = ('stock_shipment_management' | ||
'.action_move_transit_pipeline_waiting') | ||
action_dict = self.env.ref(action_ref).read()[0] | ||
moves = self._get_to_transit_moves() | ||
action_dict['domain'] = [('id', 'in', moves.ids)] | ||
return action_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# | ||
# Author: Yannick Vaucher | ||
# Copyright 2015 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more description. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# | ||
from openerp import models, fields, api | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
to_transit_moves_count = fields.Integer( | ||
compute='_count_to_transit_moves' | ||
) | ||
|
||
@api.multi | ||
def _get_to_transit_moves(self): | ||
""" Get moves related to Sale order going to transit location""" | ||
moves = self.picking_ids.mapped('move_lines') | ||
return moves.filtered( | ||
lambda rec: rec.location_dest_id.usage == 'transit') | ||
|
||
@api.one | ||
@api.depends('picking_ids.move_lines.location_dest_id.usage') | ||
def _count_to_transit_moves(self): | ||
""" Count moves related to Sale order going to transit location""" | ||
self.to_transit_moves_count = len(self._get_to_transit_moves()) | ||
|
||
@api.multi | ||
def action_open_to_transit_moves(self): | ||
""" Open move list view of to transit moves """ | ||
action_ref = ('stock_shipment_management' | ||
'.action_move_transit_pipeline_waiting') | ||
action_dict = self.env.ref(action_ref).read()[0] | ||
moves = self._get_to_transit_moves() | ||
action_dict['domain'] = [('id', 'in', moves.ids)] | ||
return action_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="purchase_order_form_2_in_transit_moves" model="ir.ui.view"> | ||
<field name="name">purchase.order.form</field> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_2_stock_picking"/> | ||
<field name="arch" type="xml"> | ||
|
||
<xpath expr="//div[@name='buttons']" position="inside"> | ||
<button class="oe_inline oe_stat_button" name="action_open_to_transit_moves" | ||
type="object" icon="fa-upload"> | ||
<field string="To transit moves" name="to_transit_moves_count" widget="statinfo" /> | ||
</button> | ||
</xpath> | ||
|
||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="view_order_form" model="ir.ui.view"> | ||
<field name="name">sale.order.form</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
<field name="arch" type="xml"> | ||
|
||
<h1 position="before"> | ||
<div class="oe_right oe_button_box" style="width: 300px;" name="buttons"> | ||
<button class="oe_inline oe_stat_button" name="action_open_to_transit_moves" | ||
type="object" icon="fa-upload"> | ||
<field string="To transit moves" name="to_transit_moves_count" widget="statinfo" /> | ||
</button> | ||
</div> | ||
</h1> | ||
|
||
</field> | ||
</record> | ||
</data> | ||
</openerp> |