[IMP] sale, sale_margin: added monetary widget on sale order form view

bzr revid: qdp-launchpad@openerp.com-20121010111205-eokyh1haa69tgrfl
This commit is contained in:
Quentin (OpenERP) 2012-10-10 13:12:05 +02:00
parent 7c6e893a39
commit 1bb568d22e
3 changed files with 13 additions and 6 deletions

View File

@ -201,6 +201,7 @@ class sale_order(osv.osv):
help="""This field controls how invoice and delivery operations are synchronized.
- With 'Before Delivery', a draft invoice is created, and it must be paid before delivery."""),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."),
'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", readonly=True, required=True),
'project_id': fields.many2one('account.analytic.account', 'Contract/Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."),
'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
@ -264,13 +265,18 @@ class sale_order(osv.osv):
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
if (not pricelist_id) or (not order_lines):
if not pricelist_id:
return {}
value = {
'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id
}
if not order_lines:
return {'value': value}
warning = {
'title': _('Pricelist Warning!'),
'message' : _('If you change the pricelist of this order (and eventually the currency), prices of existing order lines will not be updated.')
}
return {'warning': warning}
return {'warning': warning, 'value': value}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:

View File

@ -184,6 +184,7 @@
<field name="shop_id" groups="base.group_no_one" on_change="onchange_shop_id(shop_id, context)" widget="selection"/>
<field name="client_order_ref"/>
<field domain="[('type','=','sale')]" name="pricelist_id" groups="product.group_sale_pricelist" on_change="onchange_pricelist_id(pricelist_id,order_line)"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
<notebook>
@ -261,14 +262,14 @@
</tree>
</field>
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
<field name="amount_untaxed"/>
<field name="amount_tax"/>
<field name="amount_untaxed" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_tax" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div class="oe_subtotal_footer_separator oe_inline">
<label for="amount_total" />
<button name="button_dummy"
states="draft" string="(update)" type="object" class="oe_edit_only oe_link"/>
</div>
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator"/>
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
<group name="sale_margin_grp">
</group>

View File

@ -11,7 +11,7 @@
<group>
<label for="margin"/>
<div>
<field name="margin"/>
<field name="margin" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</div>
</group>
</xpath>