Skip to content

Commit

Permalink
[8.0.1.0.0][stock_picking_wave_picking_selection]
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevhe18 authored and andhit-r committed Jan 26, 2018
1 parent 96ebfff commit 22462ba
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 0 deletions.
48 changes: 48 additions & 0 deletions stock_picking_wave_picking_selection/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

====================================
Stock Picking Wave Picking Selection
====================================

This module adds searching criteria for picking wave.

Installation
============

To install this module, you need to:

1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opnsynid-stock-logistics-workflow
2. Add the path to this repository in your configuration (addons-path)
3. Update the module list
4. Go to menu *Setting -> Modules -> Local Modules*
5. Search For *Stock Picking Wave Picking Selection*
6. Install the module

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/open-synergy/opnsynid-stock-logistics-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed
and welcomed feedback.


Credits
=======

Contributors
------------

* Michael Viriyananda <viriyananda.michael@gmail.com>

Maintainer
----------

.. image:: https://opensynergy-indonesia.com/logo.png
:alt: OpenSynergy Indonesia
:target: https://opensynergy-indonesia.com

This module is maintained by the OpenSynergy Indonesia.
5 changes: 5 additions & 0 deletions stock_picking_wave_picking_selection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions stock_picking_wave_picking_selection/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Automatic Picking Selection on Picking Wave",
"version": "8.0.1.0.0",
"category": "Stock Management",
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"stock_picking_wave",
"stock_transport_multi_address"
],
"data": [
"views/stock_picking_wave_view.xml"
],
}
5 changes: 5 additions & 0 deletions stock_picking_wave_picking_selection/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_picking_wave
110 changes: 110 additions & 0 deletions stock_picking_wave_picking_selection/models/stock_picking_wave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields, api, _
from openerp.exceptions import Warning as UserError


class StockPickingWave(models.Model):
_inherit = "stock.picking.wave"

delivery_address_ids = fields.Many2many(
string="Delivery Address",
comodel_name="res.partner",
relation="picking_wave_partner_rel",
column1="wave_id",
column2="partner_id",
)
picking_type_ids = fields.Many2many(
string="Picking Type",
comodel_name="stock.picking.type",
relation="picking_wave_picking_type_rel",
column1="wave_id",
column2="picking_type_id",
)
scheduled_date_start = fields.Datetime(
string="Scheduled Date Start"
)
scheduled_date_end = fields.Datetime(
string="Scheduled Date End"
)
creation_date_start = fields.Datetime(
string="Creation Date Start"
)
creation_date_end = fields.Datetime(
string="Creation Date End"
)

@api.constrains(
"scheduled_date_start", "scheduled_date_end")
def _check_scheduled_date(self):
strWarning = _(
"Scheduled Date Start must be greater than Scheduled Date End")
if self.scheduled_date_start and self.scheduled_date_end:
if self.scheduled_date_start > self.scheduled_date_end:
raise UserError(strWarning)

@api.constrains(
"creation_date_start", "creation_date_end")
def _check_creation_date(self):
strWarning = _(
"Creation Date Start must be greater than Creation Date End")
if self.creation_date_start and self.creation_date_end:
if self.creation_date_start > self.creation_date_end:
raise UserError(strWarning)

@api.multi
def _prepare_picking_search(self):
self.ensure_one()
criteria = []

scheduled_date_start = self.scheduled_date_start
scheduled_date_end = self.scheduled_date_end
creation_date_start = self.creation_date_start
creation_date_end = self.creation_date_end
delivery_address_ids = self.delivery_address_ids
picking_type_ids = self.picking_type_ids

if scheduled_date_start:
criteria.append(
("min_date", ">=", scheduled_date_start)
)
if scheduled_date_end:
criteria.append(
("min_date", "<=", scheduled_date_end)
)
if creation_date_start:
criteria.append(
("date", ">=", creation_date_start)
)
if creation_date_end:
criteria.append(
("date", "<=", creation_date_end)
)
if delivery_address_ids:
criteria.append(
("delivery_address_id", "in", delivery_address_ids.ids)
)
if picking_type_ids:
criteria.append(
("picking_type_id", "in", picking_type_ids.ids)
)
return criteria

@api.multi
def button_search_pickings(self):
obj_stock_picking = self.env["stock.picking"]

criteria = self._prepare_picking_search()
criteria.append(
("wave_id", "=", False)
)
criteria.append(
("state", "not in", ("cancel", "done"))
)
picking_ids = obj_stock_picking.search(criteria)
if picking_ids:
self.picking_ids = [(6, 0, picking_ids.ids)]
else:
self.picking_ids = [(6, 0, [])]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="stock_picking_wave_view_form" model="ir.ui.view">
<field name="name">Inherit: Stock Picking Wave Picking Selection Form</field>
<field name="model">stock.picking.wave</field>
<field name="inherit_id" ref="stock_picking_wave.view_picking_wave_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='picking_ids']" position="before">
<group name="group_1">
<button
name="button_search_pickings"
type="object"
string="Search"
icon="gtk-find"
attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}"
/>
</group>
<group name="group_2" colspan="4" col="2">
<group name="group_2_1" colspan="1" col="2">
<field name="scheduled_date_start" string="Schedule Date" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}"/>
<field name="scheduled_date_end" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}"/>
</group>
<group name="group_2_2" colspan="1" col="2">
<field name="creation_date_start" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}"/>
<field name="creation_date_end" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}"/>
</group>
</group>
<group name="group_3" colspan="4" col="2">
<field name="delivery_address_ids" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}" widget="many2many_tags"/>
<field name="picking_type_ids" attrs="{'invisible': [('state', 'not in', ('draft', 'in_progress'))]}" widget="many2many_tags"/>
</group>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

0 comments on commit 22462ba

Please sign in to comment.