diff options
| author | csn-openerp <csn@openerp.com> | 2013-02-19 10:59:23 +0100 |
|---|---|---|
| committer | csn-openerp <csn@openerp.com> | 2013-02-19 10:59:23 +0100 |
| commit | aca48e943856c7c6f61e9fd4e13ccfd2fc563bc4 (patch) | |
| tree | 3329d22d579e175d606b8f368cd4328dabb0ff8e | |
| parent | 95ff2f9092b1fb216c3806dddfd70988bc301e29 (diff) | |
| parent | e704c22878a65bc9d47e4c73719f3a23d99e23de (diff) | |
[FIX]lunch : fix problem when trying to order a meal on current date and then changing the date, it wasn't updating correctly the date in lunch_order_line
bzr revid: csn@openerp.com-20130219095923-qoewmo8n3kulqo8c
| -rw-r--r-- | addons/lunch/lunch.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index 0f9033fce38..5b5e99b5f51 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -372,12 +372,25 @@ class lunch_order_line(osv.Model): cash_ids = [cash.id for cash in order_line.cashmove] cashmove_ref.unlink(cr, uid, cash_ids, context=context) return self._update_order_lines(cr, uid, ids, context=context) + + def _get_line_order_ids(self, cr, uid, ids, context=None): + """ + return the list of lunch.order.lines ids to which belong the lunch.order 'ids' + """ + result = set() + for lunch_order in self.browse(cr, uid, ids, context=context): + for lines in lunch_order.order_line_ids: + result.add(lines.id) + return list(result) _columns = { 'name': fields.related('product_id', 'name', readonly=True), 'order_id': fields.many2one('lunch.order', 'Order', ondelete='cascade'), 'product_id': fields.many2one('lunch.product', 'Product', required=True), - 'date': fields.related('order_id', 'date', type='date', string="Date", readonly=True, store=True), + 'date': fields.related('order_id', 'date', type='date', string="Date", readonly=True, store={ + 'lunch.order': (_get_line_order_ids, ['date'], 10), + 'lunch.order.line': (lambda self, cr, uid, ids, ctx: ids, [], 10), + }), 'supplier': fields.related('product_id', 'supplier', type='many2one', relation='res.partner', string="Supplier", readonly=True, store=True), 'user_id': fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='User', readonly=True, store=True), 'note': fields.text('Note'), |
