Skip to content

Commit

Permalink
[FIX] travis
Browse files Browse the repository at this point in the history
  • Loading branch information
serpentcs-dev1 authored and AaronHForgeFlow committed May 4, 2017
1 parent 26bbe86 commit 8bbadbc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion sale_procurement_group_by_requested_date/README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

========================================
Sale Procurement Group by Requested date
==============================
========================================

This module creates different procurements groups for different requested
dates in a sale order line when the sale order is confirmed.
Expand Down
9 changes: 4 additions & 5 deletions sale_procurement_group_by_requested_date/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api
from datetime import datetime
from openerp.exceptions import Warning


class SaleOrder(models.Model):
_inherit = 'sale.order'
Expand All @@ -28,9 +27,10 @@ def _prepare_procurement_group_by_line(self, line):
if line._get_procurement_group_key()[0] == 9:
if line.requested_date:
vals['name'] = '/'.join([vals['name'], line.warehouse_id.name,
req_date])
req_date])
return vals


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

Expand All @@ -47,6 +47,5 @@ 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)
key = '/'.join([str(self.warehouse_id.id),
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 @@ -6,6 +6,7 @@
from openerp import fields
import datetime


class TestSaleMultiPickingByRequestedDate(TransactionCase):
"""Check the _get_shipped method of Sale Order. """

Expand All @@ -18,29 +19,29 @@ def setUp(self):
SOL = self.env['sale.order.line']
Product = self.env['product.product']
Warehouse = self.env['stock.warehouse']
self.wh1 = Warehouse.create({'name':'wh1','code':'wh1'})
self.wh2 = Warehouse.create({'name':'wh2','code':'wh2'})
p1 = Product.create({'name':'p1', 'type':'product'}).id
self.wh1 = Warehouse.create({'name': 'wh1', 'code': 'wh1'})
self.wh2 = Warehouse.create({'name': 'wh2', 'code': 'wh2'})
p1 = Product.create({'name': 'p1', 'type': 'product'}).id
today = datetime.datetime.now()
self.dt1 = today
self.dt2 = today + datetime.timedelta(days=1)
self.sale1 = SO.create({'partner_id': 1})
self.sale_line1 = SOL.create({'product_id':p1,
self.sale_line1 = SOL.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt1})
self.sale_line2 = SOL.create({'product_id':p1,
self.sale_line2 = SOL.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh1.id,
'requested_date': self.dt2})
self.sale_line3 = SOL.create({'product_id':p1,
self.sale_line3 = SOL.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
'requested_date': self.dt1})
self.sale_line4 = SOL.create({'product_id':p1,
self.sale_line4 = SOL.create({'product_id': p1,
'name': 'cool product',
'order_id': self.sale1.id,
'warehouse_id': self.wh2.id,
Expand Down Expand Up @@ -76,12 +77,12 @@ def test_number_of_groups(self):
self.sale1.action_button_confirm()
req_date = fields.Date.to_string(self.dt1)
g_name = self.sale1.name + '/' + self.wh1.name + '/' + req_date
groups = self.env['procurement.group'].search([('name','=',g_name)])
groups = self.env['procurement.group'].search([('name', '=', g_name)])

for group in groups:
if group.name == g_name:
procurements = self.env['procurement.order'].search([
('group_id','=', group.id)])
('group_id', '=', group.id)])
self.assertEqual(len(procurements), 1)
self.assertEqual(len(group), 1)
ok = True
Expand All @@ -105,4 +106,4 @@ def test_number_of_groups(self):
groups = self.env['procurement.group'].search([('name', 'ilike',
g_name)])
self.assertEqual(len(groups), 2)
self.assertTrue(ok)
self.assertTrue(ok)

0 comments on commit 8bbadbc

Please sign in to comment.