Changed the type of fields.date_order on purhcase.order object from date to datetime
This commit is contained in:
parent
957c0cca1c
commit
e9abc723c0
|
@ -209,9 +209,9 @@ class purchase_order(osv.osv):
|
||||||
"It's mainly used to do the matching when you receive the "
|
"It's mainly used to do the matching when you receive the "
|
||||||
"products as this reference is usually written on the "
|
"products as this reference is usually written on the "
|
||||||
"delivery order sent by your supplier."),
|
"delivery order sent by your supplier."),
|
||||||
'date_order':fields.date('Order Date', required=True, states={'confirmed':[('readonly',True)],
|
'date_order':fields.datetime('Order Date', required=True, states={'confirmed':[('readonly',True)],
|
||||||
'approved':[('readonly',True)]},
|
'approved':[('readonly',True)]},
|
||||||
select=True, help="Date on which this document has been created.",
|
select=True, help="Depicts the date where the Quotation should be validated and converted into a Purchase Order, by default it's the creation date.",
|
||||||
copy=False),
|
copy=False),
|
||||||
'date_approve':fields.date('Date Approved', readonly=1, select=True, copy=False,
|
'date_approve':fields.date('Date Approved', readonly=1, select=True, copy=False,
|
||||||
help="Date on which purchase order has been approved"),
|
help="Date on which purchase order has been approved"),
|
||||||
|
@ -290,7 +290,7 @@ class purchase_order(osv.osv):
|
||||||
'invoice_count': fields.function(_count_all, type='integer', string='Invoices', multi=True)
|
'invoice_count': fields.function(_count_all, type='integer', string='Invoices', multi=True)
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'date_order': fields.date.context_today,
|
'date_order': fields.datetime.now,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'name': lambda obj, cr, uid, context: '/',
|
'name': lambda obj, cr, uid, context: '/',
|
||||||
'shipped': 0,
|
'shipped': 0,
|
||||||
|
@ -710,7 +710,7 @@ class purchase_order(osv.osv):
|
||||||
'product_id': order_line.product_id.id,
|
'product_id': order_line.product_id.id,
|
||||||
'product_uom': order_line.product_uom.id,
|
'product_uom': order_line.product_uom.id,
|
||||||
'product_uos': order_line.product_uom.id,
|
'product_uos': order_line.product_uom.id,
|
||||||
'date': fields.date.date_to_datetime(self, cr, uid, order.date_order, context),
|
'date': order.date_order,
|
||||||
'date_expected': fields.date.date_to_datetime(self, cr, uid, order_line.date_planned, context),
|
'date_expected': fields.date.date_to_datetime(self, cr, uid, order_line.date_planned, context),
|
||||||
'location_id': order.partner_id.property_stock_supplier.id,
|
'location_id': order.partner_id.property_stock_supplier.id,
|
||||||
'location_dest_id': order.location_id.id,
|
'location_dest_id': order.location_id.id,
|
||||||
|
@ -980,8 +980,8 @@ class purchase_order_line(osv.osv):
|
||||||
'order_line_id', 'invoice_id', 'Invoice Lines',
|
'order_line_id', 'invoice_id', 'Invoice Lines',
|
||||||
readonly=True, copy=False),
|
readonly=True, copy=False),
|
||||||
'invoiced': fields.boolean('Invoiced', readonly=True, copy=False),
|
'invoiced': fields.boolean('Invoiced', readonly=True, copy=False),
|
||||||
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner", store=True),
|
'partner_id': fields.related('order_id', 'partner_id', string='Partner', readonly=True, type="many2one", relation="res.partner", store=True),
|
||||||
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date"),
|
'date_order': fields.related('order_id', 'date_order', string='Order Date', readonly=True, type="datetime"),
|
||||||
'procurement_ids': fields.one2many('procurement.order', 'purchase_line_id', string='Associated procurements'),
|
'procurement_ids': fields.one2many('procurement.order', 'purchase_line_id', string='Associated procurements'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
|
@ -1026,13 +1026,13 @@ class purchase_order_line(osv.osv):
|
||||||
|
|
||||||
:param browse_record | False supplier_info: product.supplierinfo, used to
|
:param browse_record | False supplier_info: product.supplierinfo, used to
|
||||||
determine delivery delay (if False, default delay = 0)
|
determine delivery delay (if False, default delay = 0)
|
||||||
:param str date_order_str: date of order, as a string in
|
:param str date_order_str: date of order field, as a string in
|
||||||
DEFAULT_SERVER_DATE_FORMAT
|
DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
:rtype: datetime
|
:rtype: datetime
|
||||||
:return: desired Schedule Date for the PO line
|
:return: desired Schedule Date for the PO line
|
||||||
"""
|
"""
|
||||||
supplier_delay = int(supplier_info.delay) if supplier_info else 0
|
supplier_delay = int(supplier_info.delay) if supplier_info else 0
|
||||||
return datetime.strptime(date_order_str, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=supplier_delay)
|
return datetime.strptime(date_order_str, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=supplier_delay)
|
||||||
|
|
||||||
def action_cancel(self, cr, uid, ids, context=None):
|
def action_cancel(self, cr, uid, ids, context=None):
|
||||||
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
|
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
|
||||||
|
@ -1101,7 +1101,7 @@ class purchase_order_line(osv.osv):
|
||||||
|
|
||||||
# - determine product_qty and date_planned based on seller info
|
# - determine product_qty and date_planned based on seller info
|
||||||
if not date_order:
|
if not date_order:
|
||||||
date_order = fields.date.context_today(self,cr,uid,context=context)
|
date_order = fields.datetime.now()
|
||||||
|
|
||||||
|
|
||||||
supplierinfo = False
|
supplierinfo = False
|
||||||
|
@ -1125,8 +1125,9 @@ class purchase_order_line(osv.osv):
|
||||||
if state not in ('sent','bid'):
|
if state not in ('sent','bid'):
|
||||||
# - determine price_unit and taxes_id
|
# - determine price_unit and taxes_id
|
||||||
if pricelist_id:
|
if pricelist_id:
|
||||||
|
date_order_str = datetime.strptime(date_order, DEFAULT_SERVER_DATETIME_FORMAT).strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||||
price = product_pricelist.price_get(cr, uid, [pricelist_id],
|
price = product_pricelist.price_get(cr, uid, [pricelist_id],
|
||||||
product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order})[pricelist_id]
|
product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order_str})[pricelist_id]
|
||||||
else:
|
else:
|
||||||
price = product.standard_price
|
price = product.standard_price
|
||||||
|
|
||||||
|
@ -1320,8 +1321,8 @@ class procurement_order(osv.osv):
|
||||||
po_id = available_draft_po_ids[0]
|
po_id = available_draft_po_ids[0]
|
||||||
po_rec = po_obj.browse(cr, uid, po_id, context=context)
|
po_rec = po_obj.browse(cr, uid, po_id, context=context)
|
||||||
#if the product has to be ordered earlier those in the existing PO, we replace the purchase date on the order to avoid ordering it too late
|
#if the product has to be ordered earlier those in the existing PO, we replace the purchase date on the order to avoid ordering it too late
|
||||||
if datetime.strptime(po_rec.date_order, DEFAULT_SERVER_DATE_FORMAT) > purchase_date:
|
if datetime.strptime(po_rec.date_order, DEFAULT_SERVER_DATETIME_FORMAT) > purchase_date:
|
||||||
po_obj.write(cr, uid, [po_id], {'date_order': purchase_date}, context=context)
|
po_obj.write(cr, uid, [po_id], {'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}, context=context)
|
||||||
#look for any other PO line in the selected PO with same product and UoM to sum quantities instead of creating a new po line
|
#look for any other PO line in the selected PO with same product and UoM to sum quantities instead of creating a new po line
|
||||||
available_po_line_ids = po_line_obj.search(cr, uid, [('order_id', '=', po_id), ('product_id', '=', line_vals['product_id']), ('product_uom', '=', line_vals['product_uom'])], context=context)
|
available_po_line_ids = po_line_obj.search(cr, uid, [('order_id', '=', po_id), ('product_id', '=', line_vals['product_id']), ('product_uom', '=', line_vals['product_uom'])], context=context)
|
||||||
if available_po_line_ids:
|
if available_po_line_ids:
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
"code": "EUR",
|
"code": "EUR",
|
||||||
"symbol": "€",
|
"symbol": "€",
|
||||||
},
|
},
|
||||||
"date_order": "2011-09-13",
|
"date_order": "2011-09-13 12:00:00",
|
||||||
"partner_id": ["sale:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_test22", "Junjun wala"],
|
"partner_id": ["sale:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_test22", "Junjun wala"],
|
||||||
"partner_address": {
|
"partner_address": {
|
||||||
"__id": "base:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_address_7wdsjasdjh",
|
"__id": "base:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_address_7wdsjasdjh",
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
"code": "EUR",
|
"code": "EUR",
|
||||||
"symbol": "€",
|
"symbol": "€",
|
||||||
},
|
},
|
||||||
"date_order": "2011-09-13",
|
"date_order": "2011-09-13 12:00:00",
|
||||||
"partner_id": ["sale:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_test22", "Junjun wala"],
|
"partner_id": ["sale:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_test22", "Junjun wala"],
|
||||||
"partner_address": {
|
"partner_address": {
|
||||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_address_7wdsjasdjh",
|
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_address_7wdsjasdjh",
|
||||||
|
@ -234,4 +234,4 @@
|
||||||
assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,)
|
assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,)
|
||||||
assert purchase_line.product_qty == 10 , "product qty is not same"
|
assert purchase_line.product_qty == 10 , "product qty is not same"
|
||||||
else:
|
else:
|
||||||
raise AssertionError('unknown order line: %s' % purchase_line)
|
raise AssertionError('unknown order line: %s' % purchase_line)
|
||||||
|
|
|
@ -20,8 +20,10 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import fields, osv
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
import openerp.addons.decimal_precision as dp
|
import openerp.addons.decimal_precision as dp
|
||||||
|
|
||||||
class purchase_requisition(osv.osv):
|
class purchase_requisition(osv.osv):
|
||||||
|
@ -134,7 +136,7 @@ class purchase_requisition(osv.osv):
|
||||||
picking_type_in = self.pool.get("purchase.order")._get_picking_in(cr, uid, context=context)
|
picking_type_in = self.pool.get("purchase.order")._get_picking_in(cr, uid, context=context)
|
||||||
return {
|
return {
|
||||||
'origin': requisition.name,
|
'origin': requisition.name,
|
||||||
'date_order': requisition.date_end or fields.date.context_today(self, cr, uid, context=context),
|
'date_order': requisition.date_end or fields.datetime.now(),
|
||||||
'partner_id': supplier.id,
|
'partner_id': supplier.id,
|
||||||
'pricelist_id': supplier_pricelist,
|
'pricelist_id': supplier_pricelist,
|
||||||
'location_id': requisition.picking_type_id.default_location_dest_id.id,
|
'location_id': requisition.picking_type_id.default_location_dest_id.id,
|
||||||
|
@ -150,7 +152,7 @@ class purchase_requisition(osv.osv):
|
||||||
product_uom = self.pool.get('product.uom')
|
product_uom = self.pool.get('product.uom')
|
||||||
product = requisition_line.product_id
|
product = requisition_line.product_id
|
||||||
default_uom_po_id = product.uom_po_id.id
|
default_uom_po_id = product.uom_po_id.id
|
||||||
date_order = requisition.ordering_date or fields.date.context_today(self, cr, uid, context=context)
|
date_order = requisition.ordering_date and datetime.strptime(requisition.ordering_date, DEFAULT_SERVER_DATE_FORMAT).strftime(DEFAULT_SERVER_DATETIME_FORMAT) or fields.datetime.now()
|
||||||
qty = product_uom._compute_qty(cr, uid, requisition_line.product_uom_id.id, requisition_line.product_qty, default_uom_po_id)
|
qty = product_uom._compute_qty(cr, uid, requisition_line.product_uom_id.id, requisition_line.product_qty, default_uom_po_id)
|
||||||
supplier_pricelist = supplier.property_product_pricelist_purchase and supplier.property_product_pricelist_purchase.id or False
|
supplier_pricelist = supplier.property_product_pricelist_purchase and supplier.property_product_pricelist_purchase.id or False
|
||||||
vals = po_line_obj.onchange_product_id(
|
vals = po_line_obj.onchange_product_id(
|
||||||
|
|
Loading…
Reference in New Issue