Skip to content

Commit

Permalink
[MIG] sale_procurement_group_by_requested_date v10
Browse files Browse the repository at this point in the history
  • Loading branch information
nikul-serpentcs committed Apr 5, 2018
1 parent 7e45d35 commit c1ad3b3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 47 deletions.
2 changes: 1 addition & 1 deletion sale_procurement_group_by_requested_date/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Usage

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/9.0
:target: https://runbot.odoo-community.org/runbot/167/10.0


Bug Tracker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Group procurements by requested date",
"summary": "Groups pickings based on requested date of order line",
"version": "9.0.1.0.0",
"version": "10.0.1.0.0",
"category": "Sales Management",
"website": "http://www.eficent.com",
"author": "Eficent , "
Expand Down
12 changes: 9 additions & 3 deletions sale_procurement_group_by_requested_date/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

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


class SaleOrder(models.Model):
Expand All @@ -16,9 +16,11 @@ def _prepare_procurement_group_by_line(self, line):
req_datetime = fields.Datetime.from_string(line.requested_date)
req_date = fields.Date.to_string(req_datetime)
if line._get_procurement_group_key()[0] == 12:
if line.requested_date:
if line.requested_date and line.warehouse_id:
vals['name'] = '/'.join([vals['name'], line.warehouse_id.name,
req_date])
elif line.requested_date and not line.warehouse_id:
vals['name'] = '/'.join([vals['name'], req_date])
return vals


Expand All @@ -33,7 +35,7 @@ def _prepare_order_line_procurement(self, group_id=False):
if self.requested_date:
req_datetime = fields.Datetime.from_string(self.requested_date)
req_date = fields.Date.to_string(req_datetime)
values['requested_date'] = req_date
values['date_planned'] = req_date
return values

@api.multi
Expand All @@ -50,6 +52,10 @@ def _get_procurement_group_key(self):
return key
req_datetime = fields.Datetime.from_string(self.requested_date)
req_date = fields.Date.to_string(req_datetime)
if self.warehouse_id and not req_date:
return (priority, self.warehouse_id.id)
if req_date and not self.warehouse_id:
return (priority, str(req_date))
if self.warehouse_id and req_date:
key = '/'.join([str(self.warehouse_id.id), req_date])
return (priority, key)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase
from openerp import fields
from odoo.tests.common import TransactionCase
from odoo import fields
import datetime


Expand All @@ -26,49 +26,66 @@ def setUp(self):
today = datetime.datetime.now()
self.dt1 = today
self.dt2 = today + datetime.timedelta(days=1)

self.sale1 = sale_obj.create({'partner_id': 1})
self.sale_line1 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1})
self.sale_line2 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2})
self.sale_line3 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
'requested_date': self.dt1})
self.sale_line4 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
'requested_date': self.dt2})
self.sale_line1 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1
})
self.sale_line2 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2
})
self.sale_line3 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
'requested_date': self.dt1
})
self.sale_line4 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
'requested_date': self.dt2
})

self.sale2 = sale_obj.create({'partner_id': 1})
self.sale_line5 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1})
self.sale_line6 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2})
self.sale_line7 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1})
self.sale_line8 = order_line.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2})
self.sale_line5 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1
})
self.sale_line6 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2
})
self.sale_line7 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1
})
self.sale_line8 = order_line.create({
'product_id': p1,
'name': 'cool product',
'order_id': self.sale2.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2
})

def test_number_of_groups(self):
"""True when the number of groups created matches the
Expand Down

0 comments on commit c1ad3b3

Please sign in to comment.