Maintenance
- OpenERP
- 4.5 years (for 3 LT series + 1 series)
- Tryton
- 2.5 years (for 5 series)
Author: | Cédric Krier |
---|---|
Date: | 2011-11-11 |
No coding style
Custom YAML
Which one do you want to read every day?
13 tests
54% coverage
310 tests
69% coverage
Manage shipment and invoice exception
Show by default <1 year old
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for order in self.browse(cr, uid, ids, context=context):
...
return res
'amount_total': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Total',
store = {
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The total amount."),
total_amount = fields.Function(fields.Numeric('Total',
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits']), 'get_total_amount')
def get_total_amount(self, ids, name):
result = {}
for sale in self.browse(ids):
...
return result
<field name="partner_id"
on_change="onchange_partner_id(partner_id)"
domain="[('customer','=',True)]"
context="{'search_default_customer':1}"
required="1"/>
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact'])
part = self.pool.get('res.partner').browse(cr, uid, part)
...
return {'value': val}
party = fields.Many2One('party.party', 'Party',
required=True, select=1, states={
'readonly': Eval('state') != 'draft',
}, on_change=['party', 'payment_term'],
depends=['state'])
def on_change_party(self, values):
party_obj = Pool().get('party.party')
res = {}
if values.get('party'):
party = party_obj.browse(values['party'])
...
return res
'amount_total': fields.function(_amount_all,
digits_compute= dp.get_precision('Sale Price'), string='Total',
store = {
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The total amount."),
currency_digits = fields.Function(fields.Integer('Currency Digits',
on_change_with=['currency']), 'get_function_fields')
total_amount = fields.Function(fields.Numeric('Total',
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits']), 'get_total_amount')