Skip to content

Commit

Permalink
Merge 2b5d505 into fe9ac6d
Browse files Browse the repository at this point in the history
  • Loading branch information
kittiu committed Jun 21, 2015
2 parents fe9ac6d + 2b5d505 commit b576bcf
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sale_expected_delivery_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#
#
# Author: Kitti U. <kittiu@gmail.com>
# Copyright 2015 Ecosoft
#
# 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 details.
#
# 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 . import model
47 changes: 47 additions & 0 deletions sale_expected_delivery_date/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
#
# Author: Kitti U. <kittiu@gmail.com>
# Copyright 2015 Ecosoft
#
# 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 details.
#
# 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/>.
#
#

{
'name': 'Sales Expected Delivery Date',
'version': '1.0',
'author': "Ecosoft, Odoo Community Association (OCA)",
'category': 'Sale',
'license': 'AGPL-3',
'complexity': 'easy',
'images': [],
'website': "http://www.ecosoft.co.th",
'description': """
This module provides "Expected Delivery Date" in Sales Order.
This date will be used for DO's Scheduled Time instead of standard use of Product's customer lead time (will be ignored).
""",
'depends': ['sale',
'sale_stock'
],
'demo': [],
'data': ['view/sale_view.xml',
],
'auto_install': False,
'test': [
'test/sale_expected_delivery_date.yml',
],
'installable': True,
}

22 changes: 22 additions & 0 deletions sale_expected_delivery_date/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
#
#
# Author: Kitti U. <kittiu@gmail.com>
# Copyright 2015 Ecosoft
#
# 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 details.
#
# 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 . import sale
41 changes: 41 additions & 0 deletions sale_expected_delivery_date/model/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
#
#
# Author: Kitti U. <kittiu@gmail.com>
# Copyright 2015 Ecosoft
#
# 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 details.
#
# 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
from datetime import datetime

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

date_expected = fields.Date(
string='Expected Delivery Date',
required=True,
readonly=True,
states={'draft': [('readonly', False)]},
default=lambda *a: datetime.now().strftime('%Y-%m-%d'),
)

@api.v7
def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
# Overwrite with this date
return order.date_expected

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
23 changes: 23 additions & 0 deletions sale_expected_delivery_date/test/sale_expected_delivery_date.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-
In order to test that expected delivery date will be used as scheduled date in delivery order
I create a Quotation
-
!record {model: sale.order, id: sale_order_expected_delivery_01}:
partner_id: base.res_partner_2
order_policy: 'picking'
date_expected: '2015-06-28'
order_line:
- product_id: stock.product_icecream_product_template
product_uom_qty: 1

-
I confirm the Quotation with "On Delivery Order" order policy.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_expected_delivery_01}

-
I check Delivery Order being created, and check if it is using expected delivery date as scheduled date
-
!python {model: sale.order}: |
order = self.browse(cr, uid, ref('sale_order_expected_delivery_01'))
assert order.picking_ids[0].min_date[:10] == order.date_expected, "Delivery Order is not using Sales Order's Expected Delivery Date"
16 changes: 16 additions & 0 deletions sale_expected_delivery_date/view/sale_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_order_form_ext" model="ir.ui.view">
<field name="name">view.order.form.ext</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="date_order" position="after">
<field name='date_expected'/>
</field>
</field>
</record>
</data>
</openerp>

0 comments on commit b576bcf

Please sign in to comment.