[MERGE] [IMP] purchase_order: allow the user to choose the currency, whatever the pricelist. By default the currency is the one defined on the user's company.
bzr revid: tde@openerp.com-20130612145313-blrfa4gmrtuq5dmu
This commit is contained in:
@@ -186,7 +186,7 @@ class purchase_order(osv.osv):
|
||||
'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse'),
|
||||
'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')], states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]} ),
|
||||
'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, help="The pricelist sets the currency used for this purchase order. It also computes the supplier price for the selected products/quantities."),
|
||||
'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency",readonly=True, required=True),
|
||||
'currency_id': fields.many2one('res.currency','Currency', readonly=True, required=True,states={'draft': [('readonly', False)],'sent': [('readonly', False)]}),
|
||||
'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, help="The status of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' status. Then the order has to be confirmed by the user, the status switch to 'Confirmed'. Then the supplier must confirm the order to change the status to 'Approved'. When the purchase order is paid and received, the status becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the status becomes in exception.", select=True),
|
||||
'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines', states={'approved':[('readonly',True)],'done':[('readonly',True)]}),
|
||||
'validator' : fields.many2one('res.users', 'Validated by', readonly=True),
|
||||
@@ -237,6 +237,7 @@ class purchase_order(osv.osv):
|
||||
'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id,
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c),
|
||||
'journal_id': _get_journal,
|
||||
'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
|
||||
}
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'),
|
||||
@@ -544,7 +545,7 @@ class purchase_order(osv.osv):
|
||||
'account_id': pay_acc_id,
|
||||
'type': 'in_invoice',
|
||||
'partner_id': order.partner_id.id,
|
||||
'currency_id': order.pricelist_id.currency_id.id,
|
||||
'currency_id': order.currency_id.id,
|
||||
'journal_id': len(journal_ids) and journal_ids[0] or False,
|
||||
'invoice_line': [(6, 0, inv_lines)],
|
||||
'origin': order.name,
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_supplier':1,'default_supplier':1,'default_customer':0}" domain="[('supplier','=',True)]"/>
|
||||
<field name="partner_ref"/>
|
||||
<field domain="[('type','=','purchase')]" name="pricelist_id" groups="product.group_purchase_pricelist" on_change="onchange_pricelist(pricelist_id, context)"/>
|
||||
<field name="currency_id" invisible='1'/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="journal_id" invisible='1'/>
|
||||
</group>
|
||||
<group>
|
||||
|
||||
@@ -70,7 +70,7 @@ class stock_picking(osv.osv):
|
||||
|
||||
def get_currency_id(self, cursor, user, picking):
|
||||
if picking.purchase_id:
|
||||
return picking.purchase_id.pricelist_id.currency_id.id
|
||||
return picking.purchase_id.currency_id.id
|
||||
else:
|
||||
return super(stock_picking, self).get_currency_id(cursor, user, picking)
|
||||
|
||||
@@ -129,7 +129,7 @@ class stock_partial_picking(osv.osv_memory):
|
||||
def _product_cost_for_average_update(self, cr, uid, move):
|
||||
if move.picking_id.purchase_id:
|
||||
return {'cost': move.purchase_line_id.price_unit,
|
||||
'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id}
|
||||
'currency': move.picking_id.purchase_id.currency_id.id}
|
||||
return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move)
|
||||
|
||||
# Redefinition of the new field in order to update the model stock.picking.in in the orm
|
||||
|
||||
@@ -83,7 +83,7 @@ class purchase_line_invoice(osv.osv_memory):
|
||||
'account_id': a,
|
||||
'partner_id': partner.id,
|
||||
'invoice_line': [(6,0,lines_ids)],
|
||||
'currency_id' : orders[0].pricelist_id.currency_id.id,
|
||||
'currency_id' : orders[0].currency_id.id,
|
||||
'comment': multiple_order_invoice_notes(orders),
|
||||
'payment_term': orders[0].payment_term_id.id,
|
||||
'fiscal_position': partner.property_account_position.id
|
||||
|
||||
Reference in New Issue
Block a user