[ADD] Dates on sale order
bzr revid: nel@tinyerp.com-20100615224618-72p7gliuga9579rq
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import sale
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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': 'Customer & Sales',
|
||||
'version': '1.0',
|
||||
'category': 'Generic Modules/CRM & SRM',
|
||||
'description': """Sale Orders Dates""",
|
||||
'author': 'Tiny',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ["sale"],
|
||||
'init_xml': [
|
||||
],
|
||||
|
||||
'update_xml': [
|
||||
'sale_view.xml',
|
||||
],
|
||||
'demo_xml': [
|
||||
],
|
||||
'test': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 osv import fields, osv
|
||||
import time
|
||||
from mx import DateTime
|
||||
class sale_order_dates(osv.osv):
|
||||
_inherit = 'sale.order'
|
||||
_name = 'sale.order'
|
||||
|
||||
def _get_effective_date(self, cr, uid, ids, name, arg, context={}):
|
||||
res = {}
|
||||
dates_list = []
|
||||
for order in self.browse(cr, uid, ids):
|
||||
dates_list = []
|
||||
for pick in order.picking_ids:
|
||||
dates_list.append(pick.date)
|
||||
if dates_list:
|
||||
res[order.id] = min(dates_list)
|
||||
else:
|
||||
res[order.id] =False
|
||||
return res
|
||||
|
||||
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}):
|
||||
res = {}
|
||||
dates_list = []
|
||||
for order in self.browse(cr, uid, ids):
|
||||
dates_list = []
|
||||
for line in order.order_line:
|
||||
dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0)
|
||||
dt_s = dt.strftime('%Y-%m-%d')
|
||||
dates_list.append(dt_s)
|
||||
res[order.id] = min(dates_list)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'commitment_date': fields.function(_get_commitment_date, method=True,store=True, type='date', string='Commitment Date'),
|
||||
'requested_date': fields.date('Requested Date'),
|
||||
'effective_date': fields.function(_get_effective_date, method=True, type='date', store=True,string='Effective Date'),
|
||||
}
|
||||
sale_order_dates()
|
||||
"""
|
||||
- date_commitment: min(fields.function using delay on SO lines +
|
||||
date_order)
|
||||
- date_requested: fields.date
|
||||
- Effective date: fields.function the first picking done.
|
||||
"""
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_sale_orderfor" model="ir.ui.view">
|
||||
<field name="name">sale.order.form.inherit5</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_confirm" position="after">
|
||||
<separator string="Dates" colspan="4"/>
|
||||
<field name="commitment_date"/>
|
||||
<newline/>
|
||||
<field name="effective_date"/>
|
||||
<field name="requested_date"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user