diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 5e37350376c..ce024b1a5cb 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -68,18 +68,21 @@ class purchase_order(osv.osv): if type(ids)!=type([]): ids=[ids] for po in self.browse(cr, uid, ids, context=context): - cr.execute("""update purchase_order_line set - date_planned=%s - where - order_id=%s and - (date_planned=%s or date_planned<%s)""", (value,po.id,po.minimum_planned_date,value)) + if po.order_line: + cr.execute("""update purchase_order_line set + date_planned=%s + where + order_id=%s and + (date_planned=%s or date_planned<%s)""", (value,po.id,po.minimum_planned_date,value)) + cr.execute("""update purchase_order set + minimum_planned_date=%s where id=%s""", (value, po.id)) return True def _minimum_planned_date(self, cr, uid, ids, field_name, arg, context=None): res={} purchase_obj=self.browse(cr, uid, ids, context=context) for purchase in purchase_obj: - res[purchase.id] = time.strftime('%Y-%m-%d %H:%M:%S') + res[purchase.id] = False if purchase.order_line: min_date=purchase.order_line[0].date_planned for line in purchase.order_line: @@ -191,7 +194,11 @@ class purchase_order(osv.osv): "From Picking: a draft invoice will be pre-generated based on validated receptions.\n" \ "Manual: allows you to generate suppliers invoices by chosing in the uninvoiced lines of all manual purchase orders." ), - 'minimum_planned_date':fields.function(_minimum_planned_date, fnct_inv=_set_minimum_planned_date, method=True,store=True, string='Expected Date', type='date', select=True, help="This is computed as the minimum scheduled date of all purchase order lines' products."), + 'minimum_planned_date':fields.function(_minimum_planned_date, fnct_inv=_set_minimum_planned_date, method=True, string='Expected Date', type='date', select=True, help="This is computed as the minimum scheduled date of all purchase order lines' products.", + store = { + 'purchase.order.line': (_get_order, ['date_planned'], 10), + } + ), 'amount_untaxed': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Purchase Price'), string='Untaxed Amount', store={ 'purchase.order.line': (_get_order, None, 10), @@ -693,7 +700,7 @@ class purchase_order_line(osv.osv): dt = (datetime.now() + relativedelta(days=int(seller_delay) or 0.0)).strftime('%Y-%m-%d %H:%M:%S') - res.update({'value': {'price_unit': price, 'name': name or prod_name, + res.update({'value': {'price_unit': price, 'name': prod_name, 'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id), 'date_planned': date_planned or dt,'notes': notes or prod.description_purchase, 'product_qty': qty, @@ -714,9 +721,11 @@ class purchase_order_line(osv.osv): return res def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom, - partner_id, date_order=False,fiscal_position=False): + partner_id, date_order=False, fiscal_position=False, date_planned=False, + name=False, price_unit=False, notes=False): res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom, - partner_id=partner_id, date_order=date_order,fiscal_position=fiscal_position) + partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned, + name=name, price_unit=price_unit, notes=notes) if 'product_uom' in res['value']: if uom and (uom != res['value']['product_uom']) and res['value']['product_uom']: seller_uom_name = self.pool.get('product.uom').read(cr, uid, [res['value']['product_uom']], ['name'])[0]['name'] diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 7ee96dca850..cb83841f005 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -318,7 +318,7 @@ - + diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 05f1b5e9a0b..b632101208f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -209,7 +209,7 @@ class stock_location(osv.osv): 'company_id': fields.many2one('res.company', 'Company', select=1, help='Let this field empty if this location is shared between all companies'), 'scrap_location': fields.boolean('Scrap Location', help='Check this box to allow using this location to put scrapped/damaged goods.'), 'valuation_in_account_id': fields.many2one('account.account', 'Stock Input Account',domain = [('type','=','other')], help='This account will be used to value stock moves that have this location as destination, instead of the stock output account from the product.'), - 'valuation_out_account_id': fields.many2one('account.account', 'Stock Output Account',domain = [('type','=','other')], help='This account will be used ta value stock moves that have this location as source, instead of the stock input account from the product.'), + 'valuation_out_account_id': fields.many2one('account.account', 'Stock Output Account',domain = [('type','=','other')], help='This account will be used to value stock moves that have this location as source, instead of the stock input account from the product.'), } _defaults = { 'active': True, diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 19523e5b81b..0a2d3a8728d 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -738,10 +738,6 @@ groups="base.group_extended" icon="terp-stock_effects-object-colorize" states="draft,assigned,confirmed"/> -